Last change
on this file since 3903 was
3903,
checked in by bensch, 19 years ago
|
orxonox/branches/levelLoader.tmp: some merges
|
File size:
1.3 KB
|
Rev | Line | |
---|
[3504] | 1 | /*! |
---|
| 2 | \file factory.h |
---|
| 3 | \brief philosophy stuff |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _FACTORY_H |
---|
| 7 | #define _FACTORY_H |
---|
| 8 | |
---|
[3901] | 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 | |
---|
[3504] | 26 | #include "stdincl.h" |
---|
[3903] | 27 | #include "tinyxml.h" |
---|
[3504] | 28 | |
---|
[3530] | 29 | class BaseObject; |
---|
[3504] | 30 | |
---|
| 31 | //! The Factory is |
---|
| 32 | /** |
---|
| 33 | Very philosophic description, huh? |
---|
| 34 | */ |
---|
| 35 | class Factory { |
---|
| 36 | |
---|
| 37 | public: |
---|
| 38 | Factory (); |
---|
| 39 | ~Factory (); |
---|
| 40 | |
---|
[3525] | 41 | virtual BaseObject* fabricate( TiXmlElement* root); |
---|
[3504] | 42 | void initialize(); |
---|
[3903] | 43 | void registerFactory( Factory* factory); |
---|
[3530] | 44 | void setClassname(char* name) {classname = name;} |
---|
| 45 | char* getClassname() {return classname;}; |
---|
| 46 | void setNext( Factory* factory) {next = factory;} |
---|
| 47 | Factory* getNext() {return next;} |
---|
[3504] | 48 | |
---|
| 49 | private: |
---|
| 50 | char* classname; |
---|
| 51 | |
---|
| 52 | Factory* next; |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | // helper function |
---|
| 56 | |
---|
[3525] | 57 | const char* grabParameter( TiXmlElement* root, const char* name); |
---|
[3504] | 58 | |
---|
[3525] | 59 | #endif /* _FACTORY_H */ |
---|
| 60 | |
---|
Note: See
TracBrowser
for help on using the repository browser.