Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/levelLoader.tmp/src/util/levelLoader/factory.h @ 3901

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

orxonox/branches/levelLoader.tmp: temporaty

File size: 1.3 KB
Line 
1/*!
2    \file factory.h
3    \brief philosophy stuff
4*/
5
6#ifndef _FACTORY_H
7#define _FACTORY_H
8
9
10/** creates a Subclass of Factory, that HOPEFULLY loads modules \todo check it for real */
11#define CREATE_FACTORY(x) \
12                class x ## Factory : public Factory { \
13                 public:        \
14                  x ## Factory (){setNext( NULL); setClassname( #x ); initialize();} \
15                  ~x ## Factory () {}; \
16                 private: \
17                        BaseObject* fabricate( TiXmlElement* root) \
18                        { \
19                                if(!strcmp(root->Value(), getClassname())) return new  x ( root); \
20                                else if( getNext() != NULL) return getNext()->fabricate( root); \
21                                else return NULL; \
22                        } \
23                }; \
24                x ## Factory global_ ## x ## Factory;
25
26#include "stdincl.h"
27
28class BaseObject;
29
30//! The Factory is
31/**
32        Very philosophic description, huh?
33*/
34class Factory {
35
36 public:
37  Factory ();
38  ~Factory ();
39
40        virtual BaseObject* fabricate( TiXmlElement* root);
41        void initialize();
42  void registerFactory( Factory* factory);
43        void setClassname(char* name) {classname = name;}
44        char* getClassname() {return classname;};
45        void setNext( Factory* factory) {next = factory;}
46        Factory* getNext() {return next;}
47       
48 private:
49        char* classname;
50       
51  Factory* next;
52};
53
54// helper function
55
56const char* grabParameter( TiXmlElement* root, const char* name);
57
58#endif /* _FACTORY_H */
59
Note: See TracBrowser for help on using the repository browser.