Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / docs / tutorials / Quoter / Event_Service / client.cpp
blob858ac20a3f52691778f011ad32f776b792e37c6e
2 #include "Stock_Consumer.h"
3 #include <orbsvcs/CosNamingC.h>
4 #include "ace/streams.h"
6 int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
8 try {
9 // First initialize the ORB, that will remove some arguments...
10 CORBA::ORB_var orb =
11 CORBA::ORB_init (argc, argv);
12 CORBA::Object_var poa_object =
13 orb->resolve_initial_references ("RootPOA");
14 PortableServer::POA_var poa =
15 PortableServer::POA::_narrow (poa_object.in ());
16 PortableServer::POAManager_var poa_manager =
17 poa->the_POAManager ();
18 poa_manager->activate ();
20 CORBA::Object_var naming_context_object =
21 orb->resolve_initial_references ("NameService");
22 CosNaming::NamingContext_var naming_context =
23 CosNaming::NamingContext::_narrow (naming_context_object.in ());
25 CosNaming::Name name (1);
26 name.length (1);
27 name[0].id = CORBA::string_dup ("CosEventService");
29 CORBA::Object_var ec_object =
30 naming_context->resolve (name);
32 // Now downcast the object reference to the appropriate type
33 CosEventChannelAdmin::EventChannel_var ec =
34 CosEventChannelAdmin::EventChannel::_narrow (ec_object.in ());
36 Stock_Consumer stock_consumer_i;
37 stock_consumer_i.connect (ec.in ());
39 orb->run ();
41 stock_consumer_i.disconnect ();
43 poa->destroy (true, true);
44 orb->destroy ();
46 catch (const CORBA::Exception &) {
47 cerr << "CORBA exception raised!" << endl;
49 return 0;