Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Utils / ORB_Manager.h
blob335a477b6f5c6d2010471b18ed9f8c2359c649e9
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file ORB_Manager.h
7 * @author Chris Cleeland <cleeland@cs.wustl.edu>
8 */
9 //=============================================================================
11 #ifndef TAO_ORB_MANAGER_H
12 #define TAO_ORB_MANAGER_H
13 #include /**/ "ace/pre.h"
15 #include "tao/Utils/utils_export.h"
16 #include "tao/PortableServer/PortableServer.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "tao/ORB.h"
24 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
26 /**
27 * @class TAO_ORB_Manager
29 * @brief Helper class for simple ORB/POA initialization and
30 * registering servants with the POA.
32 * This class is a TAO extension that makes it easier to write
33 * CORBA applications. It's just a wrapper and doesn't do
34 * anything special within the ORB itself.
36 class TAO_UTILS_Export TAO_ORB_Manager
38 public:
39 /** Constructor.
41 * @param orb pointer to an ORB which is duplicated an stored
42 * internally in an ORB_var. If pointer is 0,
43 * a new ORB pointer is created internally in the init()
44 * call.
46 * @param poa pointer to a POA which is duplicated and stored
47 * internally in a POA_var. If pointer is 0,
48 * a pointer to the Root POA is obtained from the ORB.
50 * @param poa_manager pointer to a POA Manager which is duplicated
51 * and stored internally in a POAManager_var.
52 * If pointer is 0, a new POAManager is created
53 * internally in the init() call.
55 TAO_ORB_Manager (CORBA::ORB_ptr orb = CORBA::ORB::_nil(),
56 PortableServer::POA_ptr poa = PortableServer::POA::_nil(),
57 PortableServer::POAManager_ptr poa_manager =
58 PortableServer::POAManager::_nil());
60 /**
61 * Initialize the ORB/root POA, using the supplied command line
62 * arguments or the default ORB components.
64 * @retval -1 Failure
65 * @retval 0 Success
67 int init (int &argc,
68 ACE_TCHAR *argv[],
69 const char *orb_name = 0);
71 #if !defined (CORBA_E_MICRO)
72 /**
73 * Creates a child poa under the root poa with PERSISTENT and
74 * USER_ID policies. Call this if you want a @a child_poa with the
75 * above policies, otherwise call init.
77 * @retval -1 Failure
78 * @retval 0 Success
80 int init_child_poa (int &argc,
81 ACE_TCHAR *argv[],
82 const char *poa_name,
83 const char *orb_name = 0);
84 #endif /* CORBA_E_MICRO */
86 /**
87 * Shut down. Invoke the destroy() methods on the orb and poa.
89 * @retval -1 Failure
90 * @retval 0 Success
92 int fini ();
94 /// Destructor.
95 ~TAO_ORB_Manager ();
97 // = Accessor methods.
99 /**
100 * Put POA manager into the <Active> state, so that incoming corba
101 * requests are processed. This method is useful for clients,
102 * which are not going to enter "orb->run" loop, yet may want to
103 * service incoming requests while waiting for a result of CORBA
104 * call on a server.
106 * @retval -1 Failure
107 * @retval 0 Success
109 int activate_poa_manager ();
112 * Activate <servant>, using the POA <activate_object> call. Users
113 * can call this method multiple times to activate multiple objects.
115 * @return 0 on failure, a string representation of the object ID if
116 * successful. Caller of this method is responsible for
117 * memory deallocation of the string.
119 char *activate (PortableServer::Servant servant);
121 /** Deactivate object in RootPOA.
123 * @param id A string representation of the Object ID
124 * of the servant to deactivate in the POA
126 void deactivate (const char *id);
128 #if !defined (CORBA_E_MICRO)
130 * Precondition: init_child_poa has been called. Activate <servant>
131 * using the POA <activate_object_with_id> created from the string
132 * <object_name>. Users should call this to activate objects under
133 * the child_poa.
135 * @param object_name String name which will be used to create
136 * an Object ID for the servant.
137 * @param servant The servant to activate under the child POA.
139 * @return 0 on failure, a string representation of the object ID if
140 * successful. Caller of this method is responsible for
141 * memory deallocation of the string.
143 char *activate_under_child_poa (const char *object_name,
144 PortableServer::Servant servant);
147 * Deactivate object in child POA.
149 * @param id string representation of the object ID, which represents
150 * the object to deactivate in the POA
152 void deactivate_under_child_poa (const char *id);
153 #endif /* CORBA_E_MICRO */
156 * Run the ORB event loop with the specified @a tv time value.
158 * @param tv the time interval for how long to run the ORB event loop.
159 * @retval -1 Failure
160 * @retval 0 Success
162 int run (ACE_Time_Value &tv);
165 * Run the ORB event loop.
167 int run ();
170 * Accessor which returns the ORB pointer. Following the normal
171 * CORBA memory management rules of return values from functions,
172 * this function duplicates the orb return value before returning
173 * it.
175 * @return ORB pointer which has been duplicated, so caller
176 * must release pointer when done.
178 CORBA::ORB_ptr orb ();
181 * Accessor which returns the root poa. Following the normal CORBA
182 * memory management rules of return values from functions, this
183 * function duplicates the poa return value before returning it.
185 * @return Root POA pointer which has been duplicated. Caller
186 * must release pointer when done.
188 PortableServer::POA_ptr root_poa ();
191 * Accessor which returns the child poa. Following the normal CORBA
192 * memory management rules of return values from functions, this
193 * function duplicates the poa return value before returning it.
195 * @return Child POA pointer which has been duplicated. Caller
196 * must release pointer when done.
198 PortableServer::POA_ptr child_poa ();
201 * Accessor which returns the poa manager. Following the normal
202 * CORBA memory management rules of return values from functions,
203 * this function duplicates the poa manager return value before
204 * returning it.
206 * @return POAManager pointer which has been duplicated. Caller
207 * must release pointer when done.
209 PortableServer::POAManager_ptr poa_manager ();
211 protected:
212 /// The ORB.
213 CORBA::ORB_var orb_;
215 /// The POA for this ORB.
216 PortableServer::POA_var poa_;
218 /// Child poa under the root POA.
219 PortableServer::POA_var child_poa_;
221 /// The POA manager of poa_.
222 PortableServer::POAManager_var poa_manager_;
225 TAO_END_VERSIONED_NAMESPACE_DECL
227 #include /**/ "ace/post.h"
228 #endif /* TAO_ORB_MANAGER_H */