Changeset 9736 in orxonox.OLD for branches/new_class_id/src/lib/util
- Timestamp:
- Sep 16, 2006, 12:25:40 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/util
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/executor/executor_functional.h
r9735 r9736 54 54 55 55 /** 56 * @brief this is a Template Class used as an evaluater. 57 * 58 * Trait to determine a default Value for any Type, 59 * and to define the Convertible, and how it is transformed into the 60 * corresponding SubTypes over the operator(). 61 * 62 * This Class must be reimplemented for each Convertible and all of its 63 * conversion-members. 64 * 65 * e.g: Convertible SubSting, that splits up into many Stings 66 * conversion-members: (int) can be transformed from a String. 67 */ 68 template<typename FromType> class ExecutorEvaluater 69 { 70 public: 71 /** @brief Executes the Evaluater 72 * @param CallValue the Value that should be converted 73 * @param defaults the default Values. 74 */ 75 template <typename ToType, int index> 76 ToType operator()(FromType& CallValue, const MultiType* const defaults) 77 { 78 return defaultValue; /*(CallValue.size() > index) ? 79 fromString<ToType>(CallValue[index], getDefault<ToType>(defaults, index)) : 80 fromMulti<ToType>(defaults[index]); */ 81 } 82 static FromType& defaultValue() { return FromType(); }; 83 }; 84 85 /** 56 86 * @brief to remove writing errors, this function is Used. 57 87 * @param sub The SubString to use 58 88 * @param default The default Values. 59 89 */ 60 template< typename FromType, typename ToType, int index> class ExecutorEvaluater61 { 62 public: 63 /** @brief Executes the Evaluat or90 template<> class ExecutorEvaluater <const SubString> 91 { 92 public: 93 /** @brief Executes the Evaluater 64 94 * @param CallValue the Value that should be converted 65 95 * @param defaults the default Values. 66 96 */ 67 ToType operator()(FromType& CallValue, const MultiType* const defaults) 97 template <typename ToType, int index> 98 ToType operator()(const SubString& CallValue, const MultiType* const defaults) 68 99 { 69 100 return (CallValue.size() > index) ? … … 71 102 fromMulti<ToType>(defaults[index]); 72 103 } 73 }; 104 static const SubString& defaultValue() { return SubString::NullSubString; }; 105 }; 106 107 108 74 109 75 110 #endif /* __EXECUTOR_FUNCTIONAL_H_ */ … … 137 172 /////////// 138 173 //! @brief ExecutorClass, that can execute Functions without any parameters. 139 template<class T, typename CallType, template<typename , typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>174 template<class T, typename CallType, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 140 175 class __EXECUTOR_FUNCTIONAL_NAME(0) :public Executor<CallType, BaseClass> 141 176 { … … 160 195 * @param sub the SubString to get the Parameters from. 161 196 */ 162 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const197 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 163 198 { 164 199 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); … … 183 218 /////////// 184 219 //! @brief ExecutorClass, that can execute Functions with one parameter. 185 template<class T, typename CallType, typename type0, template<typename , typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>220 template<class T, typename CallType, typename type0, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 186 221 class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor<CallType, BaseClass> 187 222 { … … 206 241 * @param sub the SubString to get the Parameters from. 207 242 */ 208 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const243 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 209 244 { 210 245 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 211 Evaluater<CallType , type0, 0>()(sub, this->defaultValue));246 Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue)); 212 247 }; 213 248 … … 230 265 /////////// 231 266 //! @brief ExecutorClass, that can execute Functions with two parameters. 232 template<class T, typename CallType, typename type0, typename type1, template<typename , typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>267 template<class T, typename CallType, typename type0, typename type1, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 233 268 class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor<CallType, BaseClass> 234 269 { … … 243 278 */ 244 279 __EXECUTOR_FUNCTIONAL_NAME(2) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) 245 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)280 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) 246 281 { 247 282 this->functionPointer = functionPointer; … … 253 288 * @param sub the SubString to get the Parameters from. 254 289 */ 255 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const290 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 256 291 { 257 292 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 258 Evaluater<CallType , type0, 0>()(sub, this->defaultValue),259 Evaluater<CallType , type1, 1>()(sub, this->defaultValue));293 Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue), 294 Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue)); 260 295 }; 261 296 … … 278 313 /////////// 279 314 //! @brief ExecutorClass, that can execute Functions with three parameters. 280 template<class T, typename CallType, typename type0, typename type1, typename type2, template<typename , typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>315 template<class T, typename CallType, typename type0, typename type1, typename type2, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 281 316 class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor<CallType, BaseClass> 282 317 { … … 291 326 */ 292 327 __EXECUTOR_FUNCTIONAL_NAME(3) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) 293 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)328 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) 294 329 { 295 330 this->functionPointer = functionPointer; … … 301 336 * @param sub the SubString to get the Parameters from. 302 337 */ 303 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const338 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 304 339 { 305 340 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 306 Evaluater<CallType , type0, 0>()(sub, this->defaultValue),307 Evaluater<CallType , type1, 1>()(sub, this->defaultValue),308 Evaluater<CallType , type2, 2>()(sub, this->defaultValue));341 Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue), 342 Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue), 343 Evaluater<CallType>().template operator()<type2, 2>(sub, this->defaultValue)); 309 344 }; 310 345 … … 327 362 /////////// 328 363 //! @brief ExecutorClass, that can execute Functions with four parameters. 329 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, template<typename , typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>364 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 330 365 class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor<CallType, BaseClass> 331 366 { … … 340 375 */ 341 376 __EXECUTOR_FUNCTIONAL_NAME(4) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) 342 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)377 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) 343 378 { 344 379 this->functionPointer = functionPointer; … … 350 385 * @param sub the SubString to get the Parameters from. 351 386 */ 352 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const387 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 353 388 { 354 389 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 355 Evaluater<CallType , type0, 0>()(sub, this->defaultValue),356 Evaluater<CallType , type1, 1>()(sub, this->defaultValue),357 Evaluater<CallType , type2, 2>()(sub, this->defaultValue),358 Evaluater<CallType , type3, 3>()(sub, this->defaultValue));390 Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue), 391 Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue), 392 Evaluater<CallType>().template operator()<type2, 2>(sub, this->defaultValue), 393 Evaluater<CallType>().template operator()<type3, 3>(sub, this->defaultValue)); 359 394 }; 360 395 … … 378 413 /////////// 379 414 //! @brief ExecutorClass, that can execute Functions with five parameters. 380 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, typename type4, template<typename , typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>415 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, typename type4, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 381 416 class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor<CallType, BaseClass> 382 417 { … … 391 426 */ 392 427 __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) 393 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)428 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) 394 429 { 395 430 this->functionPointer = functionPointer; … … 401 436 * @param sub the SubString to get the Parameters from. 402 437 */ 403 virtual void operator()(BaseObject* object, CallType& sub = SubString()) const438 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 404 439 { 405 440 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 406 Evaluater<CallType , type0, 0>()(sub, this->defaultValue),407 Evaluater<CallType , type1, 1>()(sub, this->defaultValue),408 Evaluater<CallType , type2, 2>()(sub, this->defaultValue),409 Evaluater<CallType , type3, 3>()(sub, this->defaultValue),410 Evaluater<CallType , type4, 4>()(sub, this->defaultValue));441 Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue), 442 Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue), 443 Evaluater<CallType>().template operator()<type2, 2>(sub, this->defaultValue), 444 Evaluater<CallType>().template operator()<type3, 3>(sub, this->defaultValue), 445 Evaluater<CallType>().template operator()<type4, 4>(sub, this->defaultValue)); 411 446 }; 412 447 -
branches/new_class_id/src/lib/util/substring.cc
r9406 r9736 109 109 /** @brief Helper that gets you a String consisting of all WhiteSpaces and the Comma */ 110 110 const std::string SubString::WhiteSpacesWithComma = " \n\t,"; 111 /** An Empty SubString */ 112 const SubString SubString::NullSubString = SubString(); 111 113 112 114 /** -
branches/new_class_id/src/lib/util/substring.h
r9406 r9736 110 110 static const std::string WhiteSpaces; 111 111 static const std::string WhiteSpacesWithComma; 112 static const SubString NullSubString; 112 113 113 114 private:
Note: See TracChangeset
for help on using the changeset viewer.