Changeset 9732 in orxonox.OLD for branches/new_class_id
- Timestamp:
- Sep 15, 2006, 3:17:55 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/util/executor
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/executor/executor.cc
r9730 r9732 54 54 55 55 this->paramCount = 0; 56 for (unsigned int i = 0; i <= FUNCTOR_MAX_ARGUMENTS; i++)56 for (unsigned int i = 0; i <= EXECUTOR_MAX_ARGUMENTS; i++) 57 57 { 58 if (this->defaultValue[i] == MT_NULL || i == FUNCTOR_MAX_ARGUMENTS)58 if (this->defaultValue[i] == MT_NULL || i == EXECUTOR_MAX_ARGUMENTS) 59 59 { 60 60 this->paramCount = i; -
branches/new_class_id/src/lib/util/executor/executor.h
r9730 r9732 18 18 Executor_Static, 19 19 } Executor_Type; 20 21 //! The maximum Count of Arguments of the Executor 22 /** This is Hardcoded, for each Executor. */ 23 #define EXECUTOR_MAX_ARGUMENTS 7 20 24 21 25 … … 46 50 { 47 51 public: 48 // virtual bool operator==(const Executor* executor) const = 0;49 50 52 /** @param i the i'th defaultValue, @returns reference to the MultiType */ 51 53 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; }; … … 83 85 MultiType defaultValue[7]; //!< Default Values. 84 86 87 private: 85 88 const bool bRetVal; //!< True if the Executor has a return Value. 89 const bool bStaticFunction; //!< A Executor to a Static Function 90 const bool bConstFunction; //!< A Executor to a Constant Function 86 91 }; 87 92 -
branches/new_class_id/src/lib/util/executor/executor_functional.h
r9731 r9732 61 61 { 62 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)) :63 ToType operator()(FromType& CallValue, const MultiType* const defaults) 64 { 65 return (CallValue.size() > index) ? 66 fromString<ToType>(CallValue[index], getDefault<ToType>(defaults, index)) : 67 67 fromMulti<ToType>(defaults[index]); 68 68 } … … 426 426 */ 427 427 #define EXECUTOR_FUNCTIONAL_CREATOR1(type0) \ 428 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0 ##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \428 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) \ 429 429 { \ 430 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, const SubString, type0 ##_TYPE>(functionPointer); \430 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, const SubString, type0>(functionPointer); \ 431 431 } 432 432 … … 437 437 */ 438 438 #define EXECUTOR_FUNCTIONAL_CREATOR2(type0, type1) \ 439 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0 ##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \439 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) \ 440 440 { \ 441 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, const SubString, type0 ##_TYPE, type1##_TYPE>(functionPointer); \441 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, const SubString, type0, type1>(functionPointer); \ 442 442 } 443 443 … … 449 449 */ 450 450 #define EXECUTOR_FUNCTIONAL_CREATOR3(type0, type1, type2) \ 451 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0 ##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \451 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) \ 452 452 { \ 453 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, const SubString, type0 ##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \453 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, const SubString, type0, type1, type2>(functionPointer); \ 454 454 } 455 455 … … 462 462 */ 463 463 #define EXECUTOR_FUNCTIONAL_CREATOR4(type0, type1, type2, type3) \ 464 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0 ##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \464 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) \ 465 465 { \ 466 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, const SubString, type0 ##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \466 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, const SubString, type0, type1, type2, type3>(functionPointer); \ 467 467 } 468 468 … … 476 476 */ 477 477 #define EXECUTOR_FUNCTIONAL_CREATOR5(type0, type1, type2, type3, type4) \ 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) \478 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) \ 479 479 { \ 480 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, const SubString, type0 ##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \480 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, const SubString, type0, type1, type2, type3, type4>(functionPointer); \ 481 481 } 482 482 -
branches/new_class_id/src/lib/util/executor/functor_list.h
r9406 r9732 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 10 */ 11 11 12 12 /*! 13 13 * @file functors_list.h 14 * all the Different types of Functions one can include 15 */ 16 17 /** 18 useable FunctionParameters are: 19 l_INT: int 20 l_LONG: long 21 l_SHORT: short 22 l_FLOAT: float 23 l_STRING: const std::string& 24 l_XML_ELEM: TiXmlElement* 14 * all the Different types of Functions one can include by using a simple createExecutor call 15 * with a FunctionPointer as Argument 25 16 */ 26 17 27 #ifndef __FUNCTOR_PARAMETERS__28 #define __FUNCTOR_PARAMETERS__29 30 //! defines the maximum count of arguments function pointers might have31 #define FUNCTOR_MAX_ARGUMENTS 732 #include "multi_type.h"33 34 35 #define l_BOOL_TYPE bool //!< The type of an BOOL36 #define l_BOOL_FUNC isBool //!< The function to call to parse BOOL37 #define l_BOOL_PARAM MT_BOOL //!< the type of the parameter BOOL38 #define l_BOOL_DEFAULT false //!< a default Value for an BOOL39 #define l_BOOL_DEFGRAB(i) this->defaultValue[i].getBool()40 41 #define l_INT_TYPE int //!< The type of an INT42 #define l_INT_FUNC isInt //!< The function to call to parse INT43 #define l_INT_PARAM MT_INT //!< the type of the parameter INT44 #define l_INT_DEFAULT 0 //!< a default Value for an INT45 #define l_INT_DEFGRAB(i) this->defaultValue[i].getInt()46 47 #define l_UINT_TYPE unsigned int //!< The type of an UINT48 #define l_UINT_FUNC isInt //!< The function to call to parse UINT49 #define l_UINT_PARAM MT_INT //!< the type of the parameter UINT50 #define l_UINT_DEFAULT 0 //!< a default Value for an UINT51 #define l_UINT_DEFGRAB(i) (unsigned int)this->defaultValue[i].getInt()52 53 #define l_LONG_TYPE long //!< The type of a LONG54 #define l_LONG_FUNC isInt //!< The function to parse a LONG55 #define l_LONG_PARAM MT_INT //!< the type of the parameter LONG56 #define l_LONG_DEFAULT 0 //!< a default Value for a LONG57 #define l_LONG_DEFGRAB(i) (long)this->defaultValue[i].getInt()58 59 // #define l_SHORT_TYPE short //!< The type of a SHORT60 // #define l_SHORT_FUNC atoi //!< The function to parse a SHORT61 // #define l_SHORT_NAME "short" //!< The name of a SHORT62 // #define l_SHORT_PARAM ParameterShort //!< the type of the parameter SHORT63 // #define l_SHORT_DEFAULT 0 //!< a default Value for a SHORT64 65 #define l_FLOAT_TYPE float //!< The type of a FLOAT66 #define l_FLOAT_FUNC isFloat //!< The function to parse a FLOAT67 #define l_FLOAT_PARAM MT_FLOAT //!< the type of the parameter FLOAT68 #define l_FLOAT_DEFAULT 0.0 //!< a default Value for a FLOAT69 #define l_FLOAT_DEFGRAB(i) this->defaultValue[i].getFloat()70 71 //#define l_VECTOR_TYPE const Vector& //!< The type of a VECTOR72 //#define l_VECTOR_FUNC isVector //!< The function to parse a VECTOR73 //#define l_VECTOR_NAME "Vector[x/y/z]" //!< The name of a VECTOR74 //#define l_VECTOR_DEFAULT Vector(0,0,0) //!< Default value for a VECTOR75 76 #define l_STRING_TYPE const std::string& //!< The type of a STRING77 #define l_STRING_FUNC isString //!< The function to parse a STRING78 #define l_STRING_PARAM MT_STRING //!< the type of the parameter STRING79 #define l_STRING_DEFAULT "" //!< a default Value for an STRING80 #define l_STRING_DEFGRAB(i) this->defaultValue[i].getString()81 82 #define l_XML_ELEM_TYPE const TiXmlElement* //!< The type of an XML_ELEM83 #define l_XML_ELEM_FUNC //!< The function to parse an XML_ELEM84 //#define l_XML_ELEM_PARAM Parameter //!< the type of the parameter XML_ELEM85 #define l_XML_ELEM_DEFAULT NULL //!< The dafault Value for an XML_ELEM86 87 #endif /* __FUNCTOR_PARAMETERS__ */88 89 90 18 #ifdef FUNCTOR_LIST 91 92 19 FUNCTOR_LIST(0)(); 93 20 //! makes functions with one string 94 FUNCTOR_LIST(1)( l_STRING);21 FUNCTOR_LIST(1)(const std::string&); 95 22 //! makes functions with two strings 96 FUNCTOR_LIST(2)( l_STRING, l_STRING);23 FUNCTOR_LIST(2)(const std::string&, const std::string&); 97 24 //! makes functions with three strings 98 FUNCTOR_LIST(3)( l_STRING, l_STRING, l_STRING);25 FUNCTOR_LIST(3)(const std::string&, const std::string&, const std::string&); 99 26 //! makes functions with four strings 100 FUNCTOR_LIST(4)( l_STRING, l_STRING, l_STRING, l_STRING);27 FUNCTOR_LIST(4)(const std::string&, const std::string&, const std::string&, const std::string&); 101 28 102 29 103 30 //! makes functions with one bool 104 FUNCTOR_LIST(1)( l_BOOL);31 FUNCTOR_LIST(1)(bool); 105 32 106 33 //! makes functions with one int 107 FUNCTOR_LIST(1)( l_INT);34 FUNCTOR_LIST(1)(int); 108 35 //! makes functions with two ints 109 FUNCTOR_LIST(2)( l_INT, l_INT);36 FUNCTOR_LIST(2)(int, int); 110 37 //! makes functions with three ints 111 FUNCTOR_LIST(3)( l_INT, l_INT, l_INT);38 FUNCTOR_LIST(3)(int, int, int); 112 39 //! makes functions with four ints 113 FUNCTOR_LIST(4)( l_INT, l_INT, l_INT, l_INT);40 FUNCTOR_LIST(4)(int, int, int, int); 114 41 115 42 116 43 //! makes functions with one unsigned int 117 FUNCTOR_LIST(1)( l_UINT);44 FUNCTOR_LIST(1)(unsigned int); 118 45 //! makes functions with two unsigned ints 119 FUNCTOR_LIST(2)( l_UINT, l_UINT);46 FUNCTOR_LIST(2)(unsigned int, unsigned int); 120 47 //! makes functions with three unsigned ints 121 FUNCTOR_LIST(3)( l_UINT, l_UINT, l_UINT);48 FUNCTOR_LIST(3)(unsigned int, unsigned int, unsigned int); 122 49 //! makes functions with four unsigned ints 123 FUNCTOR_LIST(4)( l_UINT, l_UINT, l_UINT, l_UINT);50 FUNCTOR_LIST(4)(unsigned int, unsigned int, unsigned int, unsigned int); 124 51 125 52 //! makes functions with one float 126 FUNCTOR_LIST(1)( l_FLOAT);53 FUNCTOR_LIST(1)(float); 127 54 //! makes functions with two floats 128 FUNCTOR_LIST(2)( l_FLOAT, l_FLOAT);55 FUNCTOR_LIST(2)(float, float); 129 56 //! makes functions with three floats 130 FUNCTOR_LIST(3)( l_FLOAT, l_FLOAT, l_FLOAT);57 FUNCTOR_LIST(3)(float, float, float); 131 58 //! makes functions with four floats 132 FUNCTOR_LIST(4)( l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);59 FUNCTOR_LIST(4)(float, float, float, float); 133 60 //! makes functions with four floats 134 FUNCTOR_LIST(5)( l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);61 FUNCTOR_LIST(5)(float, float, float, float, float); 135 62 136 63 //! mixed values: 137 FUNCTOR_LIST(2)( l_STRING, l_INT);138 FUNCTOR_LIST(2)( l_STRING, l_FLOAT);139 FUNCTOR_LIST(2)( l_UINT, l_LONG);140 FUNCTOR_LIST(2)( l_STRING, l_UINT);64 FUNCTOR_LIST(2)(const std::string&, int); 65 FUNCTOR_LIST(2)(const std::string&, float); 66 FUNCTOR_LIST(2)(unsigned int, long); 67 FUNCTOR_LIST(2)(const std::string&, unsigned int); 141 68 142 FUNCTOR_LIST(3)( l_STRING, l_FLOAT, l_UINT);143 FUNCTOR_LIST(4)( l_STRING, l_FLOAT, l_UINT, l_UINT);144 FUNCTOR_LIST(3)( l_STRING, l_INT, l_UINT);145 FUNCTOR_LIST(3)( l_STRING, l_UINT, l_UINT);69 FUNCTOR_LIST(3)(const std::string&, float, unsigned int); 70 FUNCTOR_LIST(4)(const std::string&, float, unsigned int, unsigned int); 71 FUNCTOR_LIST(3)(const std::string&, int, unsigned int); 72 FUNCTOR_LIST(3)(const std::string&, unsigned int, unsigned int); 146 73 147 FUNCTOR_LIST(5)( l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_STRING);74 FUNCTOR_LIST(5)(float, float, float, float, const std::string&); 148 75 149 76 #endif /* FUNCTOR_LIST */
Note: See TracChangeset
for help on using the changeset viewer.