Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/ll2trunktemp/src/factory.cc @ 4003

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

orxonox/branches/ll2trunktemp: some small modifications, testing, why 2 instances of fabricate are deleted, and not just the first one

File size: 1.8 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 classname
31*/
32Factory::Factory ()
33{
34  classname = "NULL";
35  next = NULL;
36 
37  initialize();
38}
39
40/**
41   \brief destructor
42   
43   clear the Q
44*/
45Factory::~Factory ()
46{
47  printf("%s\n", this->classname);
48  Factory* tmpDel = this->next;
49  this->next = NULL;
50  //  if (tmpDel)
51  //    delete tmpDel;
52}
53
54/**
55   \brief generates the associated object from data
56*/
57BaseObject* Factory::fabricate( TiXmlElement* data)
58{
59  return NULL;
60}
61
62/**
63   \brief make this particular factory known to the LevelFactory
64*/
65void Factory::initialize()
66{
67  assert( classname != NULL);
68  GameLoader* gl = GameLoader::getInstance();
69  gl->registerFactory( this);
70}
71
72/**
73   \brief add a Factory to the Q
74*/
75void Factory::registerFactory( Factory* factory)
76{
77  if( next == NULL) setNext( factory);
78  else next->registerFactory( factory);
79}
80
81const char* grabParameter( TiXmlElement* root, const char* name)
82{
83  TiXmlElement* element;
84  TiXmlNode* node;
85       
86  assert( root != NULL);
87  assert( name != NULL);
88       
89  element = root->FirstChildElement( name);
90  if( element == NULL) return NULL;
91       
92  node = element->FirstChild();
93  while( node != NULL)
94    {
95      if( node->ToText()) return node->Value();
96      node = node->NextSibling();
97    }
98  return NULL;
99}
100
Note: See TracBrowser for help on using the repository browser.