CORBAManager.h
Go to the documentation of this file.
1 // -*- C++ -*-
18 #ifndef DOIL_CORBA_CORBAMANAGER_H
19 #define DOIL_CORBA_CORBAMANAGER_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/ProxyFactory.h>
27 #include <doil/corba/CORBA.h>
29 #include <doil/corba/CORBAProxyBase.h>
30 #include <doil/ObjectManager.h>
31 
32 namespace doil
33 {
34 namespace CORBA
35 {
50  : public doil::IORB
51  {
52  public:
53  //
54  //for unit tests
55  //
56 // doil::LocalBase* toLocal(::CORBA::Object_ptr& obj);
57  doil::LocalBase* toLocal(::CORBA::Object_ptr& obj)
58  {
59  return NULL;
60  }
69  throw();
70 
78  static CORBAManager& instance()
79  throw();
80 
81  //------------------------------------------------------------
82  // IORB interfaces
83  //------------------------------------------------------------
98  virtual const char* name()
99  throw();
100 
101  virtual void run()
102  throw();
103  virtual void shutdown()
104  throw();
105 
129  virtual ReturnCode_t
130  registerFactory(const char* id,
131  doil::ServantNewFunc new_func,
132  doil::ServantDeleteFunc delete_func)
133  throw();
134 #if 1
135  //
136  //for unit tests
137  //
138  virtual ReturnCode_t
139  registerProxyFactory(const char* id,
140  doil::ProxyNewFunc new_func,
141  doil::ProxyDeleteFunc delete_func)
142  throw();
143 #endif
144 
174  throw();
175 
207  doil::ServantBase* servant)
208  throw();
209 
237  throw();
238 
265  virtual ReturnCode_t deactivateObject(const char* name)
266  throw();
267 
294  virtual ImplBase* getImpl(const char* name)
295  throw();
296 
323  virtual ImplBase* toImpl(doil::ServantBase* servant)
324  throw();
325 
352  virtual ServantBase* getServant(const char* name)
353  throw();
354 
381  virtual ServantBase* toServant(doil::ImplBase* lobj)
382  throw();
383 
384  //------------------------------------------------------------
385  // CORBAManager interfaces
386  //------------------------------------------------------------
396  doil::ImplBase* toImpl(::CORBA::Object_ptr obj)
397  throw();
398 
408  ::CORBA::Object_ptr getReference(const char* name)
409  throw();
410 
420  ::CORBA::Object_ptr toReference(doil::ImplBase* impl)
421  throw();
422 
432  ::CORBA::Object_ptr toReference(doil::ServantBase* servant)
433  throw();
434 
444  doil::ServantBase* toServant(::CORBA::Object_ptr obj)
445  throw();
446 
447  //------------------------------------------------------------
448  // CORBA functions
449  //------------------------------------------------------------
459  ::CORBA::ORB_ptr getORB()
460  throw();
461 
471  ::PortableServer::POA_ptr getPOA()
472  throw();
473 
483  ::PortableServer::POAManager_ptr getPOAManager()
484  throw();
485 
486  //------------------------------------------------------------
487  // protected functions:
488  //------------------------------------------------------------
489  protected:
507  void initOrb(coil::Properties prop);
508 
528  std::string createORBOptions();
529 
530  //------------------------------------------------------------
531  // private functions:
532  //------------------------------------------------------------
533  private:
534  // private constructor
536  // private big three
537  CORBAManager(const CORBAManager& cmgr);
538  CORBAManager& operator=(const CORBAManager& rhs);
539  ~CORBAManager() throw() {}
540 
541  //------------------------------------------------------------
542  // private data:
543  //------------------------------------------------------------
544  private:
545  // static data member for singleton
548 
549  // CORBA ORB pointer
550  ::CORBA::ORB_ptr m_orb;
551 
552  // default POA pointer
553  ::PortableServer::POA_ptr m_poa;
554 
555  // POAManager pointer
556  ::PortableServer::POAManager_ptr m_poaManager;
557 
558  // configuration properties
560 
561 
562  // Entry class for active object map
563  class Entry
564  {
565  public:
566  Entry(ImplBase* impl, CORBAServantBase* servant,
567  ::CORBA::Object_ptr objref)
568  : impl_(impl), servant_(servant), objref_(objref)
569  {
570  }
571  virtual ~Entry()
572  {
573  }
576  ::CORBA::Object_ptr objref_;
577  };
578 
579  // Predicate class for active object map
580  class EntryPred
581  {
582  public:
583  EntryPred(const char* name)
584  : m_name(name)
585  {
586  }
587  EntryPred(Entry* entry)
588  : m_name(entry->impl_->name())
589  {
590  }
591  bool operator()(Entry* entry)
592  {
593  return m_name == entry->impl_->name();
594  }
595  std::string m_name;
596  };
597 
598  // Active object map
600 
601 
602 
603 #if 0
604  //
605  // for unit test
606  //
607  // Entry class for active object map
608  class EntryProxy
609  {
610  public:
611  EntryProxy(ImplBase* impl, CORBAProxyBase* proxy,
612  ::CORBA::Object_ptr objref)
613  : impl_(impl), proxy_(proxy), objref_(objref)
614  {
615  }
616  virtual ~EntryProxy()
617  {
618  }
619  ImplBase* impl_;
620  CORBAProxyBase* proxy_;
621  ::CORBA::Object_ptr objref_;
622  };
623 
624  //
625  // for unit test
626  //
627  // Predicate class for active object map
628  class EntryPredProxy
629  {
630  public:
631  EntryPredProxy(const char* name)
632  : m_name(name)
633  {
634  }
635  EntryPredProxy(Entry* entry)
636  : m_name(entry->impl_->name())
637  {
638  }
639  bool operator()(Entry* entry)
640  {
641  return m_name == entry->impl_->name();
642  }
643  std::string m_name;
644  };
645 
646  //
647  // for unit test
648  //
649  // Active object map
651 #endif
652 
653  // Predicate functor for Factory map
655  {
656  public:
657  FactoryPred(const char* id) : m_id(id) {}
658  FactoryPred(ServantFactory* factory) : m_id(factory->id()) {}
659  bool operator()(ServantFactory* factory)
660  {
661  return m_id == factory->id();
662  }
663  std::string m_id;
664  };
665  // Servant factory map
667 
668 #if 1
669  //
670  // for unit test
671  //
672  // Predicate functor for Factory map
674  {
675  public:
676  ProxyFactoryPred(const char* id) : m_id(id) {}
677  ProxyFactoryPred(ProxyFactory* factory) : m_id(factory->id()) {}
678  bool operator()(ProxyFactory* factory)
679  {
680  return m_id == factory->id();
681  }
682  std::string m_id;
683  };
684  //
685  // for unit test
686  //
687  // Servant factory map
689 #endif
690  };
691 };
692 };
693 
694 extern "C"
695 {
697 }
698 #endif // RTM_CORBA_CORBAMANAGER_H
static CORBAManager * manager
Definition: CORBAManager.h:546
virtual const char * name()
Getting ORB&#39;s name.
::PortableServer::POA_ptr getPOA()
Getting default POA pointer.
virtual ServantBase * toServant(doil::ImplBase *lobj)
Getting servant object by impl object.
ServantBase *(* ServantNewFunc)()
doil implementation base class for debag
bool operator()(ServantFactory *factory)
Definition: CORBAManager.h:659
void(* ProxyDeleteFunc)(ProxyBase *)
Definition: ProxyFactory.h:31
virtual ReturnCode_t registerFactory(const char *id, doil::ServantNewFunc new_func, doil::ServantDeleteFunc delete_func)
Register servant&#39;s factory.
Mutex class.
static coil::Mutex mutex
Definition: CORBAManager.h:547
coil::Properties m_config
Definition: CORBAManager.h:559
virtual const char * id()
::CORBA::ORB_ptr getORB()
Getting ORB pointer.
ReturnCode_t
Definition: doil.h:53
ObjectManager< const char *, Entry, EntryPred > m_map
Definition: CORBAManager.h:599
virtual ReturnCode_t registerProxyFactory(const char *id, doil::ProxyNewFunc new_func, doil::ProxyDeleteFunc delete_func)
virtual ImplBase * toImpl(doil::ServantBase *servant)
Getting impl object by servant.
static CORBAManager & instance()
getting instance
virtual ServantBase * getServant(const char *name)
Getting servant object by name.
ObjectManager< const char *, ProxyFactory, ProxyFactoryPred > m_factory_proxy
Definition: CORBAManager.h:688
static CORBAManager * init(coil::Properties prop)
initializer
FactoryPred(ServantFactory *factory)
Definition: CORBAManager.h:658
virtual const char * id()
Definition: ProxyFactory.h:91
void initOrb(coil::Properties prop)
CORBA ORB initialization.
::CORBA::Object_ptr toReference(doil::ImplBase *impl)
Converting Impl object to object reference.
::CORBA::Object_ptr getReference(const char *name)
Getting object reference from the given name.
virtual ImplBase * getImpl(const char *name)
Getting object by name.
CORBAManager & operator=(const CORBAManager &rhs)
ProxyBase *(* ProxyNewFunc)(::CORBA::Object_ptr obj)
Definition: ProxyFactory.h:30
void(* ServantDeleteFunc)(ServantBase *)
::PortableServer::POAManager_ptr getPOAManager()
Getting POAManager pointer.
void DoilCORBAInit(coil::Properties &prop)
prop
Organization::get_organization_property ();.
virtual const char * name()=0
Class represents a set of properties.
Definition: Properties.h:101
::CORBA::ORB_ptr m_orb
Definition: CORBAManager.h:550
doil::LocalBase * toLocal(::CORBA::Object_ptr &obj)
Definition: CORBAManager.h:57
ObjectManager< const char *, ServantFactory, FactoryPred > m_factory
Definition: CORBAManager.h:666
Entry(ImplBase *impl, CORBAServantBase *servant, ::CORBA::Object_ptr objref)
Definition: CORBAManager.h:566
virtual ReturnCode_t deactivateObject(doil::ImplBase *impl)
Deactivate object.
doil CORBA header
virtual void shutdown()
Shutdown ORB.
::PortableServer::POAManager_ptr m_poaManager
Definition: CORBAManager.h:556
bool operator()(ProxyFactory *factory)
Definition: CORBAManager.h:678
std::string createORBOptions()
Create ORB command options.
::PortableServer::POA_ptr m_poa
Definition: CORBAManager.h:553
virtual ReturnCode_t activateObject(doil::ImplBase *impl)
Activate object.
Generic ORB interface.


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