Changeset 9762 in orxonox.OLD for branches/new_class_id/src/lib/util/loading/factory.h
- Timestamp:
- Sep 19, 2006, 5:00:10 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/loading/factory.h
r9757 r9762 27 27 #include "parser/tinyxml/tinyxml.h" 28 28 #include "base_object.h" 29 #include < list>29 #include <map> 30 30 31 31 /** … … 34 34 */ 35 35 #define CREATE_FACTORY(CLASS_NAME) \ 36 tFactory<CLASS_NAME> * global_##CLASS_NAME##_Factory = newtFactory<CLASS_NAME>(CLASS_NAME::staticClassID())36 tFactory<CLASS_NAME> global_##CLASS_NAME##_Factory = tFactory<CLASS_NAME>(CLASS_NAME::staticClassID()) 37 37 38 38 //! The Factory is a loadable object handler 39 39 class Factory : public BaseObject 40 40 { 41 //! Declare the ObjectList at the BaseObject List 41 42 ObjectListDeclaration(Factory); 42 43 public: 43 44 virtual ~Factory (); 44 45 static void deleteFactories();46 45 47 46 static BaseObject* fabricate(const std::string& className); … … 49 48 static BaseObject* fabricate(const TiXmlElement* root); 50 49 51 52 50 bool operator==(int classID) const; 53 51 bool operator==(const std::string& className) const; 52 /** @param classID the ID to compare @returns true if the ID's match */ 54 53 bool operator==(const ClassID& classID) const { return _classID == classID; }; 54 55 56 void debug() const; 57 static void debugAll(); 55 58 56 59 protected: 57 60 Factory (const ClassID& id); 61 /** 62 * @brief The core function of the Factory. Creates objects of the Factories Type. 63 * @param root The TiXmlElement of the Factory. 64 * @returns the created Object in BaseType* format. 65 */ 58 66 virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const = 0; 59 67 60 68 private: 69 //! Copy Constructor is hidden. 61 70 Factory (const Factory&) {}; 62 71 63 72 protected: 64 const ClassID _classID; //!< The Class-Identifyer of the Factory. 65 static std::list<Factory*>* _factoryList; //!< List of Registered Factories 73 /** The Type of the FactoryMap that is sorted by ID */ 74 typedef std::map<const ClassID, Factory*> FactoryIDMap; 75 /** The Type of the FactoryMap that is sorted by Name */ 76 typedef std::map<std::string, Factory*> FactoryStringMap; 77 78 const ClassID _classID; //!< The Class-Identifyer of the Factory. 79 static FactoryIDMap _factoryIDMap; //!< List of Registered Factories 80 static FactoryStringMap _factoryStringMap; //!< List of Registered Factories 66 81 }; 67 82 … … 75 90 /** 76 91 * @brief creates a new type Factory to enable the loading of T 77 * @param factoryName the Name of the Factory to load.78 92 * @param classID the ID of the Class to be created. 79 93 */ … … 81 95 : Factory(classID) 82 96 { } 97 /** 98 * @brief copy constructor 99 * @param factory the Factory to copy 100 */ 101 tFactory (const tFactory& factory) : Factory(factory._classID) {}; 83 102 84 private:85 tFactory (const tFactory&) {};86 103 /** 87 104 * @brief fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
Note: See TracChangeset
for help on using the changeset viewer.