Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/levelLoader/src/util/loading/factory.cc @ 4253

Last change on this file since 4253 was 4253, checked in by bensch, 19 years ago

orxonox/branches/levelLoader: constifization

File size: 2.1 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
[4250]13   co-programmer: Benjamin Grauer
[3940]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*/
[4253]67BaseObject* Factory::fabricate(const TiXmlElement* data)
[3940]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
[4239]90const char* grabParameter(const TiXmlElement* root, const char* name)
[3940]91{
[4239]92  const TiXmlElement* element;
93  const 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.