| 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 | * 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->next = NULL; |
|---|
| 38 | |
|---|
| 39 | Factory::registerFactory(this); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | /** a reference to the First Factory */ |
|---|
| 43 | Factory* Factory::first = NULL; |
|---|
| 44 | |
|---|
| 45 | /** |
|---|
| 46 | * destructor |
|---|
| 47 | |
|---|
| 48 | clear the Q |
|---|
| 49 | */ |
|---|
| 50 | Factory::~Factory () |
|---|
| 51 | { |
|---|
| 52 | // printf("%s\n", this->factoryName); |
|---|
| 53 | // Factory* tmpDel = this->next; |
|---|
| 54 | // this->next = NULL; |
|---|
| 55 | if (this->next) |
|---|
| 56 | delete this->next; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | /** |
|---|
| 60 | * add a Factory to the Factory Queue |
|---|
| 61 | * @param factory a Factory to be registered |
|---|
| 62 | */ |
|---|
| 63 | void Factory::registerFactory( Factory* factory) |
|---|
| 64 | { |
|---|
| 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 | } |
|---|
| 80 | } |
|---|