Changeset 933
- Timestamp:
- Mar 27, 2008, 5:04:41 PM (17 years ago)
- Location:
- code/branches/core2/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/core/Executor.cc
r932 r933 81 81 else 82 82 { 83 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given ." << std::endl;83 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl; 84 84 return false; 85 85 } … … 93 93 if (!this->bAddedDefaultValue_[i]) 94 94 { 95 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given ." << std::endl;95 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl; 96 96 return false; 97 97 } … … 151 151 } 152 152 153 void Executor:: description(const std::string& description)153 void Executor::setDescription(const std::string& description) 154 154 { 155 155 if (!this->bAddedDescription_) … … 166 166 } 167 167 168 void Executor:: descriptionParam(int param, const std::string& description)168 void Executor::setDescriptionParam(int param, const std::string& description) 169 169 { 170 170 if (param >= 0 && param < MAX_FUNCTOR_ARGUMENTS) … … 191 191 } 192 192 193 void Executor:: descriptionReturnvalue(const std::string& description)193 void Executor::setDescriptionReturnvalue(const std::string& description) 194 194 { 195 195 if (!this->bAddedDescriptionReturnvalue_) … … 256 256 } 257 257 258 void Executor::setDefaultValue( int index, const MultiTypeMath& param)258 void Executor::setDefaultValue(unsigned int index, const MultiTypeMath& param) 259 259 { 260 260 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) … … 264 264 } 265 265 } 266 267 bool Executor::allDefaultValuesSet() const 268 { 269 for (unsigned int i = 0; i < this->functor_->getParamCount(); i++) 270 if (!this->bAddedDefaultValue_[i]) 271 return false; 272 273 return true; 274 } 266 275 } -
code/branches/core2/src/orxonox/core/Executor.h
r932 r933 62 62 const std::string& getName() const; 63 63 64 void description(const std::string& description);64 void setDescription(const std::string& description); 65 65 const std::string& getDescription() const; 66 66 67 void descriptionParam(int param, const std::string& description);67 void setDescriptionParam(int param, const std::string& description); 68 68 const std::string& getDescriptionParam(int param) const; 69 69 70 void descriptionReturnvalue(const std::string& description);70 void setDescriptionReturnvalue(const std::string& description); 71 71 const std::string& getDescriptionReturnvalue(int param) const; 72 72 … … 89 89 void setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4); 90 90 void setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5); 91 void setDefaultValue(int index, const MultiTypeMath& param); 91 void setDefaultValue(unsigned int index, const MultiTypeMath& param); 92 93 bool allDefaultValuesSet() const; 92 94 93 95 protected: 94 96 Functor* functor_; 97 std::string name_; 98 MultiTypeMath defaultValue_[MAX_FUNCTOR_ARGUMENTS]; 99 bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS]; 95 100 96 101 private: 97 std::string name_;98 99 102 LanguageEntryLabel description_; 100 103 LanguageEntryLabel descriptionReturnvalue_; … … 104 107 bool bAddedDescriptionReturnvalue_; 105 108 bool bAddedDescriptionParam_[MAX_FUNCTOR_ARGUMENTS]; 106 107 MultiTypeMath defaultValue_[MAX_FUNCTOR_ARGUMENTS];108 bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS];109 109 }; 110 110 … … 155 155 { ((FunctorMember<T>*)this->functor_)->setObject(object); } 156 156 157 bool parse(T* object, const std::string& params, const std::string& delimiter ) const157 bool parse(T* object, const std::string& params, const std::string& delimiter = " ") const 158 158 { 159 159 unsigned int paramCount = this->functor_->getParamCount(); … … 179 179 else 180 180 { 181 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given ." << std::endl;181 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl; 182 182 return false; 183 183 } … … 191 191 if (!this->bAddedDefaultValue_[i]) 192 192 { 193 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given ." << std::endl;193 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl; 194 194 return false; 195 195 } … … 239 239 } 240 240 241 bool parse(const T* object, const std::string& params, const std::string& delimiter ) const241 bool parse(const T* object, const std::string& params, const std::string& delimiter = " ") const 242 242 { 243 243 unsigned int paramCount = this->functor_->getParamCount(); … … 263 263 else 264 264 { 265 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given ." << std::endl;265 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl; 266 266 return false; 267 267 } … … 275 275 if (!this->bAddedDefaultValue_[i]) 276 276 { 277 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given ." << std::endl;277 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl; 278 278 return false; 279 279 } … … 323 323 } 324 324 }; 325 326 inline Executor* createExecutor(Functor* functor, const std::string& name = "") 327 { 328 return new Executor(functor, name); 329 } 330 331 template <class T> 332 inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "") 333 { 334 return new ExecutorMember<T>(functor, name); 335 } 336 337 inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "") 338 { 339 return new ExecutorStatic(functor, name); 340 } 325 341 } 326 342 -
code/branches/core2/src/orxonox/core/XMLPort.cc
r878 r933 34 34 namespace orxonox 35 35 { 36 // ###############################37 // ### XMLPortParamContainer ###38 // ###############################39 XMLPortParamContainer::XMLPortParamContainer()40 {41 this->bAddedDescription_ = false;42 this->bAddedDefaultValues_ = false;43 }44 45 XMLPortParamContainer& XMLPortParamContainer::description(const std::string description)46 {47 if (!this->bAddedDescription_)48 {49 this->description_ = std::string("XMLPortParamContainer::" + this->classname_ + "::" + this->paramname_);50 AddLanguageEntry(this->description_, description);51 this->bAddedDescription_ = true;52 }53 54 return (*this);55 }56 57 const std::string& XMLPortParamContainer::getDescription()58 {59 return GetLocalisation(this->description_);60 }61 62 63 36 // ################################ 64 37 // ### XMLPortObjectContainer ### 65 38 // ################################ 66 XMLPortObjectContainer::XMLPortObjectContainer()67 {68 this->bAddedDescription_ = false;69 this->bApplyLoaderMask_ = false;70 }71 72 XMLPortObjectContainer& XMLPortObjectContainer::description(const std::string description)73 {74 if (!this->bAddedDescription_)75 {76 this->description_ = std::string("XMLPortObjectContainer::" + this->classname_ + "::" + this->sectionname_);77 AddLanguageEntry(this->description_, description);78 this->bAddedDescription_ = true;79 }80 81 return (*this);82 }83 84 const std::string& XMLPortObjectContainer::getDescription()85 {86 return GetLocalisation(this->description_);87 }88 89 39 bool XMLPortObjectContainer::identifierIsIncludedInLoaderMask(const Identifier* identifier) 90 40 { -
code/branches/core2/src/orxonox/core/XMLPort.h
r931 r933 33 33 #include "util/tinyxml/ticpp.h" 34 34 #include "util/SubString.h" 35 #include " Functor.h"35 #include "Executor.h" 36 36 #include "Debug.h" 37 37 #include "CoreIncludes.h" … … 41 41 42 42 43 #define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, loading) \ 44 XMLPortParamGeneric(classname, paramname, xmlcontainer##loadfunction##savefunction, createFunctor(&classname::loadfunction), createFunctor(&classname::savefunction), xmlelement, loading) 45 #define XMLPortParam_Template(classname, paramname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, loading) \ 46 XMLPortParamGeneric(classname, paramname, xmlcontainer##loadfunction##savefunction, createFunctor loadtemplate (&classname::loadfunction), createFunctor savetemplate (&classname::savefunction), xmlelement, loading) 47 48 49 #define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, loading) \ 50 XMLPortParamGeneric(classname, paramname, xmlcontainer##loadfunction##0, createFunctor(&classname::loadfunction), 0, xmlelement, loading) 51 #define XMLPortParamLoadOnly_Template(classname, paramname, loadtemplate, loadfunction, xmlelement, loading) \ 52 XMLPortParamGeneric(classname, paramname, xmlcontainer##loadfunction##0, createFunctor loadtemplate (&classname::loadfunction), 0, xmlelement, loading) 53 54 55 #define XMLPortParamGeneric(classname, paramname, containername, loadfunctor, savefunctor, xmlelement, loading) \ 43 #define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \ 44 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, createExecutor(createFunctor(&classname::loadfunction), #loadfunction), createExecutor(createFunctor(&classname::savefunction), #savefunction), xmlelement, mode) 45 #define XMLPortParam_Template(classname, paramname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, mode) \ 46 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, createExecutor(createFunctor loadtemplate (&classname::loadfunction), #loadfunction), createExecutor(createFunctor savetemplate (&classname::savefunction), #savefunction), xmlelement, mode) 47 48 #define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \ 49 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, createExecutor(createFunctor(&classname::loadfunction), #loadfunction), 0, xmlelement, mode) 50 #define XMLPortParamLoadOnly_Template(classname, paramname, loadtemplate, loadfunction, xmlelement, mode) \ 51 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, createExecutor(createFunctor loadtemplate (&classname::loadfunction), #loadfunction), 0, xmlelement, mode) 52 53 #define XMLPortParamGeneric(containername, classname, paramname, loadexecutor, saveexecutor, xmlelement, mode) \ 56 54 orxonox::XMLPortClassParamContainer<classname>* containername = (orxonox::XMLPortClassParamContainer<classname>*)(this->getIdentifier()->getXMLPortParamContainer(paramname)); \ 57 55 if (!containername) \ 58 56 { \ 59 containername = new orxonox::XMLPortClassParamContainer<classname>( this->getIdentifier()->getName(), std::string(paramname), loadfunctor, savefunctor); \57 containername = new orxonox::XMLPortClassParamContainer<classname>(std::string(paramname), loadexecutor, saveexecutor); \ 60 58 this->getIdentifier()->addXMLPortParamContainer(paramname, containername); \ 61 59 } \ 62 containername->port(this, xmlelement, loading) 63 64 65 #define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, loading, bApplyLoaderMask, bLoadBefore) \ 66 orxonox::XMLPortClassObjectContainer<classname, objectclass>* xmlcontainer##loadfunction##savefunction = (orxonox::XMLPortClassObjectContainer<classname, objectclass>*)(this->getIdentifier()->getXMLPortObjectContainer(sectionname)); \ 67 if (!xmlcontainer##loadfunction##savefunction) \ 60 containername->port(this, xmlelement, mode) 61 62 63 #define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \ 64 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, createExecutor(createFunctor(&classname::loadfunction), #loadfunction), createExecutor(createFunctor(&classname::savefunction), #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore) 65 #define XMLPortObject_Template(classname, objectclass, sectionname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \ 66 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, createExecutor(createFunctor loadtemplate (&classname::loadfunction), #loadfunction), createExecutor(createFunctor savetemplate (&classname::savefunction), #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore) 67 68 #define XMLPortObjectGeneric(containername, classname, objectclass, sectionname, loadexecutor, saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \ 69 orxonox::XMLPortClassObjectContainer<classname, objectclass>* containername = (orxonox::XMLPortClassObjectContainer<classname, objectclass>*)(this->getIdentifier()->getXMLPortObjectContainer(sectionname)); \ 70 if (!containername) \ 68 71 { \ 69 xmlcontainer##loadfunction##savefunction = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(this->getIdentifier()->getName(), std::string(sectionname), &classname::loadfunction, &classname::savefunction, bApplyLoaderMask, bLoadBefore); \70 this->getIdentifier()->addXMLPortObjectContainer(sectionname, xmlcontainer##loadfunction##savefunction); \72 containername = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(std::string(sectionname), loadexecutor, saveexecutor, bApplyLoaderMask, bLoadBefore); \ 73 this->getIdentifier()->addXMLPortObjectContainer(sectionname, containername); \ 71 74 } \ 72 xmlcontainer##loadfunction##savefunction->port(this, xmlelement, loading)75 containername->port(this, xmlelement, mode) 73 76 74 77 … … 93 96 class _CoreExport XMLPortParamContainer 94 97 { 98 enum ParseResult 99 { 100 PR_not_started, 101 PR_finished, 102 PR_waiting_for_default_values 103 }; 104 95 105 public: 96 XMLPortParamContainer(); 106 XMLPortParamContainer() 107 { this->parseResult_ = PR_not_started; } 108 virtual ~XMLPortParamContainer() {} 97 109 98 110 inline const std::string& getName() const 99 111 { return this->paramname_; } 100 112 101 XMLPortParamContainer& description(const std::string description); 102 const std::string& getDescription(); 113 virtual XMLPortParamContainer& description(const std::string description) = 0; 114 virtual const std::string& getDescription() = 0; 115 116 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiTypeMath& param) = 0; 117 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1) = 0; 118 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2) = 0; 119 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) = 0; 120 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) = 0; 121 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) = 0; 103 122 104 123 protected: 105 std::string classname_;106 124 std::string paramname_; 107 108 private: 109 LanguageEntryLabel description_; 110 bool bAddedDescription_; 111 bool bAddedDefaultValues_; 125 ParseResult parseResult_; 126 112 127 }; 113 128 … … 115 130 class XMLPortClassParamContainer : public XMLPortParamContainer 116 131 { 132 struct ParseParams 133 { 134 T* object; 135 Element* xmlelement; 136 XMLPort::Mode mode; 137 }; 138 117 139 public: 118 XMLPortClassParamContainer(const std::string classname, const std::string paramname, FunctorMember<T>* loadfunction, FunctorMember<T>* savefunction) 119 { 120 this->classname_ = classname; 140 XMLPortClassParamContainer(const std::string paramname, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor) 141 { 121 142 this->paramname_ = paramname; 122 this->loadfunction_ = loadfunction; 123 this->savefunction_ = savefunction; 143 this->loadexecutor_ = loadexecutor; 144 this->saveexecutor_ = saveexecutor; 145 146 this->setDefaultValue_[0] = false; 147 this->setDefaultValue_[1] = false; 148 this->setDefaultValue_[2] = false; 149 this->setDefaultValue_[3] = false; 150 this->setDefaultValue_[4] = false; 124 151 } 125 152 126 153 XMLPortParamContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode) 127 154 { 155 this->parseParams_.object = object; 156 this->parseParams_.xmlelement = &xmlelement; 157 this->parseParams_.mode = mode; 158 128 159 if (mode == XMLPort::LoadObject) 129 160 { … … 131 162 { 132 163 std::string attribute = xmlelement.GetAttribute(this->paramname_); 133 if ( attribute.size() > 0)164 if ((attribute.size() > 0) || (this->loadexecutor_->allDefaultValuesSet())) 134 165 { 135 SubString tokens(attribute, ",", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0'); 136 if ((unsigned int)tokens.size() >= (unsigned int)this->loadfunction_->getParamCount()) 137 { 138 COUT(5) << object->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->classname_ << " (objectname " << object->getName() << ") with "; 139 if (this->loadfunction_->getParamCount() == 1) 140 { 141 COUT(5) << "1 parameter (using whole string):" << std::endl; 142 COUT(5) << object->getLoaderIndentation() << " " << attribute << std::endl; 143 (*this->loadfunction_)(object, MultiTypeMath(attribute)); 144 } 145 else 146 { 147 COUT(5) << tokens.size() << " parameter (using MultiTypeMath)." << std::endl; 148 MultiTypeMath param1 = MT_null, param2 = MT_null, param3 = MT_null, param4 = MT_null, param5 = MT_null; 149 if (tokens.size() >= 1) param1 = tokens[0]; 150 if (tokens.size() >= 2) param2 = tokens[1]; 151 if (tokens.size() >= 3) param3 = tokens[2]; 152 if (tokens.size() >= 4) param4 = tokens[3]; 153 if (tokens.size() >= 5) param5 = tokens[4]; 154 COUT(5) << object->getLoaderIndentation() << " " << attribute << std::endl; 155 COUT(5) << object->getLoaderIndentation() << " " << param1 << ", " << param2 << ", " << param3 << ", " << param4 << ", " << param5 << std::endl; 156 157 (*this->loadfunction_)(object, param1, param2, param3, param4, param5); 158 } 159 } 166 COUT(5) << object->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << object->getIdentifier()->getName() << " (objectname " << object->getName() << ")." << std::endl << object->getLoaderIndentation(); 167 if (this->loadexecutor_->parse(object, attribute, ",")) 168 this->parseResult_ = PR_finished; 160 169 else 161 { 162 COUT(2) << object->getLoaderIndentation() << "Warning: Parameter \"" << this->paramname_ << "\" in \"" << this->classname_ << "\" (objectname: " << object->getName() << ") is incomplete and couln't be loaded." << std::endl; 163 } 170 this->parseResult_ = PR_waiting_for_default_values; 164 171 } 165 172 } … … 167 174 { 168 175 COUT(1) << std::endl; 169 COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->classname_<< "' (objectname: " << object->getName() << ") in " << object->getLevelfile() << ":" << std::endl;176 COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << object->getIdentifier()->getName() << "' (objectname: " << object->getName() << ") in " << object->getLevelfile() << ":" << std::endl; 170 177 COUT(1) << ex.what() << std::endl; 171 178 } … … 173 180 else 174 181 { 175 if (this->save function_)182 if (this->saveexecutor_) 176 183 { 177 184 // xmlelement.SetAttribute(this->paramname_, "..."); … … 182 189 } 183 190 191 XMLPortParamContainer& port(const ParseParams& parseParams) 192 { 193 return this->port(parseParams.object, *parseParams.xmlelement, parseParams.mode); 194 } 195 196 XMLPortParamContainer& portIfWaitingForDefaultValues(const ParseResult& result, const ParseParams& params) 197 { 198 if (result == PR_waiting_for_default_values) 199 return this->port(params); 200 else 201 return (*this); 202 } 203 204 virtual XMLPortParamContainer& description(const std::string description) 205 { this->loadexecutor_->setDescription(description); return (*this); } 206 virtual const std::string& getDescription() 207 { return this->loadexecutor_->getDescription(); } 208 209 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiTypeMath& param) 210 { 211 if (!this->setDefaultValue_[index]) 212 { 213 this->setDefaultValue_[index] = true; 214 this->loadexecutor_->setDefaultValue(index, param); 215 } 216 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 217 } 218 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1) 219 { 220 if (!this->setDefaultValue_[0]) 221 { 222 this->setDefaultValue_[0] = true; 223 this->loadexecutor_->setDefaultValues(param1); 224 } 225 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 226 } 227 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2) 228 { 229 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1])) 230 { 231 this->setDefaultValue_[0] = true; 232 this->setDefaultValue_[1] = true; 233 this->loadexecutor_->setDefaultValues(param1, param2); 234 } 235 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 236 } 237 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) 238 { 239 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1]) || (!this->setDefaultValue_[2])) 240 { 241 this->setDefaultValue_[0] = true; 242 this->setDefaultValue_[1] = true; 243 this->setDefaultValue_[3] = true; 244 this->loadexecutor_->setDefaultValues(param1, param2, param3); 245 } 246 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 247 } 248 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) 249 { 250 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1]) || (!this->setDefaultValue_[2]) || (!this->setDefaultValue_[3])) 251 { 252 this->setDefaultValue_[0] = true; 253 this->setDefaultValue_[1] = true; 254 this->setDefaultValue_[3] = true; 255 this->setDefaultValue_[4] = true; 256 this->loadexecutor_->setDefaultValues(param1, param2, param3, param4); 257 } 258 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 259 } 260 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) 261 { 262 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1]) || (!this->setDefaultValue_[2]) || (!this->setDefaultValue_[3]) || (!this->setDefaultValue_[4])) 263 { 264 this->setDefaultValue_[0] = true; 265 this->setDefaultValue_[1] = true; 266 this->setDefaultValue_[3] = true; 267 this->setDefaultValue_[4] = true; 268 this->setDefaultValue_[5] = true; 269 this->loadexecutor_->setDefaultValues(param1, param2, param3, param4, param5); 270 } 271 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 272 } 273 184 274 private: 185 FunctorMember<T>* loadfunction_; 186 FunctorMember<T>* savefunction_; 275 ExecutorMember<T>* loadexecutor_; 276 ExecutorMember<T>* saveexecutor_; 277 ParseParams parseParams_; 278 bool setDefaultValue_[5]; 187 279 }; 188 280 … … 194 286 { 195 287 public: 196 XMLPortObjectContainer(); 288 XMLPortObjectContainer() 289 { this->bApplyLoaderMask_ = false; } 290 virtual ~XMLPortObjectContainer() {} 197 291 198 292 inline const std::string& getName() const 199 293 { return this->sectionname_; } 200 294 201 XMLPortObjectContainer& description(const std::string description); 202 const std::string& getDescription(); 295 virtual XMLPortObjectContainer& description(const std::string description) = 0; 296 virtual const std::string& getDescription() = 0; 297 203 298 bool identifierIsIncludedInLoaderMask(const Identifier* identifier); 204 299 205 300 protected: 206 std::string classname_;207 301 std::string sectionname_; 208 302 bool bApplyLoaderMask_; 209 303 bool bLoadBefore_; 210 211 private:212 LanguageEntryLabel description_;213 bool bAddedDescription_;214 304 }; 215 305 … … 218 308 { 219 309 public: 220 XMLPortClassObjectContainer(const std::string classname, const std::string sectionname, void (T::*loadfunction)(O*), const O* (T::*savefunction)(unsigned int) const, bool bApplyLoaderMask, bool bLoadBefore) 221 { 222 this->classname_ = classname; 310 XMLPortClassObjectContainer(const std::string sectionname, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore) 311 { 223 312 this->sectionname_ = sectionname; 224 this->load function_ = loadfunction;225 this->save function_ = savefunction;313 this->loadexecutor_ = loadexecutor; 314 this->saveexecutor_ = saveexecutor; 226 315 this->bApplyLoaderMask_ = bApplyLoaderMask; 227 316 this->bLoadBefore_ = bLoadBefore; … … 252 341 { 253 342 COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl; 343 254 344 O* newObject = (O*)identifier->fabricate(); 255 345 newObject->setLoaderIndentation(object->getLoaderIndentation() + " "); 256 346 newObject->setLevel(object->getLevel()); 257 347 newObject->setNamespace(object->getNamespace()); 348 258 349 if (this->bLoadBefore_) 259 350 { 260 351 newObject->XMLPort(*child, XMLPort::LoadObject); 261 COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->classname_<< " (objectname " << object->getName() << ")" << std::endl;352 COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << object->getIdentifier()->getName() << " (objectname " << object->getName() << ")" << std::endl; 262 353 } 263 354 else 264 355 { 265 COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->classname_<< " (objectname " << object->getName() << ")" << std::endl;356 COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << object->getIdentifier()->getName() << " (objectname " << object->getName() << ")" << std::endl; 266 357 } 267 (*object.*this->loadfunction_)(newObject); 358 359 COUT(5) << object->getLoaderIndentation(); 360 (*this->loadexecutor_)(object, newObject); 361 268 362 if (!this->bLoadBefore_) 269 363 newObject->XMLPort(*child, XMLPort::LoadObject); 364 270 365 COUT(5) << object->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl; 271 366 } … … 286 381 { 287 382 COUT(1) << std::endl; 288 COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->classname_<< "' (objectname: " << object->getName() << ") in " << object->getLevelfile() << ":" << std::endl;383 COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << object->getIdentifier()->getName() << "' (objectname: " << object->getName() << ") in " << object->getLevelfile() << ":" << std::endl; 289 384 COUT(1) << ex.what() << std::endl; 290 385 } … … 297 392 } 298 393 394 virtual XMLPortObjectContainer& description(const std::string description) 395 { this->loadexecutor_->setDescription(description); return (*this); } 396 virtual const std::string& getDescription() 397 { return this->loadexecutor_->getDescription(); } 398 299 399 private: 300 void (T::*loadfunction_)(O*);301 const O* (T::*savefunction_)(unsigned int) const;400 ExecutorMember<T>* loadexecutor_; 401 ExecutorMember<T>* saveexecutor_; 302 402 }; 303 403 } -
code/branches/core2/src/util/Math.h
r871 r933 26 26 */ 27 27 28 #ifndef _ Math_H__29 #define _ Math_H__28 #ifndef _Util_Math_H__ 29 #define _Util_Math_H__ 30 30 31 31 #include <ostream> … … 146 146 } 147 147 148 #endif /* _ Math_H__ */148 #endif /* _Util_Math_H__ */ -
code/branches/core2/src/util/MultiTypeMath.cc
r925 r933 88 88 } 89 89 90 MultiTypeMath::operator orxonox::BaseObject*() const91 { return (this->type_ == MT_void) ? (orxonox::BaseObject*)this->value_.void_ : (orxonox::BaseObject*)ConvertValueAndReturn<MultiTypeMath, void*>(*this); }92 90 MultiTypeMath::operator void*() const 93 91 { return (this->type_ == MT_void) ? this->value_.void_ : ConvertValueAndReturn<MultiTypeMath, void*>(*this); } -
code/branches/core2/src/util/MultiTypeMath.h
r925 r933 91 91 bool operator!=(const MultiTypeMath& mtm) const; 92 92 93 virtual operator orxonox::BaseObject*() const;94 93 virtual operator void*() const; 95 94 virtual operator int() const; -
code/branches/core2/src/util/MultiTypePrimitive.cc
r925 r933 134 134 } 135 135 136 MultiTypePrimitive::operator orxonox::BaseObject*() const137 { return (this->type_ == MT_void) ? (orxonox::BaseObject*)this->value_.void_ : (orxonox::BaseObject*)ConvertValueAndReturn<MultiTypePrimitive, void*>(*this); }138 136 MultiTypePrimitive::operator void*() const 139 137 { return (this->type_ == MT_void) ? this->value_.void_ : ConvertValueAndReturn<MultiTypePrimitive, void*>(*this); } -
code/branches/core2/src/util/MultiTypePrimitive.h
r925 r933 105 105 bool operator!=(const MultiTypePrimitive& mtp) const; 106 106 107 virtual operator orxonox::BaseObject*() const; 107 template <class T> 108 operator T*() const 109 { return ((T*)this->value_.void_); } 108 110 virtual operator void*() const; 109 111 virtual operator int() const; -
code/branches/core2/src/util/MultiTypeString.cc
r931 r933 65 65 } 66 66 67 MultiTypeString::operator orxonox::BaseObject*() const68 { return (this->type_ == MT_void) ? (orxonox::BaseObject*)this->value_.void_ : (orxonox::BaseObject*)ConvertValueAndReturn<MultiTypeString, void*>(*this); }69 67 MultiTypeString::operator void*() const 70 68 { return (this->type_ == MT_void) ? this->value_.void_ : ConvertValueAndReturn<MultiTypeString, void*>(*this); } -
code/branches/core2/src/util/MultiTypeString.h
r925 r933 79 79 bool operator!=(const MultiTypeString& mts) const; 80 80 81 virtual operator orxonox::BaseObject*() const;82 81 virtual operator void*() const; 83 82 virtual operator int() const; -
code/branches/core2/src/util/String.h
r871 r933 26 26 */ 27 27 28 #ifndef _ String_H__29 #define _ String_H__28 #ifndef _Util_String_H__ 29 #define _Util_String_H__ 30 30 31 31 #include <string> … … 144 144 }; 145 145 146 #endif /* _ String_H__ */146 #endif /* _Util_String_H__ */
Note: See TracChangeset
for help on using the changeset viewer.