Factory.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef Factory_h
00021 #define 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     
00351     virtual RTObject_impl* create(Manager* mgr);
00352     
00372     virtual void destroy(RTObject_impl* comp);
00373     
00374   protected:
00382     RtcNewFunc m_New;
00383     
00391     RtcDeleteFunc m_Delete;
00392     
00400     NumberingPolicy* m_policy;
00401   };
00402 };
00403 #endif // Factory_h

Generated on Sun May 24 14:08:45 2009 for OpenRTM by  doxygen 1.5.3