IceManager.h
Go to the documentation of this file.
1 // -*- C++ -*-
18 #ifndef DOIL_ICE_ICEMANAGER_H
19 #define DOIL_ICE_ICEMANAGER_H
20 
21 #include <coil/Properties.h>
22 #include <coil/Mutex.h>
23 #include <coil/Guard.h>
24 #include <doil/IORB.h>
25 #include <doil/ServantFactory.h>
26 #include <doil/ice/Ice.h>
28 #include <doil/ObjectManager.h>
29 
30 namespace doil
31 {
32 namespace Ice
33 {
47  class IceManager
48  : public doil::IORB
49  {
50  public:
59  throw();
60 
68  static IceManager& instance()
69  throw();
70 
71  //------------------------------------------------------------
72  // IORB interfaces
73  //------------------------------------------------------------
88  virtual const char* name()
89  throw();
90 
91  virtual void run()
92  throw();
93  virtual void shutdown()
94  throw();
95 
119  virtual ReturnCode_t
120  registerFactory(const char* id,
121  doil::ServantNewFunc new_func,
122  doil::ServantDeleteFunc delete_func)
123  throw();
124 
155  throw();
156 
188  doil::ServantBase* servant)
189  throw();
190 
218  throw();
219 
246  virtual ReturnCode_t deactivateObject(const char* name)
247  throw();
248 
275  virtual ImplBase* getImpl(const char* name)
276  throw();
277 
304  virtual ImplBase* toImpl(doil::ServantBase* servant)
305  throw();
306 
333  virtual ServantBase* getServant(const char* name)
334  throw();
335 
362  virtual ServantBase* toServant(doil::ImplBase* lobj)
363  throw();
364 
365  //------------------------------------------------------------
366  // IceManager interfaces
367  //------------------------------------------------------------
377  doil::ImplBase* toImpl(::Ice::ObjectPrx obj)
378  throw();
379 
389  ::Ice::ObjectPrx getReference(const char* name)
390  throw();
391 
401  ::Ice::ObjectPrx toReference(doil::ImplBase* impl)
402  throw();
403 
413  ::Ice::ObjectPrx toReference(doil::ServantBase* servant)
414  throw();
415 
425  doil::ServantBase* toServant(::Ice::ObjectPrx obj)
426  throw();
427 
428  //------------------------------------------------------------
429  // Ice functions
430  //------------------------------------------------------------
440  ::Ice::CommunicatorPtr getORB()
441  throw();
442 
452  ::Ice::ObjectAdapterPtr getAdapter()
453  throw();
454 
455  //------------------------------------------------------------
456  // protected functions:
457  //------------------------------------------------------------
458  protected:
476  void initIce(coil::Properties prop);
477 
497  std::string createIceOptions();
498 
499  //------------------------------------------------------------
500  // private functions:
501  //------------------------------------------------------------
502  private:
503  // private constructor
505  // private big three
506  IceManager(const IceManager& cmgr);
507  IceManager& operator=(const IceManager& rhs);
508  ~IceManager() throw() {}
509 
510  //------------------------------------------------------------
511  // private data:
512  //------------------------------------------------------------
513  private:
514  // static data member for singleton
517 
518  // Ice communicator pointer
519  ::Ice::CommunicatorPtr m_ice;
520 
521  // Ice object adapter pointer
522  ::Ice::ObjectAdapterPtr m_adapter;
523 
524  // configuration properties
526 
527 
528  // Entry class for active object map
529  class Entry
530  {
531  public:
532  Entry(ImplBase* impl, IceServantBase* servant,
533  ::Ice::ObjectPrx objref)
534  : impl_(impl), servant_(servant), objref_(objref)
535  {
536  }
537  virtual ~Entry()
538  {
539  }
542  ::Ice::ObjectPrx objref_;
543  };
544 
545  // Predicate class for active object map
546  class EntryPred
547  {
548  public:
549  EntryPred(const char* name)
550  : m_name(name)
551  {
552  }
553  EntryPred(Entry* entry)
554  : m_name(entry->impl_->name())
555  {
556  }
557  bool operator()(Entry* entry)
558  {
559  return m_name == entry->impl_->name();
560  }
561  std::string m_name;
562  };
563 
564  // Active object map
566  ObjectMap m_map;
567 
568  // Predicate functor for Factory map
570  {
571  public:
572  FactoryPred(const char* id) : m_id(id) {}
573  FactoryPred(ServantFactory* factory) : m_id(factory->id()) {}
574  bool operator()(ServantFactory* factory)
575  {
576  return m_id == factory->id();
577  }
578  std::string m_id;
579  };
580 
581  // Servant factory map
583 
584 
586  {
587  public:
588  find_by_obj(::Ice::ObjectPrx obj) : result_(NULL), m_obj(obj) {};
590  {
591  if (m_obj == (entry->objref_))
592  {
593  result_ = entry;
594  }
595  }
596  public:
598  private:
599  ::Ice::ObjectPrx m_obj;
600  };
601 
602 
603  };
604 };
605 };
606 
607 extern "C"
608 {
610 }
611 #endif // RTM_Ice_IceMANAGER_H
::Ice::CommunicatorPtr m_ice
Definition: IceManager.h:519
virtual ImplBase * toImpl(doil::ServantBase *servant)
Getting impl object by servant.
Definition: IceManager.cpp:275
static coil::Mutex mutex
Definition: IceManager.h:516
ServantBase *(* ServantNewFunc)()
::Ice::ObjectAdapterPtr m_adapter
Definition: IceManager.h:522
Entry(ImplBase *impl, IceServantBase *servant,::Ice::ObjectPrx objref)
Definition: IceManager.h:532
IceManager & operator=(const IceManager &rhs)
Mutex class.
virtual const char * id()
find_by_obj(::Ice::ObjectPrx obj)
Definition: IceManager.h:588
ReturnCode_t
Definition: doil.h:53
ObjectManager< const char *, Entry, EntryPred > ObjectMap
Definition: IceManager.h:565
virtual ImplBase * getImpl(const char *name)
Getting object by name.
Definition: IceManager.cpp:258
IceServantBase * servant_
Definition: IceManager.h:541
virtual void run()
Definition: IceManager.cpp:83
void DoilIceInit(coil::Properties &prop)
Definition: IceManager.cpp:462
ObjectManager< const char *, ServantFactory, FactoryPred > m_factory
Definition: IceManager.h:582
virtual ReturnCode_t registerFactory(const char *id, doil::ServantNewFunc new_func, doil::ServantDeleteFunc delete_func)
Register servant&#39;s factory.
Definition: IceManager.cpp:115
FactoryPred(ServantFactory *factory)
Definition: IceManager.h:573
Doil Ice servant base class.
doil Ice header
void(* ServantDeleteFunc)(ServantBase *)
::Ice::ObjectPrx toReference(doil::ImplBase *impl)
Converting Impl object to object reference.
Definition: IceManager.cpp:360
bool operator()(Entry *entry)
Definition: IceManager.h:557
::Ice::CommunicatorPtr getORB()
Getting ORB pointer.
Definition: IceManager.cpp:404
virtual ReturnCode_t deactivateObject(doil::ImplBase *impl)
Deactivate object.
Definition: IceManager.cpp:216
virtual ServantBase * getServant(const char *name)
Getting servant object by name.
Definition: IceManager.cpp:294
prop
Organization::get_organization_property ();.
virtual void shutdown()
Shutdown ORB.
Definition: IceManager.cpp:91
::Ice::ObjectPrx objref_
Definition: IceManager.h:542
virtual const char * name()=0
Class represents a set of properties.
Definition: Properties.h:101
::Ice::ObjectAdapterPtr getAdapter()
Getting default POA pointer.
Definition: IceManager.cpp:417
virtual ServantBase * toServant(doil::ImplBase *lobj)
Getting servant object by impl object.
Definition: IceManager.cpp:312
static IceManager * init(coil::Properties prop)
initializer
Definition: IceManager.cpp:42
::Ice::ObjectPrx getReference(const char *name)
Getting object reference from the given name.
Definition: IceManager.cpp:345
static IceManager * manager
Definition: IceManager.h:515
void initIce(coil::Properties prop)
Ice ORB initialization.
Definition: IceManager.cpp:427
void operator()(IceManager::Entry *entry)
Definition: IceManager.h:589
virtual const char * name()
Getting ORB&#39;s name.
Definition: IceManager.cpp:78
bool operator()(ServantFactory *factory)
Definition: IceManager.h:574
std::string createIceOptions()
Create ORB command options.
Definition: IceManager.cpp:452
static IceManager & instance()
getting instance
Definition: IceManager.cpp:64
Generic ORB interface.
coil::Properties m_config
Definition: IceManager.h:525
virtual ReturnCode_t activateObject(doil::ImplBase *impl)
Activate object.
Definition: IceManager.cpp:138


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:52