Last change
on this file since 3947 was
3903,
checked in by bensch, 20 years ago
|
orxonox/branches/levelLoader.tmp: some merges
|
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 | #include "tinyxml.h" |
---|
28 | |
---|
29 | class BaseObject; |
---|
30 | |
---|
31 | //! The Factory is |
---|
32 | /** |
---|
33 | Very philosophic description, huh? |
---|
34 | */ |
---|
35 | class Factory { |
---|
36 | |
---|
37 | public: |
---|
38 | Factory (); |
---|
39 | ~Factory (); |
---|
40 | |
---|
41 | virtual BaseObject* fabricate( TiXmlElement* root); |
---|
42 | void initialize(); |
---|
43 | void registerFactory( Factory* factory); |
---|
44 | void setClassname(char* name) {classname = name;} |
---|
45 | char* getClassname() {return classname;}; |
---|
46 | void setNext( Factory* factory) {next = factory;} |
---|
47 | Factory* getNext() {return next;} |
---|
48 | |
---|
49 | private: |
---|
50 | char* classname; |
---|
51 | |
---|
52 | Factory* next; |
---|
53 | }; |
---|
54 | |
---|
55 | // helper function |
---|
56 | |
---|
57 | const char* grabParameter( TiXmlElement* root, const char* name); |
---|
58 | |
---|
59 | #endif /* _FACTORY_H */ |
---|
60 | |
---|
Note: See
TracBrowser
for help on using the repository browser.