Changeset 4597 in orxonox.OLD for orxonox/trunk/src/util/loading/factory.h
- Timestamp:
- Jun 11, 2005, 12:55:48 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/loading/factory.h
r4492 r4597 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 14 14 */ 15 15 16 /*! 16 /*! 17 17 \file factory.h 18 18 \brief A loadable object handler … … 27 27 #include "tinyxml.h" 28 28 #include "load_param.h" 29 #include "base_object.h" 29 30 #include "debug.h" 30 31 31 /** 32 /** 32 33 Creates a factory to a Loadable Class. 33 34 this should be used at the beginning of all the Classes that should be loadable (in the cc-file) 35 \todo make factoryName a BaseObject-parameter. (else it would be redundant) 34 36 */ 35 #define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##Factory = new tFactory<CLASS_NAME>(#CLASS_NAME) 37 #define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##Factory = new tFactory<CLASS_NAME>(#CLASS_NAME) 36 38 37 39 //! The Factory is a loadable object handler 38 class Factory {40 class Factory : public BaseObject { 39 41 40 42 public: 41 43 Factory (const char* factoryName = NULL); 42 44 ~Factory (); 43 45 44 46 45 47 virtual BaseObject* fabricate(const TiXmlElement* root); … … 53 55 /** \returns the next factory */ 54 56 Factory* getNext(void) const { return this->next; }; 55 57 56 58 protected: 57 59 char* factoryName; //!< the name of the factory … … 69 71 tFactory(const char* factoryName); 70 72 virtual ~tFactory(); 71 73 72 74 private: 73 75 BaseObject* fabricate(const TiXmlElement* root); … … 83 85 PRINTF(5)("fileName: %s loadable\n", this->factoryName); 84 86 } 85 87 86 88 87 89 template<class T> … … 90 92 91 93 template<class T> 92 BaseObject* tFactory<T>::fabricate(const TiXmlElement* root) 93 { 94 BaseObject* tFactory<T>::fabricate(const TiXmlElement* root) 95 { 94 96 if(!strcmp(root->Value(), getFactoryName())) 95 97 return new T ( root); 96 else if( getNext() != NULL) 98 else if( getNext() != NULL) 97 99 return getNext()->fabricate( root); 98 else 100 else 99 101 return NULL; 100 102 }
Note: See TracChangeset
for help on using the changeset viewer.