1 | /*! |
---|
2 | * @file executor_functional.h |
---|
3 | * Definition of an Executor |
---|
4 | */ |
---|
5 | |
---|
6 | /* |
---|
7 | orxonox - the future of 3D-vertical-scrollers |
---|
8 | |
---|
9 | Copyright (C) 2004 orx |
---|
10 | |
---|
11 | This program is free software; you can redistribute it and/or modify |
---|
12 | it under the terms of the GNU General Public License as published by |
---|
13 | the Free Software Foundation; either version 2, or (at your option) |
---|
14 | any later version. |
---|
15 | |
---|
16 | ### File Specific: |
---|
17 | main-programmer: Benjamin Grauer |
---|
18 | co-programmer: ... |
---|
19 | */ |
---|
20 | |
---|
21 | |
---|
22 | #ifndef __EXECUTOR_FUNCTIONAL_H_ |
---|
23 | #define __EXECUTOR_FUNCTIONAL_H_ |
---|
24 | |
---|
25 | #include "executor.h" |
---|
26 | |
---|
27 | template<typename type> MT_Type ExecutorParamType() { return MT_EXT1; }; |
---|
28 | template<> MT_Type ExecutorParamType<bool>(); |
---|
29 | template<> MT_Type ExecutorParamType<int>(); |
---|
30 | template<> MT_Type ExecutorParamType<unsigned int>(); |
---|
31 | template<> MT_Type ExecutorParamType<float>(); |
---|
32 | template<> MT_Type ExecutorParamType<char>(); |
---|
33 | template<> MT_Type ExecutorParamType<const std::string&>(); |
---|
34 | |
---|
35 | template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; }; |
---|
36 | template<> bool fromString<bool>(const std::string& input, bool defaultValue); |
---|
37 | template<> int fromString<int>(const std::string& input, int defaultValue); |
---|
38 | template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue); |
---|
39 | template<> float fromString<float>(const std::string& input, float defaultValue); |
---|
40 | template<> char fromString<char>(const std::string& input, char defaultValue); |
---|
41 | template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue); |
---|
42 | |
---|
43 | template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ }; |
---|
44 | template<> bool fromMulti<bool>(const MultiType& multi); |
---|
45 | template<> int fromMulti<int>(const MultiType& multi); |
---|
46 | template<> unsigned int fromMulti<unsigned int>(const MultiType& multi); |
---|
47 | template<> float fromMulti<float>(const MultiType& multi); |
---|
48 | template<> char fromMulti<char>(const MultiType& multi); |
---|
49 | template<> const std::string& fromMulti<const std::string&>(const MultiType& multi); |
---|
50 | |
---|
51 | |
---|
52 | template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; }; |
---|
53 | template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i); |
---|
54 | template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i); |
---|
55 | template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i); |
---|
56 | template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i); |
---|
57 | template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i); |
---|
58 | template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i); |
---|
59 | |
---|
60 | #endif /* __EXECUTOR_FUNCTIONAL_H_ */ |
---|
61 | |
---|
62 | //! if Functional is constant calling |
---|
63 | #define __EXECUTOR_FUNCTIONAL_CONST |
---|
64 | //! The Name to be attached to the functional (for normal, static, and const modes) |
---|
65 | #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount) Executor##ParamCount##Params |
---|
66 | //! The Execution-mode (either static or objective) |
---|
67 | #define __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC dynamic_cast<T*>(object)->*(functionPointer) |
---|
68 | //! The Function-Pointer, and how to save it internally. |
---|
69 | #define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER T::*functionPointer |
---|
70 | |
---|
71 | #ifdef EXECUTOR_FUNCTIONAL_USE_CONST |
---|
72 | #undef __EXECUTOR_FUNCTIONAL_CONST |
---|
73 | #define __EXECUTOR_FUNCTIONAL_CONST const |
---|
74 | #undef __EXECUTOR_FUNCTIONAL_NAME |
---|
75 | #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount) Executor##ParamCount##Params_const |
---|
76 | #endif |
---|
77 | |
---|
78 | #ifdef EXECUTOR_FUNCTIONAL_USE_STATIC |
---|
79 | #ifdef EXECUTOR_FUNCTIONAL_USE_CONST |
---|
80 | #error you obviously do not know what you are doing !! ask the bensch |
---|
81 | #endif /* EXECUTOR_FUNCTIONAL_USE_CONST */ |
---|
82 | |
---|
83 | #undef __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC |
---|
84 | #define __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC functionPointer |
---|
85 | #undef __EXECUTOR_FUNCTIONAL_NAME |
---|
86 | #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount) Executor##ParamCount##Params_static |
---|
87 | #undef __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER |
---|
88 | #define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER *functionPointer |
---|
89 | |
---|
90 | #endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */ |
---|
91 | |
---|
92 | /////////// |
---|
93 | //// 0 //// |
---|
94 | /////////// |
---|
95 | //! @brief ExecutorClass, that can execute Functions without any parameters. |
---|
96 | template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor |
---|
97 | { |
---|
98 | private: |
---|
99 | /** @brief the FunctioPointer. */ |
---|
100 | void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST; |
---|
101 | |
---|
102 | public: |
---|
103 | /** |
---|
104 | * @brief constructs the Executor. |
---|
105 | * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. |
---|
106 | */ |
---|
107 | __EXECUTOR_FUNCTIONAL_NAME(0) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST ) |
---|
108 | : Executor() |
---|
109 | { |
---|
110 | this->functorType = Executor_Objective; |
---|
111 | this->functionPointer = functionPointer; |
---|
112 | }; |
---|
113 | |
---|
114 | /** |
---|
115 | * @brief executes the Functional |
---|
116 | * @param object the Object the action should be executed on. |
---|
117 | * @param sub the SubString to get the Parameters from. |
---|
118 | */ |
---|
119 | virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const |
---|
120 | { |
---|
121 | (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); |
---|
122 | }; |
---|
123 | |
---|
124 | /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ |
---|
125 | virtual void operator()(BaseObject* object, int& count, void* values) const |
---|
126 | { |
---|
127 | (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); |
---|
128 | } |
---|
129 | |
---|
130 | /** |
---|
131 | * @brief copies the Executor |
---|
132 | * @returns a new Executor that's a copy of this one. |
---|
133 | */ |
---|
134 | virtual Executor* clone() const |
---|
135 | { |
---|
136 | return new __EXECUTOR_FUNCTIONAL_NAME(0)<T>(this->functionPointer); |
---|
137 | }; |
---|
138 | }; |
---|
139 | |
---|
140 | |
---|
141 | |
---|
142 | /////////// |
---|
143 | //// 1 //// |
---|
144 | /////////// |
---|
145 | //! @brief ExecutorClass, that can execute Functions with one parameter. |
---|
146 | template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor |
---|
147 | { |
---|
148 | private: |
---|
149 | /** @brief the FunctioPointer. */ |
---|
150 | void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST; |
---|
151 | |
---|
152 | public: |
---|
153 | /** |
---|
154 | * @brief constructs the Executor. |
---|
155 | * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. |
---|
156 | */ |
---|
157 | __EXECUTOR_FUNCTIONAL_NAME(1) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) |
---|
158 | : Executor(ExecutorParamType<type0>()) |
---|
159 | { |
---|
160 | this->functorType = Executor_Objective; |
---|
161 | this->functionPointer = functionPointer; |
---|
162 | }; |
---|
163 | |
---|
164 | /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ |
---|
165 | virtual void operator()(BaseObject* object, int& count, void* values) const |
---|
166 | { |
---|
167 | const MultiType* mt = (const MultiType*)values; |
---|
168 | return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( |
---|
169 | fromMulti<type0>((count > 0)? mt[0] : this->defaultValue[0]) ); |
---|
170 | } |
---|
171 | |
---|
172 | |
---|
173 | /** |
---|
174 | * @brief executes the Functional |
---|
175 | * @param object the Object the action should be executed on. |
---|
176 | * @param sub the SubString to get the Parameters from. |
---|
177 | */ |
---|
178 | virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const |
---|
179 | { |
---|
180 | (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( |
---|
181 | (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0]))); |
---|
182 | }; |
---|
183 | |
---|
184 | /** |
---|
185 | * @brief copies the Executor |
---|
186 | * @returns a new Executor that's a copy of this one. |
---|
187 | */ |
---|
188 | virtual Executor* clone() const |
---|
189 | { |
---|
190 | return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0>(this->functionPointer); |
---|
191 | }; |
---|
192 | }; |
---|
193 | |
---|
194 | /////////// |
---|
195 | //// 2 //// |
---|
196 | /////////// |
---|
197 | //! @brief ExecutorClass, that can execute Functions with two parameters. |
---|
198 | template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor |
---|
199 | { |
---|
200 | private: |
---|
201 | /** @brief the FunctioPointer. */ |
---|
202 | void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST; |
---|
203 | |
---|
204 | public: |
---|
205 | /** |
---|
206 | * @brief constructs the Executor. |
---|
207 | * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. |
---|
208 | */ |
---|
209 | __EXECUTOR_FUNCTIONAL_NAME(2) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) |
---|
210 | : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>()) |
---|
211 | { |
---|
212 | this->functorType = Executor_Objective; |
---|
213 | this->functionPointer = functionPointer; |
---|
214 | }; |
---|
215 | |
---|
216 | /** |
---|
217 | * @brief executes the Functional |
---|
218 | * @param object the Object the action should be executed on. |
---|
219 | * @param sub the SubString to get the Parameters from. |
---|
220 | */ |
---|
221 | virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const |
---|
222 | { |
---|
223 | (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( |
---|
224 | (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])), |
---|
225 | (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1]))); |
---|
226 | }; |
---|
227 | |
---|
228 | /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ |
---|
229 | virtual void operator()(BaseObject* object, int& count, void* values) const |
---|
230 | { |
---|
231 | const MultiType* mt = (const MultiType*)values; |
---|
232 | return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( |
---|
233 | fromMulti<type0>((count > 0) ? mt[0] : this->defaultValue[0]), |
---|
234 | fromMulti<type1>((count > 1) ? mt[1] : this->defaultValue[1]) ); |
---|
235 | } |
---|
236 | |
---|
237 | /** |
---|
238 | * @brief copies the Executor |
---|
239 | * @returns a new Executor that's a copy of this one. |
---|
240 | */ |
---|
241 | virtual Executor* clone() const |
---|
242 | { |
---|
243 | return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0, type1>(this->functionPointer); |
---|
244 | }; |
---|
245 | }; |
---|
246 | |
---|
247 | |
---|
248 | /////////// |
---|
249 | //// 3 //// |
---|
250 | /////////// |
---|
251 | //! @brief ExecutorClass, that can execute Functions with three parameters. |
---|
252 | template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor |
---|
253 | { |
---|
254 | private: |
---|
255 | /** @brief the FunctioPointer. */ |
---|
256 | void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST; |
---|
257 | |
---|
258 | public: |
---|
259 | /** |
---|
260 | * @brief constructs the Executor. |
---|
261 | * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. |
---|
262 | */ |
---|
263 | __EXECUTOR_FUNCTIONAL_NAME(3) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) |
---|
264 | : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) |
---|
265 | { |
---|
266 | this->functorType = Executor_Objective; |
---|
267 | this->functionPointer = functionPointer; |
---|
268 | }; |
---|
269 | |
---|
270 | /** |
---|
271 | * @brief executes the Functional |
---|
272 | * @param object the Object the action should be executed on. |
---|
273 | * @param sub the SubString to get the Parameters from. |
---|
274 | */ |
---|
275 | virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const |
---|
276 | { |
---|
277 | (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( |
---|
278 | (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])), |
---|
279 | (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])), |
---|
280 | (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2]))); |
---|
281 | }; |
---|
282 | |
---|
283 | /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ |
---|
284 | virtual void operator()(BaseObject* object, int& count, void* values) const |
---|
285 | { |
---|
286 | const MultiType* mt = (const MultiType*)values; |
---|
287 | return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( |
---|
288 | fromMulti<type0>((count > 0) ? mt[0] : this->defaultValue[0]), |
---|
289 | fromMulti<type1>((count > 1) ? mt[1] : this->defaultValue[1]), |
---|
290 | fromMulti<type2>((count > 2) ? mt[2] : this->defaultValue[2]) ); |
---|
291 | } |
---|
292 | |
---|
293 | /** |
---|
294 | * @brief copies the Executor |
---|
295 | * @returns a new Executor that's a copy of this one. |
---|
296 | */ |
---|
297 | virtual Executor* clone() const |
---|
298 | { |
---|
299 | return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0, type1, type2>(this->functionPointer); |
---|
300 | }; |
---|
301 | }; |
---|
302 | |
---|
303 | |
---|
304 | |
---|
305 | /////////// |
---|
306 | //// 4 //// |
---|
307 | /////////// |
---|
308 | //! @brief ExecutorClass, that can execute Functions with four parameters. |
---|
309 | template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor |
---|
310 | { |
---|
311 | private: |
---|
312 | /** @brief the FunctioPointer. */ |
---|
313 | void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST; |
---|
314 | |
---|
315 | public: |
---|
316 | /** |
---|
317 | * @brief constructs the Executor. |
---|
318 | * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. |
---|
319 | */ |
---|
320 | __EXECUTOR_FUNCTIONAL_NAME(4) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) |
---|
321 | : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) |
---|
322 | { |
---|
323 | this->functorType = Executor_Objective; |
---|
324 | this->functionPointer = functionPointer; |
---|
325 | }; |
---|
326 | |
---|
327 | /** |
---|
328 | * @brief executes the Functional |
---|
329 | * @param object the Object the action should be executed on. |
---|
330 | * @param sub the SubString to get the Parameters from. |
---|
331 | */ |
---|
332 | virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const |
---|
333 | { |
---|
334 | (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( |
---|
335 | (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])), |
---|
336 | (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])), |
---|
337 | (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])), |
---|
338 | (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3]))); |
---|
339 | }; |
---|
340 | |
---|
341 | /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ |
---|
342 | virtual void operator()(BaseObject* object, int& count, void* values) const |
---|
343 | { |
---|
344 | const MultiType* mt = (const MultiType*)values; |
---|
345 | return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( |
---|
346 | fromMulti<type0>((count > 0) ? mt[0] : this->defaultValue[0]), |
---|
347 | fromMulti<type1>((count > 1) ? mt[1] : this->defaultValue[1]), |
---|
348 | fromMulti<type2>((count > 2) ? mt[2] : this->defaultValue[2]), |
---|
349 | fromMulti<type3>((count > 3) ? mt[3] : this->defaultValue[3]) ); |
---|
350 | } |
---|
351 | |
---|
352 | /** |
---|
353 | * @brief copies the Executor |
---|
354 | * @returns a new Executor that's a copy of this one. |
---|
355 | */ |
---|
356 | virtual Executor* clone() const |
---|
357 | { |
---|
358 | return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0, type1, type2, type3>(this->functionPointer); |
---|
359 | }; |
---|
360 | }; |
---|
361 | |
---|
362 | |
---|
363 | |
---|
364 | /////////// |
---|
365 | //// 5 //// |
---|
366 | /////////// |
---|
367 | //! @brief ExecutorClass, that can execute Functions with five parameters. |
---|
368 | template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor |
---|
369 | { |
---|
370 | private: |
---|
371 | /** @brief the FunctioPointer. */ |
---|
372 | void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST; |
---|
373 | |
---|
374 | public: |
---|
375 | /** |
---|
376 | * @brief constructs the Executor. |
---|
377 | * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. |
---|
378 | */ |
---|
379 | __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) |
---|
380 | : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>()) |
---|
381 | { |
---|
382 | this->functorType = Executor_Objective; |
---|
383 | this->functionPointer = functionPointer; |
---|
384 | }; |
---|
385 | |
---|
386 | /** |
---|
387 | * @brief executes the Functional |
---|
388 | * @param object the Object the action should be executed on. |
---|
389 | * @param sub the SubString to get the Parameters from. |
---|
390 | */ |
---|
391 | virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const |
---|
392 | { |
---|
393 | (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( |
---|
394 | (sub.size() > 0) ? fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) : (fromMulti<type0>(this->defaultValue[0])), |
---|
395 | (sub.size() > 1) ? fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)) : (fromMulti<type1>(this->defaultValue[1])), |
---|
396 | (sub.size() > 2) ? fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)) : (fromMulti<type2>(this->defaultValue[2])), |
---|
397 | (sub.size() > 3) ? fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)) : (fromMulti<type3>(this->defaultValue[3])), |
---|
398 | (sub.size() > 4) ? fromString<type4>(sub[4], getDefault<type4>(this->defaultValue, 4)) : (fromMulti<type4>(this->defaultValue[4]))); |
---|
399 | }; |
---|
400 | |
---|
401 | /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ |
---|
402 | virtual void operator()(BaseObject* object, int& count, void* values) const |
---|
403 | { |
---|
404 | const MultiType* mt = (const MultiType*)values; |
---|
405 | return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( |
---|
406 | fromMulti<type0>((count > 0) ? mt[0] : this->defaultValue[0]), |
---|
407 | fromMulti<type1>((count > 1) ? mt[1] : this->defaultValue[1]), |
---|
408 | fromMulti<type2>((count > 2) ? mt[2] : this->defaultValue[2]), |
---|
409 | fromMulti<type3>((count > 3) ? mt[3] : this->defaultValue[3]), |
---|
410 | fromMulti<type4>((count > 4) ? mt[4] : this->defaultValue[4]) ); |
---|
411 | } |
---|
412 | |
---|
413 | /** |
---|
414 | * @brief copies the Executor |
---|
415 | * @returns a new Executor that's a copy of this one. |
---|
416 | */ |
---|
417 | virtual Executor* clone() const |
---|
418 | { |
---|
419 | return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0, type1, type2, type3, type4>(this->functionPointer); |
---|
420 | }; |
---|
421 | }; |
---|
422 | |
---|
423 | |
---|
424 | |
---|
425 | /** |
---|
426 | * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) |
---|
427 | */ |
---|
428 | #define EXECUTOR_FUNCTIONAL_CREATOR0() \ |
---|
429 | template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \ |
---|
430 | { \ |
---|
431 | return new __EXECUTOR_FUNCTIONAL_NAME(0)<T>(functionPointer); \ |
---|
432 | } |
---|
433 | |
---|
434 | /** |
---|
435 | * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) |
---|
436 | * @param type0 for internal usage: the first Argument |
---|
437 | */ |
---|
438 | #define EXECUTOR_FUNCTIONAL_CREATOR1(type0) \ |
---|
439 | template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ |
---|
440 | { \ |
---|
441 | return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0##_TYPE>(functionPointer); \ |
---|
442 | } |
---|
443 | |
---|
444 | /** |
---|
445 | * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) |
---|
446 | * @param type0 for internal usage: the first Argument |
---|
447 | * @param type1 for internal usage: the second Argument |
---|
448 | */ |
---|
449 | #define EXECUTOR_FUNCTIONAL_CREATOR2(type0, type1) \ |
---|
450 | template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ |
---|
451 | { \ |
---|
452 | return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0##_TYPE, type1##_TYPE>(functionPointer); \ |
---|
453 | } |
---|
454 | |
---|
455 | /** |
---|
456 | * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) |
---|
457 | * @param type0 for internal usage: the first Argument |
---|
458 | * @param type1 for internal usage: the second Argument |
---|
459 | * @param type2 for internal usage: the third Argument |
---|
460 | */ |
---|
461 | #define EXECUTOR_FUNCTIONAL_CREATOR3(type0, type1, type2) \ |
---|
462 | template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ |
---|
463 | { \ |
---|
464 | return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \ |
---|
465 | } |
---|
466 | |
---|
467 | /** |
---|
468 | * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) |
---|
469 | * @param type0 for internal usage: the first Argument |
---|
470 | * @param type1 for internal usage: the second Argument |
---|
471 | * @param type2 for internal usage: the third Argument |
---|
472 | * @param type3 for internal usage: the fourth Argument |
---|
473 | */ |
---|
474 | #define EXECUTOR_FUNCTIONAL_CREATOR4(type0, type1, type2, type3) \ |
---|
475 | template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ |
---|
476 | { \ |
---|
477 | return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \ |
---|
478 | } |
---|
479 | |
---|
480 | /** |
---|
481 | * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) |
---|
482 | * @param type0 for internal usage: the first Argument |
---|
483 | * @param type1 for internal usage: the second Argument |
---|
484 | * @param type2 for internal usage: the third Argument |
---|
485 | * @param type3 for internal usage: the fourth Argument |
---|
486 | * @param type4 for internal usage: the fifth Argument |
---|
487 | */ |
---|
488 | #define EXECUTOR_FUNCTIONAL_CREATOR5(type0, type1, type2, type3, type4) \ |
---|
489 | template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ |
---|
490 | { \ |
---|
491 | return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \ |
---|
492 | } |
---|
493 | |
---|
494 | |
---|
495 | /** |
---|
496 | * Creates the FunctionCallers |
---|
497 | */ |
---|
498 | #define FUNCTOR_LIST(x) EXECUTOR_FUNCTIONAL_CREATOR ## x |
---|
499 | #include "functor_list.h" |
---|
500 | #undef FUNCTOR_LIST |
---|
501 | |
---|
502 | |
---|
503 | |
---|
504 | #undef __EXECUTOR_FUNCTIONAL_CONST |
---|
505 | #undef __EXECUTOR_FUNCTIONAL_NAME |
---|
506 | #undef __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC |
---|
507 | #undef __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER |
---|
508 | |
---|
509 | #ifdef EXECUTOR_FUNCTIONAL_USE_CONST |
---|
510 | #undef EXECUTOR_FUNCTIONAL_USE_CONST |
---|
511 | #endif |
---|
512 | #ifdef EXECUTOR_FUNCTIONAL_USE_STATIC |
---|
513 | #undef EXECUTOR_FUNCTIONAL_USE_STATIC |
---|
514 | #endif |
---|