Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/levelloader/src/factory.h @ 3525

Last change on this file since 3525 was 3525, checked in by chris, 20 years ago

orxonox/branches/levelloader: removed excess class usage adn messed with makefile definitions

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