ECFactory.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef RTC_ECFACTORY_H
00021 #define RTC_ECFACTORY_H
00022 
00023 #include <rtm/ExecutionContextBase.h>
00024 #include <string>
00025 
00026 namespace RTC 
00027 {
00028   
00029   typedef ExecutionContextBase* (*ECNewFunc)();
00030   typedef void (*ECDeleteFunc)(ExecutionContextBase* ec);
00031   
00051   template <class _New>
00052   ExecutionContextBase* ECCreate()
00053   {
00054     return new _New();
00055   }
00056   
00076   template <class _Delete>
00077   void ECDelete(ExecutionContextBase* ec)
00078   {
00079     delete ec;
00080   }
00081   
00115   class ECFactoryBase
00116   {
00117   public:
00133     virtual ~ECFactoryBase(void){};
00134     
00156     virtual const char* name() = 0;
00157     
00177     virtual ExecutionContextBase* create() = 0;
00178     
00198     virtual void destroy(ExecutionContextBase* comp) = 0;
00199   protected:
00200   };
00201   
00221   class ECFactoryCXX
00222     : public ECFactoryBase
00223   {
00224   public:
00248     ECFactoryCXX(const char* name,
00249                  ECNewFunc new_func,
00250                  ECDeleteFunc delete_func);
00251     
00267     ~ECFactoryCXX(void);
00268     
00288     virtual const char* name();
00289     
00309     virtual ExecutionContextBase* create();
00310     
00330     virtual void destroy(ExecutionContextBase* comp);
00331     
00332   protected:
00340     std::string m_name;
00341     
00349     ECNewFunc m_New;
00350     
00358     ECDeleteFunc m_Delete;
00359   };
00360 };
00361 #endif // RTC_ECFACTORY_H


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Aug 27 2015 14:16:37