ORBManager.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
19 #include <assert.h>
20 #include <doil/ORBManager.h>
22 
23 namespace doil
24 {
25  // singleton pointer initializer
28 
29  //------------------------------------------------------------
30  // public functions
31  //------------------------------------------------------------
40  throw()
41  {
42  if (!manager)
43  {
44  coil::Guard<coil::Mutex> guard(mutex);
45  if (!manager)
46  {
47  manager = new ORBManager();
48  // manager->initORBManager(prop);
49  }
50  }
51  return manager;
52  };
53 
62  throw()
63  {
65  }
66 
67 
75  void ORBManager::shutdown() throw()
76  {
77  try
78  {
80  }
81  catch (...)
82  {
83  // should never come here
84  assert(false);
85  return;
86  }
87  }
88 
97  {
98  try
99  {
100  if (getORB(orb->name()) != NULL) return ALREADY_EXISTS;
101  m_orbs.registerObject(orb);
102  return OK;
103  }
104  catch (...)
105  {
106  // should never come here
107  assert(false);
108  return UNKNOWN;
109  }
110  }
111 
119  IORB* ORBManager::getORB(const char* name) throw()
120  {
121  try
122  {
123  IORB* orb;
124  orb = m_orbs.find(name);
125  if (orb == NULL) return NULL;
126  return orb;
127  }
128  catch (...)
129  {
130  // should never come here
131  assert(false);
132  return NULL;
133  }
134  }
135 
143  const std::vector<IORB*> ORBManager::getORBs() throw()
144  {
145  try
146  {
147  collect_orbs o;
148  o = m_orbs.for_each(o);
149  return o.orbs_;
150  }
151  catch (...)
152  {
153  // should never come here
154  assert(false);
155  return std::vector<IORB*>();
156  }
157  }
158 
166  const std::vector<std::string> ORBManager::availableORBs() throw()
167  {
168  try
169  {
170  available_orbs o;
171  o = m_orbs.for_each(o);
172  return o.orbs_;
173  }
174  catch (...)
175  {
176  // should never come here
177  assert(false);
178  return std::vector<std::string>();
179  }
180  }
181 
189  IORB* ORBManager::deleteORB(const char* name) throw()
190  {
191  if (name == NULL) return NULL;
192  try
193  {
194  return m_orbs.unregisterObject(name);
195  }
196  catch (...)
197  {
198  // should never come here
199  assert(false);
200  return NULL;
201  }
202  }
203 
213  const char* orbname) throw()
214  {
215  if (impl == NULL || orbname == NULL) return ReturnCodes(INVALID_ARGS);
216  if (getObject(impl->name()) != NULL) return ReturnCodes(ALREADY_EXISTS);
217 
218  try
219  {
220  activate_impl a(impl, orbname);
221  a = m_orbs.for_each(a);
222  return a.retcodes_;
223  }
224  catch (...)
225  {
226  // should never come here
227  assert(false);
228  return ReturnCodes();
229  }
230  }
231 
241  const char* orbname) throw()
242  {
243  if (impl == NULL || orbname == NULL) return INVALID_ARGS;
244  if (getObject(impl->name()) == NULL) return NOT_FOUND;
245 
246  try
247  {
248  deactivate_impl d(impl, orbname);
249  d = m_orbs.for_each(d);
250  return d.retcodes_;
251  }
252  catch (...)
253  {
254  // should never come here
255  assert(false);
256  return ReturnCodes();
257  }
258  }
259 
262  const char* orbname) throw()
263  {
264  if (name == NULL || orbname == NULL) return INVALID_ARGS;
265  if (getObject(name) == NULL) return NOT_FOUND;
266 
267  try
268  {
269  deactivate_by_name d(name, orbname);
270  d = m_orbs.for_each(d);
271  return d.retcodes_;
272  }
273  catch (...)
274  {
275  // should never come here
276  assert(false);
277  return ReturnCodes();
278  }
279  }
280 
281  const std::vector<ImplBase*> ORBManager::getObjects() throw()
282  {
283  try
284  {
285  collect_impl o;
286  o = m_impls.for_each(o);
287  return o.impls_;
288  }
289  catch (...)
290  {
291  // should never come here
292  assert(false);
293  return std::vector<ImplBase*>();
294  }
295  }
296 
297 
298  ImplBase* ORBManager::getObject(const char* name) throw()
299  {
300  if (name == NULL) return NULL;
301  try
302  {
303  return m_impls.find(name);
304  }
305  catch (...)
306  {
307  // should never come here
308  assert(false);
309  return NULL;
310  }
311  }
312 
313  //------------------------------------------------------------
314  // private functions
315  //------------------------------------------------------------
316 
317 };
std::vector< IORB * > orbs_
Definition: ORBManager.h:391
virtual ReturnCodes deactivateObject(ImplBase *impl, const char *orbname="")
Deactivate object.
Definition: ORBManager.cpp:240
A functor to deactivate a given impl object.
Definition: ORBManager.h:441
Mutex class.
ReturnCode_t
Definition: doil.h:53
std::vector< std::string > orbs_
Definition: ORBManager.h:401
virtual void shutdown()
shutdown ORBManager
Definition: ORBManager.cpp:75
static ORBManager * manager
Definition: ORBManager.h:296
ImplBase * getObject(const char *name)
Delete object.
Definition: ORBManager.cpp:298
static ORBManager & instance()
getting instance
Definition: ORBManager.cpp:61
static const char * default_config[]
Default configuration for ORBManager.
IORB * deleteORB(const char *name)
Delete registered ORB by name.
Definition: ORBManager.cpp:189
bool registerObject(Object *obj)
Register the specified object.
Object * unregisterObject(const Identifier &id)
Unregister the specified object.
static coil::Mutex mutex
Definition: ORBManager.h:297
Object * find(const Identifier &id) const
Find the object.
const std::vector< ImplBase * > getObjects()
Delete object.
Definition: ORBManager.cpp:281
Pred for_each(Pred p)
Functor for searching object.
prop
Organization::get_organization_property ();.
std::vector< ImplBase * > impls_
Definition: ORBManager.h:492
ReturnCode_t addORB(IORB *orb)
Register an ORB to the ORBManager.
Definition: ORBManager.cpp:96
Class represents a set of properties.
Definition: Properties.h:101
const std::vector< std::string > availableORBs()
Get all the ORBs&#39; name that are registered in this ORBManager.
Definition: ORBManager.cpp:166
static ORBManager * init(coil::Properties prop)
initializer
Definition: ORBManager.cpp:39
IORB * getORB(const char *name)
Get an ORB that is registered in this ORBManager.
Definition: ORBManager.cpp:119
Definition: doil.h:55
virtual ReturnCodes activateObject(ImplBase *impl, const char *orbname="")
Activate object.
Definition: ORBManager.cpp:212
A functor to activate a given impl object.
Definition: ORBManager.h:411
const std::vector< IORB * > getORBs()
Get all the ORBs that are registered in this ORBManager.
Definition: ORBManager.cpp:143


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Feb 28 2022 23:00:43