Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / docs / tutorials / Quoter / RT_Event_Service / client.cpp
blob87207772bf99aca6d9cf0c928803e86dbb9434d3
2 #include "Stock_Consumer.h"
3 #include <orbsvcs/CosNamingC.h>
4 #include <orbsvcs/Event_Utilities.h>
5 #include "ace/streams.h"
6 #include "ace/OS_NS_string.h"
7 #include "tao/Exception.h"
9 int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
11 try {
12 // First initialize the ORB, that will remove some arguments...
13 CORBA::ORB_var orb =
14 CORBA::ORB_init (argc, argv);
15 CORBA::Object_var poa_object =
16 orb->resolve_initial_references ("RootPOA");
17 PortableServer::POA_var poa =
18 PortableServer::POA::_narrow (poa_object.in ());
19 PortableServer::POAManager_var poa_manager =
20 poa->the_POAManager ();
21 poa_manager->activate ();
23 CORBA::Object_var naming_context_object =
24 orb->resolve_initial_references ("NameService");
25 CosNaming::NamingContext_var naming_context =
26 CosNaming::NamingContext::_narrow (naming_context_object.in ());
28 CosNaming::Name name (1);
29 name.length (1);
30 name[0].id = CORBA::string_dup ("EventService");
32 CORBA::Object_var ec_object =
33 naming_context->resolve (name);
35 // Now downcast the object reference to the appropriate type
36 RtecEventChannelAdmin::EventChannel_var ec =
37 RtecEventChannelAdmin::EventChannel::_narrow (ec_object.in ());
39 ACE_ConsumerQOS_Factory qos;
40 qos.start_disjunction_group ();
42 for (int i = 1; i != argc; ++i) {
43 if (ACE_OS::strlen (argv[i]) < 4)
44 continue;
46 CORBA::ULong type =
47 ((int(argv[i][0]) << 24)
48 | (int(argv[i][1]) << 16)
49 | (int(argv[i][2]) << 8)
50 | int(argv[i][3]));
52 qos.insert_type (type, 0);
55 Stock_Consumer stock_consumer_i;
56 stock_consumer_i.connect (ec.in (), qos.get_ConsumerQOS ());
58 orb->run ();
60 stock_consumer_i.disconnect ();
62 poa->destroy (true, true);
63 orb->destroy ();
65 catch (const CORBA::Exception &ex) {
66 cerr << "CORBA exception raised!" << ex << endl;
68 return 0;