OpenRTM  1.0.0
rtm/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>
24 //#include <rtm/RTObject.h>
25 #include <rtm/NumberingPolicy.h>
26 
27 
28 namespace RTC
29 {
30  class RTObject_impl;
31  class Manager;
32 
33  typedef RTObject_impl* (*RtcNewFunc)(Manager* manager);
34  typedef void (*RtcDeleteFunc)(RTObject_impl* rtc);
35 
64  template <class _New>
66  {
67  return new _New(manager);
68  }
69 
91  template <class _Delete>
92  void Delete(RTObject_impl* rtc)
93  {
94  delete rtc;
95  }
96 
119  {
120  public:
141 
155  virtual ~FactoryBase(void);
156 
180  virtual RTObject_impl* create(Manager* mgr) = 0;
181 
201  virtual void destroy(RTObject_impl* comp) = 0;
202 
222  virtual coil::Properties& profile();
223 
243  virtual int number();
244 
245  protected:
254 
262  int m_Number;
263  };
264 
287  : public FactoryBase
288  {
289  public:
324  RtcNewFunc new_func,
325  RtcDeleteFunc delete_func,
326  NumberingPolicy* policy = new DefaultNumberingPolicy());
327 
328  virtual ~FactoryCXX()
329  {
330  delete m_policy;
331  }
332 
356  virtual RTObject_impl* create(Manager* mgr);
357 
377  virtual void destroy(RTObject_impl* comp);
378 
379  protected:
388 
397 
406  };
407 };
408 #endif // RTC_FACTORY_H