- Timestamp:
- Sep 15, 2006, 12:52:54 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/executor/executor_functional.h
r9730 r9731 58 58 * @param default The default Values. 59 59 */ 60 template<typename type, int index> type Evaluate(const SubString& sub, const MultiType* const defaults) 61 { 62 return (sub.size() > index) ? 63 fromString<type>(sub[index], getDefault<type>(defaults, index)) : 64 fromMulti<type>(defaults[index]); 65 }; 66 60 template<typename FromType, typename ToType, int index> class ExecutorEvaluater 61 { 62 public: 63 ToType operator()(FromType& sub, const MultiType* const defaults) 64 { 65 return (sub.size() > index) ? 66 fromString<ToType>(sub[index], getDefault<ToType>(defaults, index)) : 67 fromMulti<ToType>(defaults[index]); 68 } 69 }; 67 70 68 71 #endif /* __EXECUTOR_FUNCTIONAL_H_ */ … … 77 80 #define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER T::*functionPointer 78 81 79 #ifdef EXECUTOR_FUNCTIONAL_USE_CONST 80 #ifdef __EXECUTOR_FUNCTIONAL_CONST_INCLUDED 82 #ifdef EXECUTOR_FUNCTIONAL_USE_CONST //! USING CONST FUNCTIONALS 83 #ifdef __EXECUTOR_FUNCTIONAL_CONST_INCLUDED //!< CHECK IF ALREADY INCLUED CONST FUNCTIONALS 81 84 #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS 82 85 #else … … 122 125 /////////// 123 126 //! @brief ExecutorClass, that can execute Functions without any parameters. 124 template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor<const SubString> 127 template<class T, typename CallType, template<typename, typename, int> class Evaluater = ExecutorEvaluater> 128 class __EXECUTOR_FUNCTIONAL_NAME(0) :public Executor<CallType> 125 129 { 126 130 private: … … 134 138 */ 135 139 __EXECUTOR_FUNCTIONAL_NAME(0) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST ) 136 : Executor< const SubString>(false)140 : Executor<CallType>(false) 137 141 { 138 142 this->functorType = Executor_Objective; … … 145 149 * @param sub the SubString to get the Parameters from. 146 150 */ 147 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const151 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const 148 152 { 149 153 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); … … 154 158 * @returns a new Executor that's a copy of this one. 155 159 */ 156 virtual Executor< const SubString>* clone() const157 { 158 return new __EXECUTOR_FUNCTIONAL_NAME(0)<T >(this->functionPointer);160 virtual Executor<CallType>* clone() const 161 { 162 return new __EXECUTOR_FUNCTIONAL_NAME(0)<T, CallType>(this->functionPointer); 159 163 }; 160 164 }; … … 166 170 /////////// 167 171 //! @brief ExecutorClass, that can execute Functions with one parameter. 168 template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor<const SubString> 172 template<class T, typename CallType, typename type0, template<typename, typename, int> class Evaluater = ExecutorEvaluater> 173 class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor<CallType> 169 174 { 170 175 private: … … 178 183 */ 179 184 __EXECUTOR_FUNCTIONAL_NAME(1) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) 180 : Executor< const SubString>(false, ExecutorParamType<type0>())185 : Executor<CallType>(false, ExecutorParamType<type0>()) 181 186 { 182 187 this->functorType = Executor_Objective; … … 189 194 * @param sub the SubString to get the Parameters from. 190 195 */ 191 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const196 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const 192 197 { 193 198 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 194 Evaluate <type0, 0>(sub, this->defaultValue));199 Evaluater<CallType, type0, 0>()(sub, this->defaultValue)); 195 200 }; 196 201 … … 199 204 * @returns a new Executor that's a copy of this one. 200 205 */ 201 virtual Executor< const SubString>* clone() const202 { 203 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0>(this->functionPointer);206 virtual Executor<CallType>* clone() const 207 { 208 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, CallType, type0>(this->functionPointer); 204 209 }; 205 210 }; … … 209 214 /////////// 210 215 //! @brief ExecutorClass, that can execute Functions with two parameters. 211 template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor<const SubString> 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> 212 218 { 213 219 private: … … 221 227 */ 222 228 __EXECUTOR_FUNCTIONAL_NAME(2) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) 223 : Executor< const SubString>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>())229 : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>()) 224 230 { 225 231 this->functorType = Executor_Objective; … … 232 238 * @param sub the SubString to get the Parameters from. 233 239 */ 234 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const240 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const 235 241 { 236 242 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 237 Evaluate <type0, 0>(sub, this->defaultValue),238 Evaluate <type1, 1>(sub, this->defaultValue));243 Evaluater<CallType, type0, 0>()(sub, this->defaultValue), 244 Evaluater<CallType, type1, 1>()(sub, this->defaultValue)); 239 245 }; 240 246 … … 243 249 * @returns a new Executor that's a copy of this one. 244 250 */ 245 virtual Executor< const SubString>* clone() const246 { 247 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0, type1>(this->functionPointer);251 virtual Executor<CallType>* clone() const 252 { 253 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, CallType, type0, type1>(this->functionPointer); 248 254 }; 249 255 }; … … 254 260 /////////// 255 261 //! @brief ExecutorClass, that can execute Functions with three parameters. 256 template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor<const SubString> 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> 257 264 { 258 265 private: … … 266 273 */ 267 274 __EXECUTOR_FUNCTIONAL_NAME(3) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) 268 : Executor< const SubString>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>())275 : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) 269 276 { 270 277 this->functorType = Executor_Objective; … … 277 284 * @param sub the SubString to get the Parameters from. 278 285 */ 279 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const286 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const 280 287 { 281 288 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 282 Evaluate <type0, 0>(sub, this->defaultValue),283 Evaluate <type1, 1>(sub, this->defaultValue),284 Evaluate <type2, 2>(sub, this->defaultValue));289 Evaluater<CallType, type0, 0>()(sub, this->defaultValue), 290 Evaluater<CallType, type1, 1>()(sub, this->defaultValue), 291 Evaluater<CallType, type2, 2>()(sub, this->defaultValue)); 285 292 }; 286 293 … … 289 296 * @returns a new Executor that's a copy of this one. 290 297 */ 291 virtual Executor< const SubString>* clone() const292 { 293 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0, type1, type2>(this->functionPointer);298 virtual Executor<CallType>* clone() const 299 { 300 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, CallType, type0, type1, type2>(this->functionPointer); 294 301 }; 295 302 }; … … 301 308 /////////// 302 309 //! @brief ExecutorClass, that can execute Functions with four parameters. 303 template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor<const SubString> 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> 304 312 { 305 313 private: … … 313 321 */ 314 322 __EXECUTOR_FUNCTIONAL_NAME(4) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) 315 : Executor< const SubString>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())323 : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) 316 324 { 317 325 this->functorType = Executor_Objective; … … 324 332 * @param sub the SubString to get the Parameters from. 325 333 */ 326 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const334 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const 327 335 { 328 336 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 329 Evaluate <type0, 0>(sub, this->defaultValue),330 Evaluate <type1, 1>(sub, this->defaultValue),331 Evaluate <type2, 2>(sub, this->defaultValue),332 Evaluate <type3, 3>(sub, this->defaultValue));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)); 333 341 }; 334 342 … … 337 345 * @returns a new Executor that's a copy of this one. 338 346 */ 339 virtual Executor< const SubString>* clone() const340 { 341 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0, type1, type2, type3>(this->functionPointer);347 virtual Executor<CallType>* clone() const 348 { 349 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, CallType, type0, type1, type2, type3>(this->functionPointer); 342 350 }; 343 351 }; … … 349 357 /////////// 350 358 //! @brief ExecutorClass, that can execute Functions with five parameters. 351 template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor<const SubString> 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> 352 361 { 353 362 private: … … 361 370 */ 362 371 __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) 363 : Executor< const SubString>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>())372 : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>()) 364 373 { 365 374 this->functorType = Executor_Objective; … … 372 381 * @param sub the SubString to get the Parameters from. 373 382 */ 374 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const383 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const 375 384 { 376 385 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 377 Evaluate <type0, 0>(sub, this->defaultValue),378 Evaluate <type1, 1>(sub, this->defaultValue),379 Evaluate <type2, 2>(sub, this->defaultValue),380 Evaluate <type3, 3>(sub, this->defaultValue),381 Evaluate <type4, 4>(sub, this->defaultValue));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)); 382 391 }; 383 392 … … 386 395 * @returns a new Executor that's a copy of this one. 387 396 */ 388 virtual Executor<const SubString>* clone() const 389 { 390 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0, type1, type2, type3, type4>(this->functionPointer); 391 }; 392 }; 393 394 395 397 virtual Executor<CallType>* clone() const 398 { 399 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, CallType, type0, type1, type2, type3, type4>(this->functionPointer); 400 }; 401 }; 402 403 404 405 406 407 408 409 410 411 // // // // // // // // // // // // // 412 //// EXTENSION TO HIDE CONSTRUCT ///// 413 // // // // // // // // // // // // // 396 414 /** 397 415 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) … … 400 418 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \ 401 419 { \ 402 return new __EXECUTOR_FUNCTIONAL_NAME(0)<T >(functionPointer); \420 return new __EXECUTOR_FUNCTIONAL_NAME(0)<T, const SubString>(functionPointer); \ 403 421 } 404 422 … … 410 428 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 411 429 { \ 412 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0##_TYPE>(functionPointer); \430 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, const SubString, type0##_TYPE>(functionPointer); \ 413 431 } 414 432 … … 421 439 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 422 440 { \ 423 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0##_TYPE, type1##_TYPE>(functionPointer); \441 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, const SubString, type0##_TYPE, type1##_TYPE>(functionPointer); \ 424 442 } 425 443 … … 433 451 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 434 452 { \ 435 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \453 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, const SubString, type0##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \ 436 454 } 437 455 … … 446 464 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 447 465 { \ 448 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \466 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, const SubString, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \ 449 467 } 450 468 … … 460 478 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 461 479 { \ 462 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \480 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, const SubString, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \ 463 481 } 464 482
Note: See TracChangeset
for help on using the changeset viewer.