Changeset 7198 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- Mar 8, 2006, 2:30:19 PM (19 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/executor/executor.cc
r7197 r7198 55 55 for (unsigned int i = 0; i < FUNCTOR_MAX_ARGUMENTS; i++) 56 56 { 57 printf("%d ", i);58 57 if (this->defaultValue[i] == MT_NULL) 59 58 { … … 61 60 break; 62 61 } 63 64 62 } 65 printf("%d\n", this->paramCount);66 67 63 assert (paramCount <= FUNCTOR_MAX_ARGUMENTS); 68 64 } … … 85 81 } 86 82 87 88 89 83 /** 90 * sets default Values of the Commands 91 * @param count how many default Values to set. 92 * @param ... the default Values in order. They will be cast to the right type 84 * @brief set the default values of the executor 85 * @param value0 the first default value 86 * @param value1 the second default value 87 * @param value2 the third default value 88 * @param value3 the fourth default value 89 * @param value4 the fifth default value 93 90 * @returns itself 94 *95 * Be aware, that when you use this Function, you !!MUST!! match the input as96 * count, [EXACTLY THE SAME AS IF YOU WOULD CALL THE FUNCTION UP TO count ARGUMENTS]97 91 */ 98 Executor* Executor::defaultValues(unsigned int count, ...) 99 { 100 va_list values; 101 va_start(values, count); 102 103 this->defaultValues(count, values); 104 } 105 106 Executor* Executor::defaultValues(unsigned int count, va_list values) 92 Executor* Executor::defaultValues(const MultiType& value0, 93 const MultiType& value1, 94 const MultiType& value2, 95 const MultiType& value3, 96 const MultiType& value4) 107 97 { 108 98 if (this == NULL) 109 99 return NULL; 110 if (count == 0)111 return this;112 if (count > this->paramCount)113 count = this->paramCount;114 100 101 const MultiType* value[5]; 102 value[0] = &value0; 103 value[1] = &value1; 104 value[2] = &value2; 105 value[3] = &value3; 106 value[4] = &value4; 115 107 116 for (unsigned int i = 0; i < count; i++)108 for (unsigned int i = 0; i < this->paramCount; i++) 117 109 { 118 switch (this->defaultValue[i].getType())110 if (*value[i] != MT_NULL) 119 111 { 120 case MT_BOOL: 121 this->defaultValue[i].setInt(va_arg(values, int)); 122 break; 123 case MT_CHAR: 124 this->defaultValue[i].setChar((char)va_arg(values, int)); 125 break; 126 case MT_STRING: 127 this->defaultValue[i].setString(va_arg(values, char*)); 128 break; 129 case MT_INT: 130 this->defaultValue[i].setInt(va_arg(values, int)); 131 break; 132 /* case MT_UINT: 133 this->defaultValue[i].setInt((int)va_arg(values, unsigned int)); 134 break;*/ 135 case MT_FLOAT: 136 this->defaultValue[i].setFloat(va_arg(values, double)); 137 break; 138 /* case MT_LONG: 139 this->defaultValue[i].setInt((int) va_arg(values, long)); 140 break;*/ 141 default: 142 break; 112 if (this->defaultValue[i].getType() == value[i]->getType()) 113 { 114 this->defaultValue[i] = *value[i]; 115 } 116 else 117 { 118 PRINTF(1)("Unable to set this Value, as it is not of type %s\n", MultiType::MultiTypeToString(this->defaultValue[i].getType())); 119 } 143 120 } 144 121 } -
trunk/src/lib/util/executor/executor.h
r7197 r7198 45 45 virtual Executor* clone () const = 0; 46 46 47 Executor* defaultValues(unsigned int count, va_list values); 48 Executor* defaultValues(unsigned int count, ...); 47 Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL, 48 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 49 const MultiType& value4 = MT_NULL); 49 50 50 51 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ … … 59 60 60 61 protected: 61 Executor(const MultiType& param0 = MT_NULL, 62 const MultiType& param1 = MT_NULL, 63 const MultiType& param2 = MT_NULL, 64 const MultiType& param3 = MT_NULL, 62 Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL, 63 const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL, 65 64 const MultiType& param4 = MT_NULL); 66 65 -
trunk/src/lib/util/loading/load_param.cc
r7193 r7198 63 63 if (likely(this->object != NULL) && 64 64 ( this->loadString != NULL || 65 ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString)))65 ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString))) 66 66 { 67 67 PRINTF(4)("Loading '%s' with Parameters '%s' onto: '%s'(%s)\n", this->paramName, this->loadString, this->object->getName(), this->object->getClassName()); … … 73 73 74 74 /** 75 * set the default values of the executor 76 * @param count how many default values to set. 77 * @param ... the default values !! must be at least count parameters!! 78 */ 79 CLoadParam& CLoadParam::defaultValues(unsigned int count, ...) 80 { 81 va_list values; 82 va_start(values, count); 83 84 assert(executor != NULL); 85 this->executor->defaultValues(count, values); 75 * @brief set the default values of the executor 76 * @param value0 the first default value 77 * @param value1 the second default value 78 * @param value2 the third default value 79 * @param value3 the fourth default value 80 * @param value4 the fifth default value 81 */ 82 CLoadParam& CLoadParam::defaultValues(const MultiType& value0, const MultiType& value1, 83 const MultiType& value2, const MultiType& value3, 84 const MultiType& value4) 85 { 86 assert(this->executor != NULL); 87 this->executor->defaultValues(value0, value1, value2, value3, value4); 86 88 87 89 return *this; … … 97 99 { 98 100 if (LoadClassDescription::parametersDescription && this->paramDesc && !this->paramDesc->getDescription()) 99 100 101 101 { 102 this->paramDesc->setDescription(descriptionText); 103 } 102 104 return *this; 103 105 } … … 239 241 node = element->FirstChild(); 240 242 while( node != NULL) 241 242 243 244 243 { 244 if( node->ToText()) return node->Value(); 245 node = node->NextSibling(); 246 } 245 247 return NULL; 246 248 } -
trunk/src/lib/util/loading/load_param.h
r7130 r7198 91 91 92 92 CLoadParam& describe(const char* descriptionText); 93 CLoadParam& defaultValues(unsigned int count, ...); 93 CLoadParam& defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL, 94 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 95 const MultiType& value4 = MT_NULL); 94 96 CLoadParam& attribute(const char* attributeName, const Executor& executor); 95 97
Note: See TracChangeset
for help on using the changeset viewer.