Changeset 9742 in orxonox.OLD for branches/new_class_id/src/lib/util/executor/executor_generic.h
- Timestamp:
- Sep 16, 2006, 2:00:13 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/executor/executor_generic.h
r9740 r9742 26 26 27 27 #include "executor.h" 28 #include "substring.h"29 30 31 template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };32 template<> bool fromString<bool>(const std::string& input, bool defaultValue);33 template<> int fromString<int>(const std::string& input, int defaultValue);34 template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue);35 template<> float fromString<float>(const std::string& input, float defaultValue);36 template<> char fromString<char>(const std::string& input, char defaultValue);37 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue);38 39 template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ };40 template<> bool fromMulti<bool>(const MultiType& multi);41 template<> int fromMulti<int>(const MultiType& multi);42 template<> unsigned int fromMulti<unsigned int>(const MultiType& multi);43 template<> float fromMulti<float>(const MultiType& multi);44 template<> char fromMulti<char>(const MultiType& multi);45 template<> const std::string& fromMulti<const std::string&>(const MultiType& multi);46 47 48 template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; };49 template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i);50 template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i);51 template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i);52 template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i);53 template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i);54 template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i);55 56 57 28 /** 58 29 * @brief this is a Template Class used as an evaluater. … … 78 49 ToType operator()(FromType& CallValue, const MultiType* const defaults) 79 50 { 80 return defaultValue; /*(CallValue.size() > index) ? 81 fromString<ToType>(CallValue[index], getDefault<ToType>(defaults, index)) : 82 fromMulti<ToType>(defaults[index]); */ 51 return defaultValue; 83 52 } 84 static FromType& defaultValue() { return FromType(); }; 85 }; 86 87 /** 88 * @brief to remove writing errors, this function is Used. 89 * @param sub The SubString to use 90 * @param default The default Values. 91 */ 92 template<> class ExecutorEvaluater <const SubString> 93 { 94 public: 95 /** @brief Executes the Evaluater 96 * @param CallValue the Value that should be converted 97 * @param defaults the default Values. 98 */ 99 template <typename ToType, int index> 100 ToType operator()(const SubString& CallValue, const MultiType* const defaults) 101 { 102 return (CallValue.size() > index) ? 103 fromString<ToType>(CallValue[index], getDefault<ToType>(defaults, index)) : 104 fromMulti<ToType>(defaults[index]); 105 } 106 static const SubString& defaultValue() { return SubString::NullSubString; }; 107 }; 108 53 static FromType& defaultValue() { static FromType defaultValue; return defaultValue; }; 54 }; 109 55 #endif /* __EXECUTOR_GENERIC_H_ */ 110 56 57 #ifdef __EXECUTOR_FUNCTIONAL_NAME 111 58 112 59 /////////// … … 135 82 * @brief executes the Functional 136 83 * @param object the Object the action should be executed on. 137 * @param sub the SubStringto get the Parameters from.138 */ 139 virtual void operator()(BaseObject* object, CallType& sub= Evaluater<CallType>::defaultValue()) const84 * @param eval the CallType to get the Parameters from. 85 */ 86 virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const 140 87 { 141 88 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); … … 181 128 * @brief executes the Functional 182 129 * @param object the Object the action should be executed on. 183 * @param sub the SubStringto get the Parameters from.184 */ 185 virtual void operator()(BaseObject* object, CallType& sub= Evaluater<CallType>::defaultValue()) const186 { 187 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 188 Evaluater<CallType>().template operator()<type0, 0>( sub, this->defaultValue));130 * @param eval the CallType to get the Parameters from. 131 */ 132 virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const 133 { 134 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 135 Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue)); 189 136 }; 190 137 … … 228 175 * @brief executes the Functional 229 176 * @param object the Object the action should be executed on. 230 * @param sub the SubStringto get the Parameters from.231 */ 232 virtual void operator()(BaseObject* object, CallType& sub= Evaluater<CallType>::defaultValue()) const233 { 234 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 235 Evaluater<CallType>().template operator()<type0, 0>( sub, this->defaultValue),236 Evaluater<CallType>().template operator()<type1, 1>( sub, this->defaultValue));177 * @param eval the CallType to get the Parameters from. 178 */ 179 virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const 180 { 181 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 182 Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue), 183 Evaluater<CallType>().template operator()<type1, 1>(eval, this->defaultValue)); 237 184 }; 238 185 … … 276 223 * @brief executes the Functional 277 224 * @param object the Object the action should be executed on. 278 * @param sub the SubStringto get the Parameters from.279 */ 280 virtual void operator()(BaseObject* object, CallType& sub= Evaluater<CallType>::defaultValue()) const281 { 282 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 283 Evaluater<CallType>().template operator()<type0, 0>( sub, this->defaultValue),284 Evaluater<CallType>().template operator()<type1, 1>( sub, this->defaultValue),285 Evaluater<CallType>().template operator()<type2, 2>( sub, this->defaultValue));225 * @param eval the CallType to get the Parameters from. 226 */ 227 virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const 228 { 229 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 230 Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue), 231 Evaluater<CallType>().template operator()<type1, 1>(eval, this->defaultValue), 232 Evaluater<CallType>().template operator()<type2, 2>(eval, this->defaultValue)); 286 233 }; 287 234 … … 325 272 * @brief executes the Functional 326 273 * @param object the Object the action should be executed on. 327 * @param sub the SubStringto get the Parameters from.328 */ 329 virtual void operator()(BaseObject* object, CallType& sub= Evaluater<CallType>::defaultValue()) const330 { 331 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 332 Evaluater<CallType>().template operator()<type0, 0>( sub, this->defaultValue),333 Evaluater<CallType>().template operator()<type1, 1>( sub, this->defaultValue),334 Evaluater<CallType>().template operator()<type2, 2>( sub, this->defaultValue),335 Evaluater<CallType>().template operator()<type3, 3>( sub, this->defaultValue));274 * @param eval the CallType to get the Parameters from. 275 */ 276 virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const 277 { 278 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 279 Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue), 280 Evaluater<CallType>().template operator()<type1, 1>(eval, this->defaultValue), 281 Evaluater<CallType>().template operator()<type2, 2>(eval, this->defaultValue), 282 Evaluater<CallType>().template operator()<type3, 3>(eval, this->defaultValue)); 336 283 }; 337 284 … … 376 323 * @brief executes the Functional 377 324 * @param object the Object the action should be executed on. 378 * @param sub the SubStringto get the Parameters from.379 */ 380 virtual void operator()(BaseObject* object, CallType& sub= Evaluater<CallType>::defaultValue()) const381 { 382 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 383 Evaluater<CallType>().template operator()<type0, 0>( sub, this->defaultValue),384 Evaluater<CallType>().template operator()<type1, 1>( sub, this->defaultValue),385 Evaluater<CallType>().template operator()<type2, 2>( sub, this->defaultValue),386 Evaluater<CallType>().template operator()<type3, 3>( sub, this->defaultValue),387 Evaluater<CallType>().template operator()<type4, 4>( sub, this->defaultValue));325 * @param eval the CallType to get the Parameters from. 326 */ 327 virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const 328 { 329 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 330 Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue), 331 Evaluater<CallType>().template operator()<type1, 1>(eval, this->defaultValue), 332 Evaluater<CallType>().template operator()<type2, 2>(eval, this->defaultValue), 333 Evaluater<CallType>().template operator()<type3, 3>(eval, this->defaultValue), 334 Evaluater<CallType>().template operator()<type4, 4>(eval, this->defaultValue)); 388 335 }; 389 336 … … 398 345 }; 399 346 400 //#endif /* __EXECUTOR_GENERIC_H_*/347 #endif /* __EXECUTOR_FUNCTIONAL_NAME */
Note: See TracChangeset
for help on using the changeset viewer.