Last change
on this file since 3517 was
3504,
checked in by chris, 20 years ago
|
orxonox/branches/levelloader: forgot to add all files and removed the outdated
|
File size:
1.2 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 "xmlparser/tinyxml.h" |
---|
11 | #include "xmlparser/tinystr.h" |
---|
12 | #include "base_object.h" |
---|
13 | #include "orxonox.h" |
---|
14 | #include "world.h" |
---|
15 | |
---|
16 | #define CREATE_FACTORY(CLASS) class CLASSFactory : public Factory { \ |
---|
17 | public: \ |
---|
18 | CLASSFactory (){setNext( NULL); setClassname = "CLASS"; initialize();} \ |
---|
19 | ~CLASSFactory (); \ |
---|
20 | private: \ |
---|
21 | BaseObject* fabricate( TiXMLElement* root) \ |
---|
22 | { \ |
---|
23 | if(!strcmp(root->Value(), getClassname())) return new CLASS( root); \ |
---|
24 | else if( next != NULL) return next->fabricate( root); \ |
---|
25 | else return NULL; \ |
---|
26 | } \ |
---|
27 | }; \ |
---|
28 | CLASSFactory global_CLASSFactory; |
---|
29 | |
---|
30 | //! The Factory is |
---|
31 | /** |
---|
32 | Very philosophic description, huh? |
---|
33 | */ |
---|
34 | class 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( ObjectFactory* factory) {next = factory}; |
---|
46 | |
---|
47 | private: |
---|
48 | char* classname; |
---|
49 | |
---|
50 | Factory* next; |
---|
51 | }; |
---|
52 | |
---|
53 | // helper function |
---|
54 | |
---|
55 | const char* grabParameter( TiXMLElement* root, const char* name); |
---|
56 | |
---|
57 | #endif /* _LEVELFACTORY_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.