| 1 | /* |
|---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
|---|
| 3 | |
|---|
| 4 | Copyright (C) 2004 orx |
|---|
| 5 | |
|---|
| 6 | This program is free software; you can redistribute it and/or modify |
|---|
| 7 | it under the terms of the GNU General Public License as published by |
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
|---|
| 9 | any later version. |
|---|
| 10 | |
|---|
| 11 | ### File Specific: |
|---|
| 12 | main-programmer: Christian Meyer |
|---|
| 13 | co-programmer: Benjamin Grauer |
|---|
| 14 | */ |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | #include "factory.h" |
|---|
| 18 | #include "game_loader.h" |
|---|
| 19 | |
|---|
| 20 | using namespace std; |
|---|
| 21 | |
|---|
| 22 | /* -------------------------------------------------- |
|---|
| 23 | * Factory |
|---|
| 24 | * -------------------------------------------------- |
|---|
| 25 | */ |
|---|
| 26 | |
|---|
| 27 | /** |
|---|
| 28 | \brief constructor |
|---|
| 29 | |
|---|
| 30 | set everything to zero and define factoryName |
|---|
| 31 | */ |
|---|
| 32 | Factory::Factory (const char* factoryName) |
|---|
| 33 | { |
|---|
| 34 | this->setClassID(CL_FACTORY, "Factory"); |
|---|
| 35 | this->setName(factoryName); |
|---|
| 36 | |
|---|
| 37 | this->factoryName = NULL; |
|---|
| 38 | this->setFactoryName(factoryName); |
|---|
| 39 | next = NULL; |
|---|
| 40 | |
|---|
| 41 | initialize(); |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | /** |
|---|
| 45 | \brief destructor |
|---|
| 46 | |
|---|
| 47 | clear the Q |
|---|
| 48 | */ |
|---|
| 49 | Factory::~Factory () |
|---|
| 50 | { |
|---|
| 51 | // printf("%s\n", this->factoryName); |
|---|
| 52 | // Factory* tmpDel = this->next; |
|---|
| 53 | // this->next = NULL; |
|---|
| 54 | if (this->next) |
|---|
| 55 | delete this->next; |
|---|
| 56 | |
|---|
| 57 | if (this->factoryName) |
|---|
| 58 | delete []this->factoryName; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | /** |
|---|
| 62 | \brief sets the name of this factory |
|---|
| 63 | */ |
|---|
| 64 | void Factory::setFactoryName(const char* factoryName) |
|---|
| 65 | { |
|---|
| 66 | if (this->factoryName) |
|---|
| 67 | delete this->factoryName; |
|---|
| 68 | this->factoryName = new char[strlen(factoryName)+1]; |
|---|
| 69 | strcpy(this->factoryName, factoryName); |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | /** |
|---|
| 74 | \brief generates the associated object from data |
|---|
| 75 | */ |
|---|
| 76 | BaseObject* Factory::fabricate(const TiXmlElement* data) |
|---|
| 77 | { |
|---|
| 78 | return NULL; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | /** |
|---|
| 82 | \brief make this particular factory known to the LevelFactory |
|---|
| 83 | */ |
|---|
| 84 | void Factory::initialize() |
|---|
| 85 | { |
|---|
| 86 | #ifdef IS_ORXONOX |
|---|
| 87 | GameLoader::getInstance()->registerFactory( this); |
|---|
| 88 | #endif /* IS_ORXONOX */ |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | /** |
|---|
| 92 | \brief add a Factory to the Q |
|---|
| 93 | */ |
|---|
| 94 | void Factory::registerFactory( Factory* factory) |
|---|
| 95 | { |
|---|
| 96 | if( next == NULL) setNext( factory); |
|---|
| 97 | else next->registerFactory( factory); |
|---|
| 98 | } |
|---|
| 99 | |
|---|