Last change
on this file since 4233 was
4233,
checked in by bensch, 19 years ago
|
orxonox/branches/levelLoader: loading through Functors.
This should make our lives much more simple, if they are implemented real good.
This will take some time, and i would like you to comment on this.
|
File size:
731 bytes
|
Rev | Line | |
---|
[4233] | 1 | |
---|
| 2 | #ifndef _LOAD_PARAM_H |
---|
| 3 | #define _LOAD_PARAM_H |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | // abstract base class |
---|
| 7 | class baseLoadParam |
---|
| 8 | { |
---|
| 9 | public: |
---|
| 10 | // virtual void Call(const char* string)=0; // call using function |
---|
| 11 | }; |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | // derived template class |
---|
| 15 | template<class T> class LoadParam : public baseLoadParam |
---|
| 16 | { |
---|
| 17 | private: |
---|
| 18 | T* pt2Object; // pointer to object |
---|
| 19 | |
---|
| 20 | public: |
---|
| 21 | LoadParam(const char* loadString, T* pt2Object, void(T::*function)(const char*)) |
---|
| 22 | { |
---|
| 23 | this->pt2Object = pt2Object; |
---|
| 24 | |
---|
| 25 | (*pt2Object.*function)(loadString); |
---|
| 26 | }; |
---|
| 27 | |
---|
| 28 | LoadParam(const char* loadString, T* pt2Object, void(T::*function)(float)) |
---|
| 29 | { |
---|
| 30 | this->pt2Object = pt2Object; |
---|
| 31 | |
---|
| 32 | (*pt2Object.*function)(atoi(loadString)); |
---|
| 33 | }; |
---|
| 34 | }; |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | #endif /* _LOAD_PARAM_H */ |
---|
Note: See
TracBrowser
for help on using the repository browser.