Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / examples / Event_Comm / Notifier_Handler.cpp
blobeb4ed104bcfef6815601eaa4b002d5318b5f4748
1 #include "Notifier_Handler.h"
2 #include "tao/ORB_Core.h"
4 int
5 Notifier_Handler::close ()
7 if (this->notifier_ != 0)
9 ACE_DEBUG ((LM_DEBUG,
10 "closing down Notifier_Handler\n"));
11 CORBA::release (this->notifier_);
12 this->notifier_ = 0;
15 // shutdown the ORB.
16 this->orb_->shutdown ();
17 return 0;
20 void
21 Notifier_Handler::shutdown ()
23 ACE_ASSERT (this->shutdowncallback != 0);
25 this->shutdowncallback->close ();
28 int
29 Notifier_Handler::run ()
31 ACE_DEBUG ((LM_DEBUG,
32 "Running the Supplier...\n"));
33 // Run the ORB.
34 this->orb_->run ();
35 return 0;
38 ACE_Reactor*
39 Notifier_Handler::reactor()
41 // @@ Please see if there's a way to get to the Reactor without
42 // using the TAO_ORB_Core_instance().
43 return TAO_ORB_Core_instance ()->reactor ();
46 Event_Comm::Notifier *
47 Notifier_Handler::notifier ()
49 return this->notifier_;
52 void
53 Notifier_Handler::notifier (Event_Comm::Notifier *notifier)
55 if (this->notifier_ != notifier)
57 CORBA::release (this->notifier_);
58 this->notifier_ = notifier;
62 // Init function.
63 int
64 Notifier_Handler::init (int argc,
65 ACE_TCHAR *argv[],
66 ShutdownCallback* _shutdowncallback)
68 // set the callback
69 shutdowncallback = _shutdowncallback;
71 try
73 // Retrieve the ORB.
74 this->orb_ = CORBA::ORB_init (argc, argv);
76 CORBA::Object_var poa_object =
77 this->orb_->resolve_initial_references ("RootPOA");
79 PortableServer::POA_var poa =
80 PortableServer::POA::_narrow (poa_object.in ());
82 PortableServer::POAManager_var poa_manager =
83 poa->the_POAManager ();
85 poa_manager->activate ();
87 // Initialization of the naming service.
88 if (this->naming_client_.init (orb_.in ()) != 0)
89 ACE_ERROR_RETURN ((LM_ERROR,
90 "(%P|%t) Unable to initialize "
91 "the TAO_Naming_Client.\n"),
92 -1);
94 CosNaming::Name notifier_ref_name (1);
95 notifier_ref_name.length (1);
96 notifier_ref_name[0].id =
97 CORBA::string_dup (NOTIFIER_BIND_NAME);
99 CORBA::Object_var notifier_obj =
100 this->naming_client_->resolve (notifier_ref_name);
103 // The CORBA::Object_var object is downcast to Notifier_var
104 // using the <_narrow> method.
105 this->notifier_ =
106 Event_Comm::Notifier::_narrow (notifier_obj.in ());
108 catch (const CORBA::Exception& ex)
110 ex._tao_print_exception ("Notifier_Handler::init\n");
111 return -1;
114 return 0;