Changeset 967 for code/branches/core2/src/orxonox/core/Executor.cc
- Timestamp:
- Mar 31, 2008, 12:25:09 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/core/Executor.cc
r957 r967 29 29 #include "Executor.h" 30 30 #include "Language.h" 31 #include "util/Math.h" 31 32 32 33 namespace orxonox … … 62 63 { 63 64 EXECUTOR_PARSE(normal); 65 } 66 67 bool Executor::evaluate(const std::string& params, MultiTypeMath param[5], const std::string& delimiter) const 68 { 69 unsigned int paramCount = this->functor_->getParamCount(); 70 71 if (paramCount == 1) 72 { 73 // only one param: check if there are params given, otherwise try to use default values 74 std::string temp = getStripped(params); 75 if ((temp != "") && (temp.size() != 0)) 76 { 77 param[0] = params; 78 this->functor_->evaluateParam(0, param[0]); 79 return true; 80 } 81 else if (this->bAddedDefaultValue_[0]) 82 { 83 param[0] = this->defaultValue_[0]; 84 this->functor_->evaluateParam(0, param[0]); 85 return true; 86 } 87 return false; 88 } 89 else 90 { 91 // more than one param 92 SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0'); 93 94 // if there are not enough params given, check if there are default values 95 for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++) 96 if (!this->bAddedDefaultValue_[i]) 97 return false; 98 99 // assign all given arguments to the multitypes 100 for (unsigned int i = 0; i < min(tokens.size(), (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++) 101 param[i] = tokens[i]; 102 103 // fill the remaining multitypes with default values 104 for (unsigned int i = tokens.size(); i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++) 105 param[i] = this->defaultValue_[i]; 106 107 // evaluate the param types through the functor 108 for (unsigned int i = 0; i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++) 109 this->functor_->evaluateParam(i, param[i]); 110 111 return true; 112 } 64 113 } 65 114
Note: See TracChangeset
for help on using the changeset viewer.