1 | /*! |
---|
2 | * @file executor.h |
---|
3 | * Definition of a on-screen-shell |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _EXECUTOR_SPECIALS_H |
---|
7 | #define _EXECUTOR_SPECIALS_H |
---|
8 | |
---|
9 | #include "executor.h" |
---|
10 | #include "compiler.h" |
---|
11 | |
---|
12 | #include "luaincl.h" |
---|
13 | |
---|
14 | |
---|
15 | |
---|
16 | template<typename type> type fromLua(lua_state* state) { PRINTF(1)("NOT IMPLEMENTED\n"); }; |
---|
17 | template<> bool fromLua<bool>(lua_state* state); |
---|
18 | template<> int fromLua<int>(lua_state* state); |
---|
19 | template<> unsigned int fromLua<unsigned int>(lua_state* state); |
---|
20 | template<> float fromLua<float>(lua_state* state); |
---|
21 | template<> char fromLua<char>(lua_state* state); |
---|
22 | template<> const std::string& fromLua<const std::string&>(lua_state* state); |
---|
23 | |
---|
24 | // FORWARD DECLARATION |
---|
25 | |
---|
26 | |
---|
27 | /////////// |
---|
28 | //// 0 //// |
---|
29 | /////////// |
---|
30 | //! Executes a Function with a lua_state* parameter. |
---|
31 | template<class T> class ExecutorLua0 : public Executor |
---|
32 | { |
---|
33 | public: |
---|
34 | /** |
---|
35 | * @brief Constructor of a ExecutorXML |
---|
36 | * @param function a Function to call |
---|
37 | */ |
---|
38 | ExecutorLua0(void(T::*function)()) |
---|
39 | : Executor() |
---|
40 | { |
---|
41 | this->functionPointer = function; |
---|
42 | this->functorType = Executor_Objective | Executor_NoLoadString; |
---|
43 | } |
---|
44 | |
---|
45 | /** |
---|
46 | * @brief executes the Command on BaseObject |
---|
47 | * @param object the BaseObject to execute this Executor on |
---|
48 | * @param loadString ignored in this case |
---|
49 | */ |
---|
50 | virtual void operator()(BaseObject* object, const SubString& = SubString()) const |
---|
51 | { |
---|
52 | PRINTF(1)("no usefull executor\n"); |
---|
53 | } |
---|
54 | |
---|
55 | virtual void operator()(BaseObject* object, unsigned int count, void* values) const |
---|
56 | { |
---|
57 | (dynamic_cast<T*>(object)->*(functionPointer))(); |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | * @returns a _new_ Copy of this Executor |
---|
62 | */ |
---|
63 | virtual Executor* clone () const |
---|
64 | { |
---|
65 | return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); |
---|
66 | } |
---|
67 | }; |
---|
68 | |
---|
69 | |
---|
70 | |
---|
71 | /////////// |
---|
72 | //// 1 //// |
---|
73 | /////////// |
---|
74 | //! Executes a Function with a lua_state* parameter. |
---|
75 | template<class T, typename type0> class ExecutorLua1 : public Executor |
---|
76 | { |
---|
77 | public: |
---|
78 | /** |
---|
79 | * @brief Constructor of a ExecutorXML |
---|
80 | * @param function a Function to call |
---|
81 | */ |
---|
82 | ExecutorLua0(void(T::*function)(type0)) |
---|
83 | : Executor(ExecutorParamType<type0>()) |
---|
84 | { |
---|
85 | this->functionPointer = function; |
---|
86 | this->functorType = Executor_Objective | Executor_NoLoadString; |
---|
87 | } |
---|
88 | |
---|
89 | /** |
---|
90 | * @brief executes the Command on BaseObject |
---|
91 | * @param object the BaseObject to execute this Executor on |
---|
92 | * @param loadString ignored in this case |
---|
93 | */ |
---|
94 | virtual void operator()(BaseObject* object, const SubString& = SubString()) const |
---|
95 | { |
---|
96 | PRINTF(1)("no usefull executor\n"); |
---|
97 | } |
---|
98 | |
---|
99 | virtual void operator()(BaseObject* object, unsigned int count, void* values) const |
---|
100 | { |
---|
101 | lua_state* state = (lua_state*)values; |
---|
102 | type0 value0 = lua_pop values |
---|
103 | |
---|
104 | (dynamic_cast<T*>(object)->*(functionPointer))(); |
---|
105 | } |
---|
106 | |
---|
107 | /** |
---|
108 | * @returns a _new_ Copy of this Executor |
---|
109 | */ |
---|
110 | virtual Executor* clone () const |
---|
111 | { |
---|
112 | return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); |
---|
113 | } |
---|
114 | }; |
---|
115 | |
---|
116 | |
---|
117 | #endif /* _EXECUTOR_SPECIALS_H */ |
---|