Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/ll2trunktemp/src/factory.h @ 4003

Last change on this file since 4003 was 4003, checked in by bensch, 19 years ago

orxonox/branches/ll2trunktemp: some small modifications, testing, why 2 instances of fabricate are deleted, and not just the first one

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
9class BaseObject;
10
11#include "xmlparser/tinyxml.h"
12
13#define CREATE_FACTORY(x) \
14                class x ## Factory : public Factory { \
15                 public:        \
16                  x ## Factory (){setClassname( #x );} \
17                  ~x ## Factory () {}; \
18                 private: \
19                        BaseObject* fabricate( TiXmlElement* root) \
20                        { \
21                                if(!strcmp(root->Value(), getClassname())) return new  x ( root); \
22                                else if( getNext() != NULL) return getNext()->fabricate( root); \
23                                else return NULL; \
24                        } \
25                }; \
26                x ## Factory global_ ## x ## Factory;
27               
28//! The Factory is
29/**
30   Very philosophic description, huh?
31*/
32class Factory {
33
34 public:
35  Factory ();
36  ~Factory ();
37 
38
39  virtual BaseObject* fabricate( TiXmlElement* root);
40  void initialize();
41  void registerFactory( Factory* factory);
42  void setClassname(char* name) {classname = name;}
43  char* getClassname() {return classname;};
44  void setNext( Factory* factory) {next = factory;}
45  Factory* getNext() {return next;}
46       
47 private:
48  char* classname;
49       
50  Factory* next;
51};
52
53// helper function
54
55const char* grabParameter( TiXmlElement* root, const char* name);
56
57#endif /* _FACTORY_H */
58
Note: See TracBrowser for help on using the repository browser.