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