Changeset 9684 in orxonox.OLD for branches/new_class_id/src/lib/util/loading
- Timestamp:
- Aug 22, 2006, 1:34:31 AM (19 years ago)
- Location:
- branches/new_class_id/src/lib/util/loading
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/loading/dynamic_loader.cc
r9406 r9684 24 24 25 25 26 26 NewObjectListDefinition(DynamicLoader); 27 27 28 28 /** … … 31 31 */ 32 32 DynamicLoader::DynamicLoader (const std::string& libName) 33 : Factory(NULL, CL_NULL)33 : Factory(NULL, 0) 34 34 { 35 this-> setClassID(CL_DYNAMIC_LOADER, "DynamicLoader");35 this->registerObject(this, DynamicLoader::_objectList); 36 36 37 37 this->handle = NULL; -
branches/new_class_id/src/lib/util/loading/dynamic_loader.h
r7193 r9684 19 19 class DynamicLoader : public Factory 20 20 { 21 NewObjectListDeclaration(DynamicLoader); 21 22 22 23 public: -
branches/new_class_id/src/lib/util/loading/factory.cc
r9675 r9684 19 19 //#include "shell_command.h" 20 20 21 21 NewObjectListDefinition(Factory); 22 22 23 23 //SHELL_COMMAND(create, Factory, fabricate); … … 28 28 * set everything to zero and define factoryName 29 29 */ 30 Factory::Factory (const std::string& factoryName, ClassIDclassID)30 Factory::Factory (const std::string& factoryName, int classID) 31 31 : classID(classID), className(factoryName) 32 32 { 33 this-> setClassID(CL_FACTORY, "Factory");33 this->registerObject(this, Factory::_objectList); 34 34 this->setName(factoryName); 35 35 … … 74 74 * @returns true on match, false otherwise 75 75 */ 76 bool Factory::operator==( ClassIDclassID) const76 bool Factory::operator==(int classID) const 77 77 { 78 78 return (this->classID == classID); … … 149 149 * @returns a new Object of Type classID on match, NULL otherwise 150 150 */ 151 BaseObject* Factory::fabricate( ClassIDclassID)151 BaseObject* Factory::fabricate(int classID) 152 152 { 153 153 if (Factory::factoryList == NULL) -
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 -
branches/new_class_id/src/lib/util/loading/game_loader.cc
r9110 r9684 28 28 #include "key_mapper.h" 29 29 30 NewObjectListDefinition(GameLoader); 30 31 31 32 … … 43 44 GameLoader::GameLoader () 44 45 { 45 this-> setClassID(CL_GAME_LOADER, "GameLoader");46 this->registerObject(this, GameLoader::_objectList); 46 47 this->setName("GameLoader"); 47 48 this->bRun = true; … … 57 58 delete this->currentCampaign; 58 59 this->currentCampaign = NULL; 59 60 60 61 GameLoader::singletonRef = NULL; 61 62 } -
branches/new_class_id/src/lib/util/loading/game_loader.h
r7868 r9684 38 38 class GameLoader : public EventListener 39 39 { 40 public: 40 NewObjectListDeclaration(GameLoader); 41 public: 41 42 virtual ~GameLoader (); 42 43 /** this class is a singleton class @returns an instance of itself */ -
branches/new_class_id/src/lib/util/loading/resource_manager.cc
r9406 r9684 50 50 #include <unistd.h> 51 51 52 52 NewObjectListDefinition(ResourceManager); 53 53 54 54 /** … … 57 57 ResourceManager::ResourceManager () 58 58 { 59 this-> setClassID(CL_RESOURCE_MANAGER, "ResourceManager");59 this->registerObject(this, ResourceManager::_objectList); 60 60 this->setName("ResourceManager"); 61 61 -
branches/new_class_id/src/lib/util/loading/resource_manager.h
r8724 r9684 94 94 class ResourceManager : public BaseObject 95 95 { 96 public: 96 NewObjectListDeclaration(ResourceManager); 97 public: 97 98 virtual ~ResourceManager(); 98 99 /** @returns a Pointer to the only object of this Class */ … … 101 102 bool setDataDir(const std::string& dataDir); 102 103 /** @returns the Name of the data directory */ 103 104 inline const std::string& getDataDir() const { return this->dataDir; }; 104 105 105 106 … … 139 140 static ResourceType stringToResourceType(const std::string& resourceType); 140 141 141 142 private: 142 143 ResourceManager(); 143 144 Resource* loadResource(const std::string& fileName, ResourceType type, ResourcePriority prio, 144 145 const MultiType& param0, const MultiType& param1, const MultiType& param2); 145 146 146 147 private: 147 148 static ResourceManager* singletonRef; //!< singleton Reference 148 149
Note: See TracChangeset
for help on using the changeset viewer.