Changeset 9709 in orxonox.OLD for branches/new_class_id/src/lib/util/loading/factory.h
- Timestamp:
- Aug 31, 2006, 10:51:08 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/loading/factory.h
r9691 r9709 20 20 21 21 22 #ifndef _ FACTORY_H23 #define _ FACTORY_H22 #ifndef __FACTORY_H 23 #define __FACTORY_H 24 24 25 25 class BaseObject; … … 27 27 #include "parser/tinyxml/tinyxml.h" 28 28 #include "base_object.h" 29 #include <vector>30 29 #include <list> 31 30 … … 34 33 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file) 35 34 */ 36 #define CREATE_FACTORY(CLASS_NAME , CLASS_ID) \37 tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>( #CLASS_NAME, CLASS_ID)35 #define CREATE_FACTORY(CLASS_NAME) \ 36 tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(CLASS_NAME::classID()) 38 37 39 38 //! The Factory is a loadable object handler … … 48 47 static BaseObject* fabricate(const std::string& className); 49 48 static BaseObject* fabricate(const NewClassID& classID); 50 static BaseObject* fabricate(int classID); 51 static BaseObject* fabricate(const TiXmlElement* root = NULL); 49 static BaseObject* fabricate(const TiXmlElement* root); 52 50 53 51 54 52 bool operator==(int classID) const; 55 bool operator==(const char* className) const;56 53 bool operator==(const std::string& className) const; 54 bool operator==(const NewClassID& classID) const { return _classID == classID; }; 57 55 58 56 protected: 59 Factory (const std::string& factoryName, int classID);57 Factory (const NewClassID& id); 60 58 virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const = 0; 61 59 60 private: 61 Factory (const Factory&) {}; 62 62 63 protected: 63 const int _classID; //!< The Class-Identifyer of the Factory. 64 const std::string _className; //!< The name of the Class. 64 const NewClassID _classID; //!< The Class-Identifyer of the Factory. 65 65 static std::list<Factory*>* _factoryList; //!< List of Registered Factories 66 66 }; … … 78 78 * @param classID the ID of the Class to be created. 79 79 */ 80 tFactory (const char* factoryName, intclassID)81 : Factory( factoryName,classID)80 tFactory (const NewClassID& classID) 81 : Factory(classID) 82 82 { } 83 83 84 84 private: 85 tFactory (const tFactory&) {}; 85 86 /** 86 87 * @brief fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
Note: See TracChangeset
for help on using the changeset viewer.