Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/util/loading/factory.cc @ 4285

Last change on this file since 4285 was 4261, checked in by bensch, 20 years ago

orxonox/trunk: merged the levelLoader-branche back into the trunk, because it seems to be stable.
merged with command:
svn merge -r 4230:HEAD levelLoader ../trunk
no conflicts of any interesst

File size: 2.1 KB
Line 
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
20using namespace std;
21
22/*  --------------------------------------------------
23 *               Factory
24 *   --------------------------------------------------
25 */
26
27/**
28   \brief constructor
29   
30   set everything to zero and define factoryName
31*/
32Factory::Factory (const char* name)
33{
34  this->factoryName = NULL;
35  this->setFactoryName(name);
36  next = NULL;
37 
38  initialize();
39}
40
41/**
42   \brief destructor
43   
44   clear the Q
45*/
46Factory::~Factory ()
47{
48  //  printf("%s\n", this->factoryName);
49  //  Factory* tmpDel = this->next;
50  //  this->next = NULL;
51  if (this->next)
52    delete this->next;
53}
54
55void Factory::setFactoryName(const char* name)
56{
57  if (factoryName)
58    delete factoryName;
59  factoryName = new char[strlen(name)+1];
60  strcpy(factoryName, name);
61}
62
63
64/**
65   \brief generates the associated object from data
66*/
67BaseObject* Factory::fabricate(const TiXmlElement* data)
68{
69  return NULL;
70}
71
72/**
73   \brief make this particular factory known to the LevelFactory
74*/
75void Factory::initialize()
76{
77  GameLoader* gl = GameLoader::getInstance();
78  gl->registerFactory( this);
79}
80
81/**
82   \brief add a Factory to the Q
83*/
84void Factory::registerFactory( Factory* factory)
85{
86  if( next == NULL) setNext( factory);
87  else next->registerFactory( factory);
88}
89
90const char* grabParameter(const TiXmlElement* root, const char* name)
91{
92  const TiXmlElement* element;
93  const TiXmlNode* node;
94       
95  if (root == NULL)
96    return NULL;
97  assert( name != NULL);
98       
99  element = root->FirstChildElement( name);
100  if( element == NULL) return NULL;
101       
102  node = element->FirstChild();
103  while( node != NULL)
104    {
105      if( node->ToText()) return node->Value();
106      node = node->NextSibling();
107    }
108  return NULL;
109}
110
Note: See TracBrowser for help on using the repository browser.