Factory.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef RTC_FACTORY_H
00021 #define RTC_FACTORY_H
00022 
00023 #include <coil/Properties.h>
00024 //#include <rtm/RTObject.h>
00025 #include <rtm/NumberingPolicy.h>
00026 
00027 
00028 namespace RTC 
00029 {
00030   class RTObject_impl;
00031   class Manager;
00032   
00033   typedef RTObject_impl* (*RtcNewFunc)(Manager* manager);
00034   typedef void (*RtcDeleteFunc)(RTObject_impl* rtc);
00035   
00064   template <class _New>
00065   RTObject_impl* Create(Manager* manager)
00066   {
00067     return new _New(manager);
00068   }
00069   
00091   template <class _Delete>
00092   void Delete(RTObject_impl* rtc)
00093   {
00094     delete rtc;
00095   }
00096   
00118   class FactoryBase
00119   {
00120   public:
00140     FactoryBase(const coil::Properties& profile);
00141     
00155     virtual ~FactoryBase(void);
00156     
00180     virtual RTObject_impl* create(Manager* mgr) = 0;
00181     
00201     virtual void destroy(RTObject_impl* comp) = 0;
00202     
00222     virtual coil::Properties& profile();
00223     
00243     virtual int number();
00244     
00245   protected:
00253     coil::Properties m_Profile;
00254     
00262     int m_Number;
00263   };
00264   
00286   class FactoryCXX
00287     : public FactoryBase
00288   {
00289   public:
00323     FactoryCXX(const coil::Properties& profile,
00324                RtcNewFunc new_func,
00325                RtcDeleteFunc delete_func,
00326                NumberingPolicy* policy = new DefaultNumberingPolicy());
00327     
00328     virtual ~FactoryCXX()
00329     {
00330       delete m_policy;
00331     }
00332 
00356     virtual RTObject_impl* create(Manager* mgr);
00357     
00377     virtual void destroy(RTObject_impl* comp);
00378     
00379   protected:
00387     RtcNewFunc m_New;
00388     
00396     RtcDeleteFunc m_Delete;
00397     
00405     NumberingPolicy* m_policy;
00406   };
00407 };
00408 #endif // RTC_FACTORY_H


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sun Mar 26 2017 03:37:15