Changeset 4739 in orxonox.OLD for orxonox/trunk/src/util
- Timestamp:
- Jun 30, 2005, 4:05:23 PM (19 years ago)
- Location:
- orxonox/trunk/src/util/loading
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/loading/factory.cc
r4730 r4739 35 35 this->setName(factoryName); 36 36 37 if (Factory::first == NULL) 38 Factory::first = this; 39 next = NULL; 37 this->next = NULL; 40 38 41 initialize();39 Factory::registerFactory(this); 42 40 } 43 41 42 /** a reference to the First Factory */ 44 43 Factory* Factory::first = NULL; 45 44 … … 59 58 60 59 /** 61 \brief make this particular factory known to the LevelFactory 62 */ 63 void Factory::initialize() 64 { 65 GameLoader::getInstance()->registerFactory( this); 66 } 67 68 /** 69 \brief add a Factory to the Q 60 \brief add a Factory to the Factory Queue 61 \param factory a Factory to be registered 70 62 */ 71 63 void Factory::registerFactory( Factory* factory) 72 64 { 73 if( next == NULL) setNext( factory); 74 else next->registerFactory( factory); 65 assert( factory != NULL); 66 67 PRINTF(4)("Registered factory for '%s'\n", factory->getName()); 68 69 if( Factory::first == NULL) 70 Factory::first = factory; 71 else 72 { 73 Factory* tmpFac = Factory::first; 74 while( tmpFac->next != NULL) 75 { 76 tmpFac = tmpFac->next; 77 } 78 tmpFac->setNext(factory); 79 } 75 80 } 76 -
orxonox/trunk/src/util/loading/factory.h
r4730 r4739 46 46 47 47 virtual BaseObject* fabricate(const TiXmlElement* root) = NULL; 48 void initialize(); 49 void registerFactory( Factory* factory);48 49 static void registerFactory( Factory* factory); 50 50 /** \brief sets the Next factory in the list \param nextFactory the next factory */ 51 51 inline void setNext( Factory* nextFactory) { this->next = nextFactory; }; 52 52 /** \returns the first factory */ 53 static Factory* getFirst( void) { return Factory::first; };53 static Factory* getFirst() { return Factory::first; }; 54 54 /** \returns the next factory */ 55 55 Factory* getNext(void) const { return this->next; }; 56 56 57 57 58 private: 59 Factory* next; //!< pointer to the next factory. 60 static Factory* first; //!< A pointer to the first factory. 58 private: 59 60 private: 61 Factory* next; //!< pointer to the next factory. 62 static Factory* first; //!< A pointer to the first factory. 61 63 }; 62 64 -
orxonox/trunk/src/util/loading/game_loader.cc
r4729 r4739 43 43 this->setClassID(CL_GAME_LOADER, "GameLoader"); 44 44 this->setName("GameLoader"); 45 first = NULL;46 45 } 47 46 … … 317 316 } 318 317 319 320 /**321 \brief add a Factory to the Factory Q322 \param factory a Factory to be registered323 */324 void GameLoader::registerFactory( Factory* factory)325 {326 assert( factory != NULL);327 328 PRINTF(4)("Registered factory for '%s'\n", factory->getName());329 330 if( first == NULL) first = factory;331 else first->registerFactory( factory);332 }333 334 335 318 /** 336 319 \brief load a StoryEntity … … 341 324 assert( element != NULL); 342 325 343 if( first== NULL)326 if( Factory::getFirst() == NULL) 344 327 { 345 328 PRINTF(1)("GameLoader does not know any factories, fabricate() failed\n"); … … 350 333 { 351 334 PRINTF(4)("Attempting fabrication of a '%s'\n", element->Value()); 352 BaseObject* b = first->fabricate( element);335 BaseObject* b = Factory::getFirst()->fabricate( element); 353 336 if( b == NULL) 354 337 PRINTF(2)("Failed to fabricate a '%s'\n", element->Value()); -
orxonox/trunk/src/util/loading/game_loader.h
r4598 r4739 80 80 81 81 EventHandler* eventHandler; //!< reference to the eventHandler 82 83 Factory* first; //!< the first factory of them all84 82 }; 85 83
Note: See TracChangeset
for help on using the changeset viewer.