00001 00002 // X3DComponentCreator.h // 00004 00005 #ifndef X3DCOMPONENTCREATOR_H 00006 #define X3DCOMPONENTCREATOR_H 00007 00008 #include "X3DComponent.h" 00009 #include "CreationFunction.h" 00010 00011 namespace X3DTK { 00012 00014 00015 class X3DComponentCreator : public X3DComponent 00016 { 00017 public: 00019 X3DComponentCreator(); 00021 virtual ~X3DComponentCreator() = 0; 00022 00024 CreationFunction *getCreationFunctionOf(const SFString &name) const; 00026 inline CreationDict getCreationDict() const {return creationDict_;}; 00027 00029 bool contains(const SFString &name) const; 00030 00031 protected: 00033 template<class T> void defineNewCreationFunction(const SFString &name, X3D::SFNode (T::*ptrF)() const) 00034 { 00035 CreationFunction *CF = new CreationFunction(reinterpret_cast<ptrToCreationFunction>(ptrF), this); 00036 creationDict_.insert(std::pair<SFString, CreationFunction *>(name, CF)); 00037 }; 00038 00039 //private: 00040 CreationDict creationDict_; 00041 }; 00042 00043 } 00044 00045 #endif