Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/factory.cc @ 4215

Last change on this file since 4215 was 4020, checked in by bensch, 20 years ago

orxonox/trunk: renaming from factory→className → factory→factoryName

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