Changeset 9684 in orxonox.OLD for branches/new_class_id/src/lib/util/loading/factory.h
- Timestamp:
- Aug 22, 2006, 1:34:31 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/loading/factory.h
r8148 r9684 38 38 39 39 //! The Factory is a loadable object handler 40 class Factory : public BaseObject { 41 42 public: 40 class Factory : public BaseObject 41 { 42 NewObjectListDeclaration(Factory); 43 public: 43 44 virtual ~Factory (); 44 45 … … 46 47 47 48 static BaseObject* fabricate(const std::string& className); 48 static BaseObject* fabricate( ClassIDclassID);49 static BaseObject* fabricate(int classID); 49 50 static BaseObject* fabricate(const TiXmlElement* root = NULL); 50 51 51 52 52 bool operator==( ClassIDclassID) const;53 bool operator==(int classID) const; 53 54 bool operator==(const char* className) const; 54 55 bool operator==(const std::string& className) const; 55 56 56 57 Factory (const std::string& factoryName, ClassIDclassID);58 57 protected: 58 Factory (const std::string& factoryName, int classID); 59 virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const = 0; 59 60 60 61 const ClassIDclassID; //!< The Class-Identifyer of the Factory.62 63 61 protected: 62 const int classID; //!< The Class-Identifyer of the Factory. 63 const std::string className; //!< The name of the Class. 64 static std::list<Factory*>* factoryList; //!< List of Registered Factories 64 65 }; 65 66 … … 70 71 template<class T> class tFactory : public Factory 71 72 { 72 73 /**74 * @brief creates a new type Factory to enable the loading of T75 * @param factoryName the Name of the Factory to load.76 * @param classID the ID of the Class to be created.77 */78 tFactory (const char* factoryName, ClassIDclassID)79 : Factory(factoryName, classID)73 public: 74 /** 75 * @brief creates a new type Factory to enable the loading of T 76 * @param factoryName the Name of the Factory to load. 77 * @param classID the ID of the Class to be created. 78 */ 79 tFactory (const char* factoryName, int classID) 80 : Factory(factoryName, classID) 80 81 { } 81 82 82 83 84 85 86 87 88 89 90 91 83 private: 84 /** 85 * @brief fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*) 86 * @param root the TiXmlElement T should load parameters from. 87 * @return the newly fabricated T. 88 */ 89 virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const 90 { 91 return new T(root); 92 } 92 93 }; 93 94
Note: See TracChangeset
for help on using the changeset viewer.