00001
00002 #ifndef DDF_COMMFACTORY_HPP
00003 #define DDF_COMMFACTORY_HPP
00004
00005 #include "commbase.hpp"
00006
00007 namespace jafar
00008 {
00009 namespace ddf
00010 {
00015 class CommFactoryBase
00016 {
00017 protected:
00018 unsigned short m_sv_size;
00019
00020 public:
00021 CommFactoryBase(unsigned short sv_size) : m_sv_size(sv_size) {}
00022 virtual ~CommFactoryBase(){}
00023
00024 virtual CommBase* CreateCommObject()=0;
00025 virtual CommBase* CreateCommObject(key_t key)=0;
00026
00027 };
00028
00033 template<typename T>
00034 class CommFactoryGeneric : public CommFactoryBase
00035 {
00036 public:
00037 CommFactoryGeneric(unsigned short sv_size):CommFactoryBase(sv_size) {}
00038 virtual ~CommFactoryGeneric() {}
00039
00040 CommBase* CreateCommObject() { return new T(m_sv_size); }
00041 CommBase* CreateCommObject(key_t key) { return new T(m_sv_size, key); }
00042 };
00043
00044
00045 }
00046 }
00047 #endif