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
|
Rev | Line | |
---|
[3504] | 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: \ |
---|
[3525] | 17 | BaseObject* fabricate( TiXmlElement* root) \ |
---|
[3504] | 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 | }; \ |
---|
| 24 | CLASSFactory global_CLASSFactory; |
---|
| 25 | |
---|
| 26 | //! The Factory is |
---|
| 27 | /** |
---|
| 28 | Very philosophic description, huh? |
---|
| 29 | */ |
---|
| 30 | class Factory { |
---|
| 31 | |
---|
| 32 | public: |
---|
| 33 | Factory (); |
---|
| 34 | ~Factory (); |
---|
| 35 | |
---|
[3525] | 36 | virtual BaseObject* fabricate( TiXmlElement* root); |
---|
[3504] | 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 | |
---|
[3525] | 51 | const char* grabParameter( TiXmlElement* root, const char* name); |
---|
[3504] | 52 | |
---|
[3525] | 53 | #endif /* _FACTORY_H */ |
---|
| 54 | |
---|
Note: See
TracBrowser
for help on using the repository browser.