Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Notify / lib / Peer_T.cpp
bloba6d350b7010e8b991e63c65194017afd1b9694eb
1 #ifndef TAO_Notify_Tests_Peer_T_CPP
2 #define TAO_Notify_Tests_Peer_T_CPP
4 #include "Peer_T.h"
6 #include "ace/Arg_Shifter.h"
7 #include "Name.h"
8 #include "LookupManager.h"
9 #include "Options_Parser.h"
10 #include "orbsvcs/NotifyExtC.h"
12 template <class Peer_Traits>
13 TAO_Notify_Tests_Peer_T<Peer_Traits>::TAO_Notify_Tests_Peer_T ()
14 : proxy_id_ (0)
18 template <class Peer_Traits>
19 TAO_Notify_Tests_Peer_T<Peer_Traits>::~TAO_Notify_Tests_Peer_T ()
23 template <class Peer_Traits>
24 typename TAO_Notify_Tests_Peer_T<Peer_Traits>::Proxy_Traits_PTR
25 TAO_Notify_Tests_Peer_T<Peer_Traits>::get_proxy ()
27 return proxy_.in ();
30 template <class Peer_Traits>
31 typename TAO_Notify_Tests_Peer_T<Peer_Traits>::Peer_Traits_PTR
32 TAO_Notify_Tests_Peer_T<Peer_Traits>::activate ()
34 return this->_this ();
37 template <class Peer_Traits>
38 void
39 TAO_Notify_Tests_Peer_T<Peer_Traits>::connect (Proxy_Traits_PTR proxy,
40 Proxy_Traits_ID proxy_id)
42 // This will decr the ref count on exit.
43 // Clients of this class should use raw pointers, not vars.
44 PortableServer::ServantBase_var servant_var (this);
46 typename Peer_Traits::VAR peer_var =
47 this->activate ();
49 this->connect_to_peer (proxy, peer_var.in ());
51 // save the proxy
52 this->proxy_ = Proxy_Traits_INTERFACE::_duplicate (proxy);
53 this->proxy_id_ = proxy_id;
55 // Register the proxy.
56 if (this->proxy_name_.length () != 0)
58 LOOKUP_MANAGER->_register (this->proxy_.in (),
59 this->proxy_name_.c_str ());
63 template <class Peer_Traits>
64 void
65 TAO_Notify_Tests_Peer_T<Peer_Traits>::connect (Admin_Traits_PTR admin_ptr)
67 typename Proxy_Traits::VAR proxy_var =
68 this->obtain_proxy (admin_ptr);
70 ACE_ASSERT (!CORBA::is_nil (proxy_var.in ()));
72 this->connect (proxy_var.in (),
73 this->proxy_id_);
77 template <class Peer_Traits>
78 void
79 TAO_Notify_Tests_Peer_T<Peer_Traits>::connect ()
81 // Get the POA
82 PortableServer::POA_var poa;
83 LOOKUP_MANAGER->resolve (poa,
84 this->poa_name_.c_str ());
86 // set the POA
87 this->set_poa (poa.in ());
89 // Resolve the admin
90 typename Admin_Traits::VAR admin_var;
92 LOOKUP_MANAGER->resolve (admin_var,
93 this->admin_name_.c_str ());
95 typename Admin_Ext_Traits::VAR admin_ext_var =
96 Admin_Ext_Traits_INTERFACE::_narrow (admin_var.in ());
98 typename Proxy_Traits::VAR proxy_var =
99 this->obtain_proxy (admin_ext_var.in (),
100 this->qos_);
102 ACE_ASSERT (!CORBA::is_nil (proxy_var.in ()));
104 // connect supplier to proxy,
105 // also activates the servant as CORBA object in the POA specified.
106 this->connect (proxy_var.in (),
107 this->proxy_id_);
110 template <class Peer_Traits>
111 void
112 TAO_Notify_Tests_Peer_T<Peer_Traits>::set_qos (
113 CosNotification::QoSProperties& qos
116 this->get_proxy ()->set_qos (qos);
119 template <class Peer_Traits>
120 void
121 TAO_Notify_Tests_Peer_T<Peer_Traits>::status ()
123 #if (TAO_HAS_MINIMUM_CORBA == 0)
126 CORBA::Boolean not_exist =
127 this->get_proxy ()->_non_existent ();
129 if (not_exist == 1)
131 ACE_DEBUG ((LM_DEBUG,
132 "Peer %s, Proxy does not exist\n",
133 this->name_.c_str ()));
135 else
137 ACE_DEBUG ((LM_DEBUG,
138 "Peer %s, Proxy exists\n",
139 this->name_.c_str ()));
142 catch (const CORBA::TRANSIENT& ex)
144 ex._tao_print_exception ("Error: ");
145 ACE_DEBUG ((LM_DEBUG,
146 "Peer %s is_equivalent transient exception.",
147 this->name_.c_str ()));
149 catch (const CORBA::Exception& ex)
151 ex._tao_print_exception ("Error: ");
152 ACE_DEBUG ((LM_DEBUG,
153 "Peer %s is_equivanent other exception.",
154 this->name_.c_str ()));
156 #endif /* TAO_HAS_MINIMUM_CORBA */
159 template <class Peer_Traits>
160 void
161 TAO_Notify_Tests_Peer_T<Peer_Traits>::disconnect ()
163 ACE_ASSERT (!CORBA::is_nil (this->proxy_.in ()));
167 this->disconnect_from_proxy ();
169 catch (const CORBA::Exception&)
171 ACE_DEBUG ((LM_DEBUG,
172 "Peer %s failed to disconnect from proxy.",
173 this->name_.c_str ()));
178 this->deactivate ();
180 catch (const CORBA::Exception&)
182 ACE_DEBUG ((LM_DEBUG,
183 "Peer %s failed to deactivate.",
184 this->name_.c_str ()));
188 template <class Peer_Traits>
189 PortableServer::POA_ptr
190 TAO_Notify_Tests_Peer_T<Peer_Traits>::_default_POA (
193 return PortableServer::POA::_duplicate (this->default_POA_.in ());
196 template <class Peer_Traits>
197 void
198 TAO_Notify_Tests_Peer_T<Peer_Traits>::deactivate ()
200 PortableServer::POA_var poa = this->_default_POA ();
202 PortableServer::ObjectId_var id =
203 poa->servant_to_id (this);
205 poa->deactivate_object (id.in ());
208 #endif /* TAO_Notify_Tests_Peer_T_CPP */