Changeset 9742 in orxonox.OLD for branches/new_class_id/src/lib/util/executor/executor_substring.h
- Timestamp:
- Sep 16, 2006, 2:00:13 PM (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/executor/executor_substring.h
r9740 r9742 21 21 22 22 23 #ifndef __EXECUTOR_ GENERIC_H_24 #define __EXECUTOR_ GENERIC_H_23 #ifndef __EXECUTOR_SUBSTRING_H_ 24 #define __EXECUTOR_SUBSTRING_H_ 25 25 26 26 27 #include "executor .h"27 #include "executor_generic.h" 28 28 #include "substring.h" 29 29 … … 56 56 57 57 /** 58 * @brief this is a Template Class used as an evaluater.59 *60 * Trait to determine a default Value for any Type,61 * and to define the Convertible, and how it is transformed into the62 * corresponding SubTypes over the operator().63 *64 * This Class must be reimplemented for each Convertible and all of its65 * conversion-members.66 *67 * e.g: Convertible SubSting, that splits up into many Stings68 * conversion-members: (int) can be transformed from a String.69 */70 template<typename FromType> class ExecutorEvaluater71 {72 public:73 /** @brief Executes the Evaluater74 * @param CallValue the Value that should be converted75 * @param defaults the default Values.76 */77 template <typename ToType, int index>78 ToType operator()(FromType& CallValue, const MultiType* const defaults)79 {80 return defaultValue; /*(CallValue.size() > index) ?81 fromString<ToType>(CallValue[index], getDefault<ToType>(defaults, index)) :82 fromMulti<ToType>(defaults[index]); */83 }84 static FromType& defaultValue() { return FromType(); };85 };86 87 /**88 58 * @brief to remove writing errors, this function is Used. 89 59 * @param sub The SubString to use … … 107 77 }; 108 78 109 #endif /* __EXECUTOR_GENERIC_H_ */ 110 111 112 /////////// 113 //// 0 //// 114 /////////// 115 //! @brief ExecutorClass, that can execute Functions without any parameters. 116 template<class T, typename CallType, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 117 class __EXECUTOR_FUNCTIONAL_NAME(0) :public Executor<CallType, BaseClass> 118 { 119 private: 120 /** @brief the FunctioPointer. */ 121 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST; 122 123 public: 124 /** 125 * @brief constructs the Executor. 126 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 127 */ 128 __EXECUTOR_FUNCTIONAL_NAME(0) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST ) 129 : Executor<CallType, BaseClass>(false, __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) 130 { 131 this->functionPointer = functionPointer; 132 }; 133 134 /** 135 * @brief executes the Functional 136 * @param object the Object the action should be executed on. 137 * @param sub the SubString to get the Parameters from. 138 */ 139 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 140 { 141 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); 142 }; 143 144 /** 145 * @brief copies the Executor 146 * @returns a new Executor that's a copy of this one. 147 */ 148 virtual Executor<CallType, BaseClass>* clone() const 149 { 150 return new __EXECUTOR_FUNCTIONAL_NAME(0)<T, CallType>(this->functionPointer); 151 }; 152 }; 153 154 155 156 157 158 /////////// 159 //// 1 //// 160 /////////// 161 //! @brief ExecutorClass, that can execute Functions with one parameter. 162 template<class T, typename CallType, typename type0, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 163 class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor<CallType, BaseClass> 164 { 165 private: 166 /** @brief the FunctioPointer. */ 167 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST; 168 169 public: 170 /** 171 * @brief constructs the Executor. 172 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 173 */ 174 __EXECUTOR_FUNCTIONAL_NAME(1) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) 175 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) 176 { 177 this->functionPointer = functionPointer; 178 }; 179 180 /** 181 * @brief executes the Functional 182 * @param object the Object the action should be executed on. 183 * @param sub the SubString to get the Parameters from. 184 */ 185 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 186 { 187 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 188 Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue)); 189 }; 190 191 /** 192 * @brief copies the Executor 193 * @returns a new Executor that's a copy of this one. 194 */ 195 virtual Executor<CallType, BaseClass>* clone() const 196 { 197 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, CallType, type0>(this->functionPointer); 198 }; 199 }; 200 201 202 203 204 205 /////////// 206 //// 2 //// 207 /////////// 208 //! @brief ExecutorClass, that can execute Functions with two parameters. 209 template<class T, typename CallType, typename type0, typename type1, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 210 class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor<CallType, BaseClass> 211 { 212 private: 213 /** @brief the FunctioPointer. */ 214 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST; 215 216 public: 217 /** 218 * @brief constructs the Executor. 219 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 220 */ 221 __EXECUTOR_FUNCTIONAL_NAME(2) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) 222 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) 223 { 224 this->functionPointer = functionPointer; 225 }; 226 227 /** 228 * @brief executes the Functional 229 * @param object the Object the action should be executed on. 230 * @param sub the SubString to get the Parameters from. 231 */ 232 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 233 { 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)); 237 }; 238 239 /** 240 * @brief copies the Executor 241 * @returns a new Executor that's a copy of this one. 242 */ 243 virtual Executor<CallType, BaseClass>* clone() const 244 { 245 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, CallType, type0, type1>(this->functionPointer); 246 }; 247 }; 248 249 250 251 252 253 /////////// 254 //// 3 //// 255 /////////// 256 //! @brief ExecutorClass, that can execute Functions with three parameters. 257 template<class T, typename CallType, typename type0, typename type1, typename type2, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 258 class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor<CallType, BaseClass> 259 { 260 private: 261 /** @brief the FunctioPointer. */ 262 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST; 263 264 public: 265 /** 266 * @brief constructs the Executor. 267 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 268 */ 269 __EXECUTOR_FUNCTIONAL_NAME(3) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) 270 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) 271 { 272 this->functionPointer = functionPointer; 273 }; 274 275 /** 276 * @brief executes the Functional 277 * @param object the Object the action should be executed on. 278 * @param sub the SubString to get the Parameters from. 279 */ 280 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 281 { 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)); 286 }; 287 288 /** 289 * @brief copies the Executor 290 * @returns a new Executor that's a copy of this one. 291 */ 292 virtual Executor<CallType, BaseClass>* clone() const 293 { 294 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, CallType, type0, type1, type2>(this->functionPointer); 295 }; 296 }; 297 298 299 300 301 302 /////////// 303 //// 4 //// 304 /////////// 305 //! @brief ExecutorClass, that can execute Functions with four parameters. 306 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 307 class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor<CallType, BaseClass> 308 { 309 private: 310 /** @brief the FunctioPointer. */ 311 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST; 312 313 public: 314 /** 315 * @brief constructs the Executor. 316 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 317 */ 318 __EXECUTOR_FUNCTIONAL_NAME(4) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) 319 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) 320 { 321 this->functionPointer = functionPointer; 322 }; 323 324 /** 325 * @brief executes the Functional 326 * @param object the Object the action should be executed on. 327 * @param sub the SubString to get the Parameters from. 328 */ 329 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 330 { 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)); 336 }; 337 338 /** 339 * @brief copies the Executor 340 * @returns a new Executor that's a copy of this one. 341 */ 342 virtual Executor<CallType, BaseClass>* clone() const 343 { 344 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, CallType, type0, type1, type2, type3>(this->functionPointer); 345 }; 346 }; 347 348 349 350 351 352 353 /////////// 354 //// 5 //// 355 /////////// 356 //! @brief ExecutorClass, that can execute Functions with five parameters. 357 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, typename type4, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> 358 class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor<CallType, BaseClass> 359 { 360 private: 361 /** @brief the FunctioPointer. */ 362 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST; 363 364 public: 365 /** 366 * @brief constructs the Executor. 367 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 368 */ 369 __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) 370 : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) 371 { 372 this->functionPointer = functionPointer; 373 }; 374 375 /** 376 * @brief executes the Functional 377 * @param object the Object the action should be executed on. 378 * @param sub the SubString to get the Parameters from. 379 */ 380 virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const 381 { 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)); 388 }; 389 390 /** 391 * @brief copies the Executor 392 * @returns a new Executor that's a copy of this one. 393 */ 394 virtual Executor<CallType, BaseClass>* clone() const 395 { 396 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, CallType, type0, type1, type2, type3, type4>(this->functionPointer); 397 }; 398 }; 399 400 //#endif /* __EXECUTOR_GENERIC_H_ */ 79 #endif /* __EXECUTOR_SUBSTRING_H_ */
Note: See TracChangeset
for help on using the changeset viewer.