Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/movie_player/src/factory.cc @ 4217

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

orxonox/branches/movie_player: merged the trunk back into the movie_player
merged with command:
svn merge -r 4014:HEAD ../trunk/ movie_player/
no conflicts

File size: 2.0 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: ...
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( 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( TiXmlElement* root, const char* name)
91{
92  TiXmlElement* element;
93  TiXmlNode* node;
94       
95  assert( root != NULL);
96  assert( name != NULL);
97       
98  element = root->FirstChildElement( name);
99  if( element == NULL) return NULL;
100       
101  node = element->FirstChild();
102  while( node != NULL)
103    {
104      if( node->ToText()) return node->Value();
105      node = node->NextSibling();
106    }
107  return NULL;
108}
109
Note: See TracBrowser for help on using the repository browser.