Changeset 9709 in orxonox.OLD for branches/new_class_id/src/lib/util
- Timestamp:
- Aug 31, 2006, 10:51:08 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/util
- Files:
-
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/Makefile.am
r9406 r9709 2 2 include $(MAINSRCDIR)/defs/include_paths.am 3 3 4 noinst_LIBRARIES = libORXlibutil.a 4 noinst_LIBRARIES = \ 5 libORXlibutil.a \ 6 libORXexecutor.a 7 8 libORXexecutor_a_SOURCES = \ 9 executor/executor.cc \ 10 executor/executor_functional.cc \ 11 executor/executor_lua.cc 5 12 6 13 libORXlibutil_a_SOURCES = \ … … 9 16 helper_functions.cc \ 10 17 multi_type.cc \ 11 executor/executor.cc \12 executor/executor_functional.cc \13 executor/executor_lua.cc \14 18 \ 15 19 loading/resource_manager.cc \ … … 19 23 loading/load_param_description.cc \ 20 24 loading/factory.cc \ 21 loading/ dynamic_loader.cc \25 loading/fast_factory.cc \ 22 26 \ 23 27 filesys/file.cc \ … … 28 32 threading.cc \ 29 33 timer.cc 34 35 # loading/dynamic_loader.cc 30 36 31 37 … … 55 61 loading/load_param_description.h \ 56 62 loading/factory.h \ 63 loading/fast_factory.h \ 57 64 loading/dynamic_loader.h \ 58 65 \ -
branches/new_class_id/src/lib/util/loading/dynamic_loader.cc
r9684 r9709 31 31 */ 32 32 DynamicLoader::DynamicLoader (const std::string& libName) 33 : Factory( NULL, 0)33 : Factory(libName) 34 34 { 35 35 this->registerObject(this, DynamicLoader::_objectList); -
branches/new_class_id/src/lib/util/loading/factory.cc
r9695 r9709 28 28 * set everything to zero and define factoryName 29 29 */ 30 Factory::Factory (const std::string& factoryName, intclassID)31 : _classID(classID) , _className(factoryName)30 Factory::Factory (const NewClassID& classID) 31 : _classID(classID) 32 32 { 33 this->registerObject(this, Factory::_objectList); 34 this->setName(factoryName); 33 printf("Factory::create(%s::%d)\n", classID.name().c_str(), classID.id()); 34 //this->registerObject(this, Factory::_objectList); 35 this->setName(classID.name()); 35 36 36 37 if( Factory::_factoryList == NULL) … … 79 80 } 80 81 81 /**82 * @brief Compares the Factories Name against a given ClassName83 * @param className the Name of the Class to Query84 * @returns true on match, false otherwise.85 */86 bool Factory::operator==(const char* className) const87 {88 return (className != NULL && this->_className == className);89 }90 82 91 83 /** … … 96 88 bool Factory::operator==(const std::string& className) const 97 89 { 98 return (this->_class Name== className);90 return (this->_classID.name() == className); 99 91 } 100 92 … … 143 135 } 144 136 145 146 137 /** 147 138 * @brief Creates a new Object of type classID … … 149 140 * @returns a new Object of Type classID on match, NULL otherwise 150 141 */ 151 BaseObject* Factory::fabricate( intclassID)142 BaseObject* Factory::fabricate(const NewClassID& classID) 152 143 { 153 144 if (Factory::_factoryList == NULL) … … 157 148 for (factory = Factory::_factoryList->begin(); factory != Factory::_factoryList->end(); factory++) 158 149 if (*(*factory) == classID) 159 160 161 150 { 151 PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName()); 152 return (*factory)->fabricateObject(NULL); 162 153 163 164 PRINTF(2)("Could not Fabricate an Object of ClassID ' 0x%h'\n", classID);154 } 155 PRINTF(2)("Could not Fabricate an Object of ClassID '%d'\n", classID.id()); 165 156 return NULL; 166 157 } 167 168 169 /**170 * @brief Creates a new Object of type classID171 * @param classID the ClassID to match for the newly created Object172 * @returns a new Object of Type classID on match, NULL otherwise173 */174 BaseObject* Factory::fabricate(const NewClassID& classID)175 {176 return Factory::fabricate(classID.id());177 } -
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*) -
branches/new_class_id/src/lib/util/loading/fast_factory.h
r9707 r9709 122 122 { 123 123 public: 124 static tFastFactory<T>* getFastFactory(const NewClassID& classID, const std::string& fastFactoryName = NULL);124 static tFastFactory<T>* getFastFactory(const NewClassID& classID, const std::string& fastFactoryName); 125 125 126 126 private:
Note: See TracChangeset
for help on using the changeset viewer.