Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/levelloader/src/factory.cc @ 3530

Last change on this file since 3530 was 3530, checked in by chris, 19 years ago

orxonox/branches/levelloader: Got the system to compile, the basic backbone now runs. What remains to be done is implementing all necessary functions to load all vital classes into a world

File size: 1.8 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Christian Meyer
15   co-programmer: ...
16*/
17
18
19#include "factory.h"
20#include "game_loader.h"
21
22using namespace std;
23
24/*  --------------------------------------------------
25*                Factory
26*   --------------------------------------------------
27*/
28
29/**
30   \brief constructor
31   
32   set everything to zero and define classname
33*/
34Factory::Factory ()
35{
36        classname = "NULL";
37        next = NULL;
38}
39
40/**
41   \brief destructor
42   
43   clear the Q
44*/
45Factory::~Factory ()
46{
47        if( next != NULL)       delete next;
48}
49
50
51/**
52   \brief generates the associated object from data
53*/
54BaseObject* Factory::fabricate( TiXmlElement* data)
55{
56        return NULL;
57}
58
59/**
60   \brief make this particular factory known to the LevelFactory
61*/
62void Factory::initialize()
63{
64        assert( classname != NULL);
65        PRINTF(3)("Initializing %sFactory\n", classname);
66        GameLoader* gl = GameLoader::getInstance();
67        gl->registerFactory( this);
68}
69
70/**
71   \brief add a Factory to the Q
72*/
73void Factory::registerFactory( Factory* factory)
74{
75        if( next == NULL) setNext( factory);
76        else next->registerFactory( factory);
77}
78
79const char* grabParameter( TiXmlElement* root, const char* name)
80{
81        TiXmlElement* element;
82        TiXmlNode* node;
83       
84        assert( root != NULL);
85        assert( name != NULL);
86       
87        element = root->FirstChildElement( name);
88        if( element == NULL) return NULL;
89       
90        node = element->FirstChild();
91        while( node != NULL)
92        {
93                if( node->ToText()) return node->Value();
94                node = node->NextSibling();
95        }
96        return NULL;
97}
98
Note: See TracBrowser for help on using the repository browser.