OpenRTM-aist  2.1.0
Factory.h
Go to the documentation of this file.
1 // -*- C++ -*-
20 #ifndef RTC_FACTORY_H
21 #define RTC_FACTORY_H
22 
23 #include <coil/Properties.h>
25 #include <rtm/NumberingPolicy.h>
26 
27 
28 namespace RTC
29 {
30  class RTObject_impl;
31  class Manager;
32 
34  using RtcDeleteFunc = void (*)(RTObject_impl*);
35 
64  template <class T_New>
66  {
67  return new T_New(manager);
68  }
69 
87 
109  template <class T_Delete>
111  {
112  deleteRTObject(rtc);
113  }
114 
115 
138  {
139  public:
160 
174  virtual ~FactoryBase();
175 
199  virtual RTObject_impl* create(Manager* mgr) = 0;
200 
220  virtual void destroy(RTObject_impl* comp) = 0;
221 
242 
262  virtual int number();
263 
264  protected:
273 
281  int m_Number;
282  };
283 
306  : public FactoryBase
307  {
308  public:
343  RtcNewFunc new_func,
344  RtcDeleteFunc delete_func,
346 
347  ~FactoryCXX() override
348  {
349  delete m_policy;
350  }
351 
375  RTObject_impl* create(Manager* mgr) override;
376 
396  void destroy(RTObject_impl* comp) override;
397 
398  protected:
407 
416 
425  };
426 } // namespace RTC
427 #endif // RTC_FACTORY_H
Object numbering policy base class.
FactoryBase base class.
Definition: Factory.h:138
virtual RTObject_impl * create(Manager *mgr)=0
Create components.
FactoryBase(const coil::Properties &profile)
Constructor.
virtual coil::Properties & profile()
Get the component profile.
coil::Properties m_Profile
Component profile.
Definition: Factory.h:272
virtual void destroy(RTObject_impl *comp)=0
Destroy components.
virtual int number()
Get the number of current instances.
int m_Number
Number of current RT-Component's instances.
Definition: Factory.h:281
virtual ~FactoryBase()
Destructor.
FactoryCXX class.
Definition: Factory.h:307
RtcNewFunc m_New
The pointer to component object create function.
Definition: Factory.h:406
RTObject_impl * create(Manager *mgr) override
Create RT-Components.
void destroy(RTObject_impl *comp) override
Destroy RT-Components.
RTM::NumberingPolicyBase * m_policy
The naming policy on creating the components.
Definition: Factory.h:424
RtcDeleteFunc m_Delete
The pointer to component object destroy function.
Definition: Factory.h:415
FactoryCXX(const coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func, RTM::NumberingPolicyBase *policy=new RTM::ProcessUniquePolicy())
Constructor.
~FactoryCXX() override
Definition: Factory.h:347
Manager class.
Definition: Manager.h:91
RT-Component class.
Definition: RTObject.h:93
Definition: NumberingPolicyBase.h:56
Class for naming policy management when creating objects.
Definition: NumberingPolicy.h:54
RT-Component.
void Delete(RTObject_impl *rtc)
Template function to destroy RT-Components.
Definition: Factory.h:110
void deleteRTObject(RTObject_impl *rtc)
RTObject_impl * Create(Manager *manager)
Template function to create RT-Components.
Definition: Factory.h:65
void(*)(RTObject_impl *) RtcDeleteFunc
Definition: Factory.h:34
coil::Properties Properties
Definition: RTC.h:72
RTObject_impl *(*)(Manager *) RtcNewFunc
Definition: Factory.h:33