* Add existing files.
[matthijs/ABM2.git] / ABM2 / Engine / functor.h
1 #ifndef FUNCTOR_H_INCLUDED\r
2 #define FUNCTOR_H_INCLUDED\r
3 \r
4 #include "mmanager.h"\r
5 \r
6 class Functor : public IMMObject\r
7 {\r
8 public:\r
9         virtual int operator ()()=0;\r
10 };\r
11 \r
12 template<class T>\r
13 class ObjFunctor : public Functor\r
14 {\r
15 protected:\r
16         T *obj;\r
17         typedef int (T::*funcType)();\r
18         funcType func;\r
19 public:\r
20         AUTO_SIZE;\r
21 \r
22         ObjFunctor(T *o, funcType f) \r
23         { obj=o; func=f; }\r
24 \r
25         int operator ()() \r
26         { return (obj->*func)(); }\r
27 };\r
28 \r
29 template<class T>\r
30 class MMObjFunctor : public Functor\r
31 {\r
32 protected:\r
33         CMMPointer<T> obj;\r
34         typedef int (T::*funcType)();\r
35         funcType func;\r
36 public:\r
37         AUTO_SIZE;\r
38 \r
39         MMObjFunctor(T *o, funcType f) \r
40         { obj=o; func=f; }\r
41 \r
42         int operator ()() \r
43         { return (obj->*func)(); }\r
44 };\r
45 \r
46 #endif