[4597] | 1 | /* |
---|
[3940] | 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 |
---|
[4250] | 13 | co-programmer: Benjamin Grauer |
---|
[3940] | 14 | */ |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | #include "factory.h" |
---|
| 18 | #include "game_loader.h" |
---|
| 19 | |
---|
| 20 | using namespace std; |
---|
| 21 | |
---|
| 22 | /* -------------------------------------------------- |
---|
[4597] | 23 | * Factory |
---|
[4003] | 24 | * -------------------------------------------------- |
---|
| 25 | */ |
---|
[3940] | 26 | |
---|
| 27 | /** |
---|
| 28 | \brief constructor |
---|
[4597] | 29 | |
---|
[4020] | 30 | set everything to zero and define factoryName |
---|
[3940] | 31 | */ |
---|
[4487] | 32 | Factory::Factory (const char* factoryName) |
---|
[3940] | 33 | { |
---|
[4597] | 34 | this->setClassID(CL_FACTORY, "Factory"); |
---|
| 35 | this->setName(factoryName); |
---|
| 36 | |
---|
[4020] | 37 | this->factoryName = NULL; |
---|
[4487] | 38 | this->setFactoryName(factoryName); |
---|
[4003] | 39 | next = NULL; |
---|
[4597] | 40 | |
---|
[4003] | 41 | initialize(); |
---|
[3940] | 42 | } |
---|
| 43 | |
---|
| 44 | /** |
---|
| 45 | \brief destructor |
---|
[4597] | 46 | |
---|
[3940] | 47 | clear the Q |
---|
| 48 | */ |
---|
| 49 | Factory::~Factory () |
---|
| 50 | { |
---|
[4020] | 51 | // printf("%s\n", this->factoryName); |
---|
[4004] | 52 | // Factory* tmpDel = this->next; |
---|
| 53 | // this->next = NULL; |
---|
| 54 | if (this->next) |
---|
| 55 | delete this->next; |
---|
[4487] | 56 | |
---|
| 57 | if (this->factoryName) |
---|
| 58 | delete []this->factoryName; |
---|
[3940] | 59 | } |
---|
| 60 | |
---|
[4487] | 61 | /** |
---|
| 62 | \brief sets the name of this factory |
---|
| 63 | */ |
---|
| 64 | void Factory::setFactoryName(const char* factoryName) |
---|
[4004] | 65 | { |
---|
[4487] | 66 | if (this->factoryName) |
---|
| 67 | delete this->factoryName; |
---|
| 68 | this->factoryName = new char[strlen(factoryName)+1]; |
---|
| 69 | strcpy(this->factoryName, factoryName); |
---|
[4004] | 70 | } |
---|
| 71 | |
---|
| 72 | |
---|
[3940] | 73 | /** |
---|
| 74 | \brief generates the associated object from data |
---|
| 75 | */ |
---|
[4253] | 76 | BaseObject* Factory::fabricate(const TiXmlElement* data) |
---|
[3940] | 77 | { |
---|
[4003] | 78 | return NULL; |
---|
[3940] | 79 | } |
---|
| 80 | |
---|
| 81 | /** |
---|
| 82 | \brief make this particular factory known to the LevelFactory |
---|
| 83 | */ |
---|
| 84 | void Factory::initialize() |
---|
| 85 | { |
---|
[4003] | 86 | GameLoader* gl = GameLoader::getInstance(); |
---|
| 87 | gl->registerFactory( this); |
---|
[3940] | 88 | } |
---|
| 89 | |
---|
| 90 | /** |
---|
| 91 | \brief add a Factory to the Q |
---|
| 92 | */ |
---|
| 93 | void Factory::registerFactory( Factory* factory) |
---|
| 94 | { |
---|
[4003] | 95 | if( next == NULL) setNext( factory); |
---|
| 96 | else next->registerFactory( factory); |
---|
[3940] | 97 | } |
---|
| 98 | |
---|