Changeset 7189 for code/branches
- Timestamp:
- Aug 19, 2010, 4:57:06 PM (14 years ago)
- Location:
- code/branches/consolecommands3/src/libraries
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/CommandEvaluation.cc
r6417 r7189 74 74 bool CommandEvaluation::execute() const 75 75 { 76 bool success; 77 this->query(&success); 78 return success; 79 } 80 81 MultiType CommandEvaluation::query(bool* success) const 82 { 83 if (success) 84 *success = false; 85 76 86 if (!this->isValid()) 77 return false;87 return MT_Type::Null; 78 88 79 89 if (this->bEvaluatedParams_ && this->function_) 80 90 { 91 if (success) 92 *success = true; 81 93 COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << ' ' << this->param_[0] << ' ' << this->param_[1] << ' ' << this->param_[2] << ' ' << this->param_[3] << ' ' << this->param_[4] << std::endl; 82 (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]); 83 return true; 94 return (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]); 84 95 } 85 96 … … 90 101 unsigned int startindex = this->getStartindex(); 91 102 if (this->commandTokens_.size() > startindex) 92 return this->function_->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter()) );103 return this->function_->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter()), success); 93 104 else 94 return this->function_->parse(removeSlashes(this->additionalParameter_) );95 } 96 97 return false;105 return this->function_->parse(removeSlashes(this->additionalParameter_), success); 106 } 107 108 return MT_Type::Null; 98 109 } 99 110 … … 233 244 } 234 245 235 bool CommandEvaluation::hasReturnvalue() const236 {237 if (this->function_)238 return this->function_->hasReturnvalue();239 240 return MT_Type::Null;241 }242 243 MultiType CommandEvaluation::getReturnvalue() const244 {245 if (this->function_)246 return this->function_->getReturnvalue();247 248 return MultiType();249 }250 251 252 246 unsigned int CommandEvaluation::getStartindex() const 253 247 { -
code/branches/consolecommands3/src/libraries/core/CommandEvaluation.h
r6417 r7189 66 66 67 67 bool execute() const; 68 MultiType query(bool* success = 0) const; 69 68 70 const std::string& complete(); 69 71 std::string hint() const; … … 86 88 void setEvaluatedParameter(unsigned int index, MultiType param); 87 89 MultiType getEvaluatedParameter(unsigned int index) const; 88 89 bool hasReturnvalue() const;90 MultiType getReturnvalue() const;91 90 92 91 private: -
code/branches/consolecommands3/src/libraries/core/CommandExecutor.cc
r6417 r7189 104 104 { 105 105 if (useTcl) 106 return TclBind::eval(command); 107 108 CommandExecutor::parseIfNeeded(command); 109 return CommandExecutor::getEvaluation().execute(); 110 } 111 112 MultiType CommandExecutor::getReturnValue() 113 { 114 return CommandExecutor::getEvaluation().getReturnvalue(); 115 } 116 117 std::string CommandExecutor::getReturnValueString() 118 { 119 return CommandExecutor::getEvaluation().getReturnvalue().getString(); 106 { 107 bool success; 108 TclBind::eval(command, &success); 109 return success; 110 } 111 else 112 { 113 CommandExecutor::parseIfNeeded(command); 114 return CommandExecutor::getEvaluation().execute(); 115 } 116 } 117 118 MultiType CommandExecutor::queryMT(const std::string& command, bool* success, bool useTcl) 119 { 120 if (useTcl) 121 { 122 return TclBind::eval(command, success); 123 } 124 else 125 { 126 CommandExecutor::parseIfNeeded(command); 127 return CommandExecutor::getEvaluation().query(success); 128 } 129 } 130 131 std::string CommandExecutor::query(const std::string& command, bool* success, bool useTcl) 132 { 133 if (useTcl) 134 { 135 return TclBind::eval(command, success); 136 } 137 else 138 { 139 CommandExecutor::parseIfNeeded(command); 140 return CommandExecutor::getEvaluation().query(success).getString(); 141 } 120 142 } 121 143 -
code/branches/consolecommands3/src/libraries/core/CommandExecutor.h
r6417 r7189 47 47 public: 48 48 static bool execute(const std::string& command, bool useTcl = true); // tolua_export 49 static MultiType getReturnValue(); 50 static std::string getReturnValueString(); // tolua_export 49 50 static MultiType queryMT(const std::string& command, bool* success = 0, bool useTcl = true); 51 static std::string query(const std::string& command, bool* success = 0, bool useTcl = true); // tolua_export 51 52 52 53 static std::string complete(const std::string& command); -
code/branches/consolecommands3/src/libraries/core/Executor.cc
r7187 r7189 50 50 } 51 51 52 bool Executor::parse(const std::string& params, const std::string& delimiter) const 53 { 52 MultiType Executor::parse(const std::string& params, bool* success, const std::string& delimiter) const 53 { 54 if (success) 55 *success = true; 56 54 57 unsigned int paramCount = this->functor_->getParamCount(); 55 58 … … 57 60 { 58 61 COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl; 59 (*this->functor_)();62 return (*this->functor_)(); 60 63 } 61 64 else if (paramCount == 1) … … 65 68 { 66 69 COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl; 67 (*this->functor_)(MultiType(params));70 return (*this->functor_)(MultiType(params)); 68 71 } 69 72 else if (!this->defaultValue_[0].null()) 70 73 { 71 74 COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl; 72 (*this->functor_)(this->defaultValue_[0]);75 return (*this->functor_)(this->defaultValue_[0]); 73 76 } 74 77 else 75 78 { 76 79 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl; 77 return false; 80 if (success) 81 *success = false; 82 return MT_Type::Null; 78 83 } 79 84 } … … 87 92 { 88 93 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl; 89 return false; 94 if (success) 95 *success = false; 96 return MT_Type::Null; 90 97 } 91 98 } … … 120 127 { 121 128 case 2: 122 (*this->functor_)(param[0], param[1]); 123 break; 129 return (*this->functor_)(param[0], param[1]); 124 130 case 3: 125 (*this->functor_)(param[0], param[1], param[2]); 126 break; 131 return (*this->functor_)(param[0], param[1], param[2]); 127 132 case 4: 128 (*this->functor_)(param[0], param[1], param[2], param[3]); 129 break; 133 return (*this->functor_)(param[0], param[1], param[2], param[3]); 130 134 case 5: 131 (*this->functor_)(param[0], param[1], param[2], param[3], param[4]); 132 break; 133 } 134 } 135 136 return true; 135 return (*this->functor_)(param[0], param[1], param[2], param[3], param[4]); 136 } 137 } 138 139 return MT_Type::Null; 137 140 } 138 141 -
code/branches/consolecommands3/src/libraries/core/Executor.h
r7188 r7189 45 45 virtual ~Executor(); 46 46 47 inline voidoperator()() const48 { (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }49 inline voidoperator()(const MultiType& param1) const50 { (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }51 inline voidoperator()(const MultiType& param1, const MultiType& param2) const52 { (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }53 inline voidoperator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const54 { (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }55 inline voidoperator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const56 { (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); }57 inline voidoperator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const58 { (*this->functor_)(param1, param2, param3, param4, param5); }59 60 bool parse(const std::string& params, const std::string& delimiter = " ") const;47 inline MultiType operator()() const 48 { return (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 49 inline MultiType operator()(const MultiType& param1) const 50 { return (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 51 inline MultiType operator()(const MultiType& param1, const MultiType& param2) const 52 { return (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 53 inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const 54 { return (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); } 55 inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const 56 { return (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); } 57 inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const 58 { return (*this->functor_)(param1, param2, param3, param4, param5); } 59 60 MultiType parse(const std::string& params, bool* success = 0, const std::string& delimiter = " ") const; 61 61 62 62 bool evaluate(const std::string& params, MultiType param[5], const std::string& delimiter = " ") const; … … 70 70 inline Functor::Type::Enum getType() const 71 71 { return this->functor_->getType(); } 72 inline const MultiType& getReturnvalue() const73 { return this->functor_->getReturnvalue(); }74 72 inline std::string getTypenameParam(unsigned int param) const 75 73 { return this->functor_->getTypenameParam(param); } … … 128 126 using Executor::operator(); 129 127 130 inline voidoperator()(T* object) const131 { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }132 inline voidoperator()(T* object, const MultiType& param1) const133 { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }134 inline voidoperator()(T* object, const MultiType& param1, const MultiType& param2) const135 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }136 inline voidoperator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const137 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }138 inline voidoperator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const139 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }140 inline voidoperator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const141 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }142 143 144 inline voidoperator()(const T* object) const145 { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }146 inline voidoperator()(const T* object, const MultiType& param1) const147 { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }148 inline voidoperator()(const T* object, const MultiType& param1, const MultiType& param2) const149 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }150 inline voidoperator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const151 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }152 inline voidoperator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const153 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }154 inline voidoperator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const155 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }128 inline MultiType operator()(T* object) const 129 { return (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 130 inline MultiType operator()(T* object, const MultiType& param1) const 131 { return (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 132 inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2) const 133 { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 134 inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const 135 { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); } 136 inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const 137 { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); } 138 inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const 139 { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); } 140 141 142 inline MultiType operator()(const T* object) const 143 { return (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 144 inline MultiType operator()(const T* object, const MultiType& param1) const 145 { return (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 146 inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2) const 147 { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 148 inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const 149 { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); } 150 inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const 151 { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); } 152 inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const 153 { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); } 156 154 157 155 inline void setObject(T* object) const … … 162 160 using Executor::parse; 163 161 164 bool parse(T* object, const std::string& params, const std::string& delimiter = " ") const162 MultiType parse(T* object, const std::string& params, bool* success = 0, const std::string& delimiter = " ") const 165 163 { 166 164 FunctorMember<T>* functorMember = static_cast<FunctorMember<T>*>(this->functor_); … … 169 167 170 168 functorMember->setObject(object); 171 bool result = Executor::parse(params, delimiter);169 const MultiType& result = Executor::parse(params, success, delimiter); 172 170 functorMember->setObjects(objects); 173 171 … … 175 173 } 176 174 177 bool parse(const T* object, const std::string& params, const std::string& delimiter = " ") const175 MultiType parse(const T* object, const std::string& params, bool* success = 0, const std::string& delimiter = " ") const 178 176 { 179 177 FunctorMember<T>* functorMember = static_cast<FunctorMember<T>*>(this->functor_); … … 182 180 183 181 functorMember->setObject(object); 184 bool result = Executor::parse(params, delimiter);182 const MultiType& result = Executor::parse(params, success, delimiter); 185 183 functorMember->setObjects(objects); 186 184 -
code/branches/consolecommands3/src/libraries/core/Functor.h
r7188 r7189 104 104 virtual ~Functor() {} 105 105 106 virtual void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0; 107 108 inline const MultiType& getReturnvalue() const { return this->returnedValue_; } 106 virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0; 109 107 110 108 virtual Type::Enum getType() const = 0; … … 121 119 122 120 virtual const std::type_info& getHeaderIdentifier() const = 0; 123 124 protected:125 MultiType returnedValue_;126 121 }; 127 122 … … 130 125 public: 131 126 virtual ~FunctorStatic() {} 132 virtual voidoperator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;127 virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0; 133 128 }; 134 129 … … 144 139 virtual ~FunctorMember() {} 145 140 146 virtual voidoperator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;147 virtual voidoperator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;148 149 virtual voidoperator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)141 virtual MultiType operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0; 142 virtual MultiType operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0; 143 144 virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) 150 145 { 151 146 if (this->object_) 152 (*this)(this->object_, param1, param2, param3, param4, param5);147 return (*this)(this->object_, param1, param2, param3, param4, param5); 153 148 else if (this->constObject_) 154 (*this)(this->constObject_, param1, param2, param3, param4, param5);149 return (*this)(this->constObject_, param1, param2, param3, param4, param5); 155 150 else 156 151 { 157 152 COUT(1) << "An error occurred in Functor.h:" << std::endl; 158 153 COUT(1) << "Error: No object set." << std::endl; 154 return MT_Type::Null; 159 155 } 160 156 } … … 340 336 341 337 #define FUNCTOR_STORE_RETURNVALUE(returnvalue, functioncall) FUNCTOR_STORE_RETURNVALUE##returnvalue(functioncall) 342 #define FUNCTOR_STORE_RETURNVALUE0(functioncall) functioncall 343 #define FUNCTOR_STORE_RETURNVALUE1(functioncall) this->returnedValue_ =functioncall338 #define FUNCTOR_STORE_RETURNVALUE0(functioncall) functioncall; return MT_Type::Null 339 #define FUNCTOR_STORE_RETURNVALUE1(functioncall) return functioncall 344 340 345 341 … … 395 391 } \ 396 392 \ 397 voidoperator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \393 MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \ 398 394 { \ 399 395 FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \ … … 441 437 } \ 442 438 \ 443 voidoperator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \439 MultiType operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \ 444 440 { \ 445 441 FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \ 446 442 } \ 447 443 \ 448 voidoperator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \444 MultiType operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \ 449 445 { \ 450 446 COUT(1) << "An error occurred in Functor.h:" << std::endl; \ 451 447 COUT(1) << "Error: Function is not const." << std::endl; \ 448 return MT_Type::Null; \ 452 449 } \ 453 450 \ … … 482 479 } \ 483 480 \ 484 voidoperator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \481 MultiType operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \ 485 482 { \ 486 483 FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \ 487 484 } \ 488 485 \ 489 voidoperator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \486 MultiType operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \ 490 487 { \ 491 488 FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \ -
code/branches/consolecommands3/src/libraries/core/LuaState.cc
r6763 r7189 370 370 } 371 371 372 voidLuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)372 MultiType LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) 373 373 { 374 374 lua_->doString(this->code_); 375 return MT_Type::Null; 375 376 } 376 377 } -
code/branches/consolecommands3/src/libraries/core/LuaState.h
r7188 r7189 52 52 public: 53 53 LuaFunctor(const std::string& code, LuaState* luaState); 54 voidoperator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null);54 MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null); 55 55 void evaluateParam(unsigned int index, MultiType& param) const {} 56 56 -
code/branches/consolecommands3/src/libraries/core/Shell.cc
r7167 r7189 308 308 this->updateListeners<&ShellListener::executed>(); 309 309 310 if (!CommandExecutor::execute(this->inputBuffer_->get())) 310 bool success; 311 const std::string& result = CommandExecutor::query(this->inputBuffer_->get(), &success); 312 if (!success) 311 313 { 312 314 this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\"." << std::endl; 313 315 this->outputChanged(Error); 316 } 317 else if (result != "") 318 { 319 this->outputBuffer_ << result << std::endl; 320 this->outputChanged(Command); 314 321 } 315 322 -
code/branches/consolecommands3/src/libraries/core/TclBind.cc
r7174 r7189 134 134 const std::string& command = stripEnclosingBraces(args.get()); 135 135 136 if (!CommandExecutor::execute(command, false)) 136 bool success; 137 const std::string& result = CommandExecutor::query(command, &success, false); 138 if (!success) 137 139 { 138 140 COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl; 139 141 } 140 142 141 if (CommandExecutor::getLastEvaluation().hasReturnvalue()) 142 return CommandExecutor::getLastEvaluation().getReturnvalue().getString(); 143 144 return ""; 143 return result; 145 144 } 146 145 … … 181 180 } 182 181 183 bool TclBind::eval(const std::string& tclcode)182 std::string TclBind::eval(const std::string& tclcode, bool* success) 184 183 { 184 if (success) 185 *success = true; 186 185 187 try 186 188 { 187 TclBind::getInstance().interpreter_->eval(tclcode); 188 return true; 189 return TclBind::getInstance().interpreter_->eval(tclcode); 189 190 } 190 191 catch (Tcl::tcl_error const &e) 191 192 { COUT(1) << "Tcl error: " << e.what() << std::endl; } 192 193 193 return false; 194 if (success) 195 *success = false; 196 return ""; 194 197 } 195 198 } -
code/branches/consolecommands3/src/libraries/core/TclBind.h
r6417 r7189 59 59 static void tcl_execute(Tcl::object const &args); 60 60 61 static bool eval(const std::string& tclcode);61 static std::string eval(const std::string& tclcode, bool* success = 0); 62 62 63 63 private: -
code/branches/consolecommands3/src/libraries/core/TclThreadManager.cc
r7174 r7189 439 439 // It's a query to the CommandExecutor 440 440 TclThreadManager::debug("TclThread_query -> CE: " + command); 441 if (!CommandExecutor::execute(command, false)) 441 bool success; 442 output = CommandExecutor::query(command, &success, false); 443 if (!success) 442 444 TclThreadManager::error("Error: Can't execute command \"" + command + "\"!"); 443 444 if (CommandExecutor::getLastEvaluation().hasReturnvalue())445 output = CommandExecutor::getLastEvaluation().getReturnvalue().getString();446 445 } 447 446 else -
code/branches/consolecommands3/src/libraries/core/XMLPort.h
r7186 r7189 398 398 { 399 399 COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation(); 400 if (this->loadexecutor_->parse(object, attributeValue, ",") || (mode == XMLPort::ExpandObject)) 400 bool success; 401 this->loadexecutor_->parse(object, attributeValue, &success, ","); 402 if (success || (mode == XMLPort::ExpandObject)) 401 403 this->parseResult_ = PR_finished; 402 404 else -
code/branches/consolecommands3/src/libraries/util/MultiType.h
r7187 r7189 78 78 79 79 #include "TypeTraits.h" 80 #include "mbool.h" 80 81 81 82 namespace orxonox … … 266 267 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 267 268 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 269 inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } /** @brief Constructor: Assigns the given mbool and converts it to bool. */ 268 270 inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } /** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */ 269 271 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } /** @brief Copyconstructor: Assigns value and type of the other MultiType. */
Note: See TracChangeset
for help on using the changeset viewer.