Changeset 1747 for code/trunk/src/core
- Timestamp:
- Sep 9, 2008, 4:25:52 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 9 deleted
- 47 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core3 (added) merged: 1573-1574,1583-1586,1591-1594,1596-1597,1603,1606-1607,1610-1611,1655,1658,1676-1679,1681-1685,1687,1716-1723,1725-1729,1736
- Property svn:mergeinfo changed
-
code/trunk/src/core/BaseObject.h
r1625 r1747 39 39 #include "CorePrereqs.h" 40 40 41 #include "Super.h" 42 #include "OrxonoxClass.h" 41 43 #include "util/XMLIncludes.h" 42 #include "OrxonoxClass.h"43 44 44 45 namespace orxonox … … 101 102 Namespace* namespace_; 102 103 }; 104 105 SUPER_FUNCTION(0, BaseObject, XMLPort, false); 106 SUPER_FUNCTION(2, BaseObject, changedActivity, false); 107 SUPER_FUNCTION(3, BaseObject, changedVisibility, false); 103 108 } 104 109 -
code/trunk/src/core/CMakeLists.txt
r1612 r1747 3 3 ConfigValueContainer.cc 4 4 Core.cc 5 Error.cc6 5 Language.cc 6 ObjectListBase.cc 7 7 OrxonoxClass.cc 8 OutputBuffer.cc9 OutputHandler.cc10 8 Script.cc 11 SignalHandler.cc12 9 13 10 # command -
code/trunk/src/core/ClassFactory.h
r1543 r1747 43 43 #include "Factory.h" 44 44 #include "Identifier.h" 45 #include " Debug.h"45 #include "util/Debug.h" 46 46 47 47 namespace orxonox … … 74 74 { 75 75 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl; 76 ClassIdentifier<T>::getIdentifier( )->addFactory(new ClassFactory<T>);76 ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>); 77 77 Factory::add(name, ClassIdentifier<T>::getIdentifier()); 78 78 -
code/trunk/src/core/ClassTreeMask.h
r1505 r1747 78 78 namespace orxonox 79 79 { 80 // ############################### 81 // ### ClassTreeMaskNode###82 // ############################### 80 // ################################### 81 // ### ClassTreeMaskNode ### 82 // ################################### 83 83 //! The ClassTreeMaskNode is a node in the internal tree of the ClassTreeMask, containing the rules of the mask. 84 84 /** … … 116 116 117 117 118 // ############################### 119 // ### ClassTreeMaskIterator###120 // ############################### 118 // ################################### 119 // ### ClassTreeMaskIterator ### 120 // ################################### 121 121 //! The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask, containing the rules. 122 122 /** … … 146 146 147 147 148 // ############################### 149 // ### ClassTreeMask###150 // ############################### 148 // ################################### 149 // ### ClassTreeMask ### 150 // ################################### 151 151 //! The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not. 152 152 /** … … 214 214 ClassTreeMaskNode* root_; //!< The root-node of the internal rule-tree, usually BaseObject 215 215 }; 216 217 218 // ################################### 219 // ### ClassTreeMaskObjectIterator ### 220 // ################################### 221 //! ... 222 /** 223 ... 224 */ 225 class _CoreExport ClassTreeMaskObjectIterator 226 { 227 }; 216 228 } 217 229 -
code/trunk/src/core/CommandEvaluation.cc
r1563 r1747 30 30 #include "ConsoleCommand.h" 31 31 #include "Identifier.h" 32 #include " Debug.h"32 #include "util/Debug.h" 33 33 #include "util/String.h" 34 34 … … 218 218 } 219 219 220 void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiType Mathparam)220 void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiType param) 221 221 { 222 222 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) … … 224 224 } 225 225 226 MultiType MathCommandEvaluation::getEvaluatedParameter(unsigned int index) const226 MultiType CommandEvaluation::getEvaluatedParameter(unsigned int index) const 227 227 { 228 228 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) … … 240 240 } 241 241 242 MultiType MathCommandEvaluation::getReturnvalue() const242 MultiType CommandEvaluation::getReturnvalue() const 243 243 { 244 244 if (this->function_) 245 245 return this->function_->getReturnvalue(); 246 246 247 return MultiType Math();247 return MultiType(); 248 248 } 249 249 … … 304 304 305 305 if (command->defaultValueSet(i)) 306 output += "=" + command->getDefaultValue(i). toString() + "]";306 output += "=" + command->getDefaultValue(i).getString() + "]"; 307 307 else 308 308 output += "}"; -
code/trunk/src/core/CommandEvaluation.h
r1505 r1747 37 37 #include "ArgumentCompletionListElement.h" 38 38 #include "util/SubString.h" 39 #include "util/MultiType Math.h"39 #include "util/MultiType.h" 40 40 41 41 namespace orxonox … … 81 81 { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; } 82 82 83 void setEvaluatedParameter(unsigned int index, MultiType Mathparam);84 MultiType MathgetEvaluatedParameter(unsigned int index) const;83 void setEvaluatedParameter(unsigned int index, MultiType param); 84 MultiType getEvaluatedParameter(unsigned int index) const; 85 85 86 86 bool hasReturnvalue() const; 87 MultiType MathgetReturnvalue() const;87 MultiType getReturnvalue() const; 88 88 89 89 private: … … 115 115 116 116 bool bEvaluatedParams_; 117 MultiType Mathparam_[5];117 MultiType param_[5]; 118 118 }; 119 119 } -
code/trunk/src/core/CommandExecutor.cc
r1505 r1747 31 31 #include "util/String.h" 32 32 #include "util/Convert.h" 33 #include "util/Debug.h" 33 34 #include "Identifier.h" 34 35 #include "Language.h" 35 #include "Debug.h"36 36 #include "TclBind.h" 37 37 -
code/trunk/src/core/ConfigFileManager.cc
r1543 r1747 38 38 namespace orxonox 39 39 { 40 SetConsoleCommandShortcutExtern(config). setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue());41 SetConsoleCommandShortcutExtern(tconfig). setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue());40 SetConsoleCommandShortcutExtern(config).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue()); 41 SetConsoleCommandShortcutExtern(tconfig).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue()); 42 42 SetConsoleCommandShortcutExtern(reloadConfig); 43 43 SetConsoleCommandShortcutExtern(cleanConfig); 44 SetConsoleCommandShortcutExtern(loadSettings). setArgumentCompleter(0, autocompletion::files());45 SetConsoleCommandShortcutExtern(loadKeybindings). setArgumentCompleter(0, autocompletion::files());44 SetConsoleCommandShortcutExtern(loadSettings).argumentCompleter(0, autocompletion::files()); 45 SetConsoleCommandShortcutExtern(loadKeybindings).argumentCompleter(0, autocompletion::files()); 46 46 47 47 bool config(const std::string& classname, const std::string& varname, const std::string& value) … … 71 71 void reloadConfig() 72 72 { 73 ConfigFileManager::get Singleton()->load();73 ConfigFileManager::getInstance()->load(); 74 74 } 75 75 76 76 void cleanConfig() 77 77 { 78 ConfigFileManager::get Singleton()->clean(false);78 ConfigFileManager::getInstance()->clean(false); 79 79 } 80 80 81 81 void loadSettings(const std::string& filename) 82 82 { 83 ConfigFileManager::get Singleton()->setFile(CFT_Settings, filename, false);83 ConfigFileManager::getInstance()->setFile(CFT_Settings, filename, false); 84 84 } 85 85 86 86 void loadKeybindings(const std::string& filename) 87 87 { 88 ConfigFileManager::get Singleton()->setFile(CFT_Keybindings, filename);88 ConfigFileManager::getInstance()->setFile(CFT_Keybindings, filename); 89 89 } 90 90 … … 327 327 file.close(); 328 328 329 COUT( 3) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;329 COUT(0) << "Loaded config file \"" << this->filename_ << "\"." << std::endl; 330 330 331 331 // Save the file in case something changed (like stripped whitespaces) … … 459 459 } 460 460 461 ConfigFileManager* ConfigFileManager::get Singleton()461 ConfigFileManager* ConfigFileManager::getInstance() 462 462 { 463 463 static ConfigFileManager instance; -
code/trunk/src/core/ConfigFileManager.h
r1505 r1747 258 258 { 259 259 public: 260 static ConfigFileManager* get Singleton();260 static ConfigFileManager* getInstance(); 261 261 262 262 void setFile(ConfigFileType type, const std::string& filename, bool bCreateIfNotExisting = true); -
code/trunk/src/core/ConfigValueContainer.cc
r1505 r1747 47 47 { 48 48 /** 49 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 50 @param type The type of the corresponding config-file 51 @param identifier The identifier of the class the variable belongs to 52 @param varname The name of the variable 53 @param defvalue The default-value 54 */ 55 ConfigValueContainer::ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const MultiTypeMath& defvalue) 49 @brief Initializes the ConfigValueContainer with defaultvalues. 50 */ 51 void ConfigValueContainer::init(ConfigFileType type, Identifier* identifier, const std::string& varname) 56 52 { 57 53 this->type_ = type; … … 59 55 this->sectionname_ = identifier->getName(); 60 56 this->varname_ = varname; 61 57 this->callback_ = 0; 58 this->bContainerIsNew_ = true; 59 this->bDoInitialCallback_ = false; 60 this->bAddedDescription_ = false; 61 } 62 63 /** 64 @brief Does some special initialization for single config-values. 65 */ 66 void ConfigValueContainer::initValue(const MultiType& defvalue) 67 { 62 68 this->value_ = defvalue; 63 this->bAddedDescription_ = false;64 69 this->bIsVector_ = false; 65 70 66 this->defvalueString_ = defvalue.toString();71 this->defvalueString_ = this->value_.getString(); 67 72 this->update(); 68 73 } 69 74 70 75 /** 71 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 72 @param type The type of the corresponding config-file 73 @param identifier The identifier of the class the variable belongs to 74 @param varname The name of the variable 75 @param defvalue The default-value 76 */ 77 ConfigValueContainer::ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<MultiTypeMath>& defvalue) 78 { 79 this->type_ = type; 80 this->identifier_ = identifier; 81 this->sectionname_ = identifier->getName(); 82 this->varname_ = varname; 83 84 this->valueVector_ = defvalue; 85 this->bAddedDescription_ = false; 76 @brief Does some special initialization for vector config-values. 77 */ 78 void ConfigValueContainer::initVector() 79 { 86 80 this->bIsVector_ = true; 87 81 88 if (defvalue.size() > 0) 89 { 90 this->value_ = defvalue[0]; 91 92 for (unsigned int i = 0; i < defvalue.size(); i++) 93 { 94 ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, defvalue[i].toString(), this->value_.isA(MT_string)); 95 this->defvalueStringVector_.push_back(defvalue[i].toString()); 96 } 97 98 this->update(); 99 } 82 for (unsigned int i = 0; i < this->valueVector_.size(); i++) 83 { 84 ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string)); 85 this->defvalueStringVector_.push_back(this->valueVector_[i]); 86 } 87 88 this->update(); 89 } 90 91 /** 92 @brief Destructor: Deletes the callback object if necessary. 93 */ 94 ConfigValueContainer::~ConfigValueContainer() 95 { 96 if (this->callback_) 97 delete this->callback_; 100 98 } 101 99 … … 105 103 @return True if the new value was successfully assigned 106 104 */ 107 bool ConfigValueContainer::set(const MultiType Math& input)108 { 109 if (this->bIsVector_) 110 { 111 return this->callFunctionWithIndex(&ConfigValueContainer::set, input .toString());105 bool ConfigValueContainer::set(const MultiType& input) 106 { 107 if (this->bIsVector_) 108 { 109 return this->callFunctionWithIndex(&ConfigValueContainer::set, input); 112 110 } 113 111 else … … 115 113 if (this->tset(input)) 116 114 { 117 ConfigFileManager::get Singleton()->setValue(this->type_, this->sectionname_, this->varname_, input.toString(), this->value_.isA(MT_string));115 ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_string)); 118 116 return true; 119 117 } … … 128 126 @return True if the new value was successfully assigned 129 127 */ 130 bool ConfigValueContainer::set(unsigned int index, const MultiType Math& input)128 bool ConfigValueContainer::set(unsigned int index, const MultiType& input) 131 129 { 132 130 if (this->bIsVector_) … … 134 132 if (this->tset(index, input)) 135 133 { 136 ConfigFileManager::get Singleton()->setValue(this->type_, this->sectionname_, this->varname_, index, input.toString(), this->value_.isA(MT_string));134 ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_string)); 137 135 return true; 138 136 } … … 150 148 @return True if the new value was successfully assigned 151 149 */ 152 bool ConfigValueContainer::tset(const MultiTypeMath& input) 153 { 154 if (this->bIsVector_) 155 { 156 return this->callFunctionWithIndex(&ConfigValueContainer::tset, input.toString()); 157 } 158 else 159 { 160 MultiTypeMath temp = this->value_; 161 if (temp.assimilate(input)) 162 { 163 this->value_ = temp; 164 if (this->identifier_) 165 this->identifier_->updateConfigValues(); 166 167 return true; 168 } 169 } 170 return false; 150 bool ConfigValueContainer::tset(const MultiType& input) 151 { 152 if (this->bIsVector_) 153 { 154 return this->callFunctionWithIndex(&ConfigValueContainer::tset, input); 155 return false; 156 } 157 else 158 { 159 this->value_ = input; 160 161 if (this->identifier_) 162 this->identifier_->updateConfigValues(); 163 164 return true; 165 } 171 166 } 172 167 … … 177 172 @return True if the new value was successfully assigned 178 173 */ 179 bool ConfigValueContainer::tset(unsigned int index, const MultiType Math& input)174 bool ConfigValueContainer::tset(unsigned int index, const MultiType& input) 180 175 { 181 176 if (this->bIsVector_) … … 191 186 for (unsigned int i = this->valueVector_.size(); i <= index; i++) 192 187 { 193 this->valueVector_.push_back(MultiType Math());188 this->valueVector_.push_back(MultiType()); 194 189 } 195 190 } 196 191 197 MultiTypeMath temp = this->value_; 198 if (temp.assimilate(input)) 199 { 200 this->valueVector_[index] = temp; 201 202 if (this->identifier_) 203 this->identifier_->updateConfigValues(); 204 205 return true; 206 } 192 this->valueVector_[index] = input; 193 194 if (this->identifier_) 195 this->identifier_->updateConfigValues(); 196 197 return true; 207 198 } 208 199 else 209 200 { 210 201 COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl; 211 }212 return false;202 return false; 203 } 213 204 } 214 205 … … 218 209 @return True if the new entry was successfully added 219 210 */ 220 bool ConfigValueContainer::add(const MultiType Math& input)211 bool ConfigValueContainer::add(const MultiType& input) 221 212 { 222 213 if (this->bIsVector_) … … 241 232 this->valueVector_.erase(this->valueVector_.begin() + index); 242 233 for (unsigned int i = index; i < this->valueVector_.size(); i++) 243 ConfigFileManager::get Singleton()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isA(MT_string));244 ConfigFileManager::get Singleton()->deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size());234 ConfigFileManager::getInstance()->setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string)); 235 ConfigFileManager::getInstance()->deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size()); 245 236 246 237 return true; … … 266 257 if (!this->set(i, this->defvalueStringVector_[i])) 267 258 success = false; 268 ConfigFileManager::get Singleton()->deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->defvalueStringVector_.size());259 ConfigFileManager::getInstance()->deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->defvalueStringVector_.size()); 269 260 return success; 270 261 } … … 277 268 { 278 269 if (!this->bIsVector_) 279 this->value_ .fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isA(MT_string)));270 this->value_ = ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_string)); 280 271 else 281 272 { 282 273 this->valueVector_.clear(); 283 for (unsigned int i = 0; i < ConfigFileManager::get Singleton()->getVectorSize(this->type_, this->sectionname_, this->varname_); i++)274 for (unsigned int i = 0; i < ConfigFileManager::getInstance()->getVectorSize(this->type_, this->sectionname_, this->varname_); i++) 284 275 { 285 276 if (i < this->defvalueStringVector_.size()) 286 277 { 287 this->value_ .fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isA(MT_string)));278 this->value_ = ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_string)); 288 279 } 289 280 else 290 281 { 291 this->value_ .fromString(ConfigFileManager::getSingleton()->getValue(this->type_, this->sectionname_, this->varname_, i, MultiTypeMath(), this->value_.isA(MT_string)));282 this->value_ = ConfigFileManager::getInstance()->getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_string)); 292 283 } 293 284 … … 303 294 @return The returnvalue of the functioncall 304 295 */ 305 bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType Math&), const std::string& input)296 bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input) 306 297 { 307 298 SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, '(', ')', false, '\0'); … … 335 326 @param description The description 336 327 */ 337 voidConfigValueContainer::description(const std::string& description)328 ConfigValueContainer& ConfigValueContainer::description(const std::string& description) 338 329 { 339 330 if (!this->bAddedDescription_) … … 343 334 this->bAddedDescription_ = true; 344 335 } 336 return (*this); 345 337 } 346 338 -
code/trunk/src/core/ConfigValueContainer.h
r1505 r1747 50 50 51 51 #include "util/Math.h" 52 #include "util/MultiType Math.h"52 #include "util/MultiType.h" 53 53 #include "ConfigFileManager.h" 54 54 55 55 namespace orxonox 56 56 { 57 class ConfigValueCallbackBase 58 { 59 public: 60 virtual void call(void* object) = 0; 61 inline virtual ~ConfigValueCallbackBase() {} 62 }; 63 64 template <class T> 65 class ConfigValueCallback: public ConfigValueCallbackBase 66 { 67 public: 68 inline ConfigValueCallback(void (T::*function) (void)) : function_(function) {} 69 inline virtual ~ConfigValueCallback() {} 70 inline virtual void call(void* object) 71 { (((T*)object)->*this->function_)(); } 72 73 private: 74 void (T::*function_) (void); 75 }; 76 77 57 78 //! The ConfigValuecontainer contains all needed informations about a configurable variable. 58 79 /** … … 74 95 { 75 96 public: 76 ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const MultiTypeMath& defvalue); 77 ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<MultiTypeMath>& defvalue); 78 79 /** @brief Returns the configured value. @param value This is only needed to determine the right type. @return The value */ 80 template <typename T> 81 inline ConfigValueContainer& getValue(T* value) 82 { this->value_.getValue(value); return *this; } 83 template <typename T> 84 inline ConfigValueContainer& getValue(std::vector<T>* value) 85 { 86 value->clear(); 87 for (unsigned int i = 0; i < this->valueVector_.size(); i++) 88 value->push_back(this->valueVector_[i]); 97 /** 98 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 99 @param type The type of the corresponding config-file 100 @param identifier The identifier of the class the variable belongs to 101 @param varname The name of the variable 102 @param defvalue The default-value 103 @param value Only needed do determine the right type. 104 */ 105 template <class D, class V> 106 ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const D& defvalue, const V& value) 107 { 108 this->init(type, identifier, varname); 109 this->initValue((V)defvalue); 110 } 111 112 /** 113 @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable. 114 @param type The type of the corresponding config-file 115 @param identifier The identifier of the class the variable belongs to 116 @param varname The name of the variable 117 @param defvalue The default-value 118 */ 119 template <class V> 120 ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<V>& defvalue) 121 { 122 this->init(type, identifier, varname); 123 124 this->value_ = V(); 125 for (unsigned int i = 0; i < defvalue.size(); i++) 126 this->valueVector_.push_back(MultiType(defvalue[i])); 127 128 this->initVector(); 129 } 130 131 ~ConfigValueContainer(); 132 133 /** 134 @brief Returns the configured value. 135 @param value A pointer to the variable to store the value. 136 @param object The object calling this function 137 @return The ConfigValueContainer 138 */ 139 template <typename T, class C> 140 ConfigValueContainer& getValue(T* value, C* object) 141 { 142 if ((this->callback_ && object) || this->bContainerIsNew_) 143 { 144 if (this->bContainerIsNew_) 145 this->bContainerIsNew_ = false; 146 147 T temp = *value; 148 this->value_.getValue(value); 149 if ((*value) != temp) 150 { 151 if (this->callback_ && object) 152 this->callback_->call(object); 153 else 154 this->bDoInitialCallback_ = true; 155 } 156 } 157 else 158 { 159 this->value_.getValue(value); 160 } 89 161 return *this; 90 162 } 91 163 92 template <typename T> 93 inline void setVectorType(const std::vector<T>& value) 94 { 95 this->value_ = T(); 96 this->update(); 97 } 98 164 /** 165 @brief Returns the configured vector. 166 @param value A pointer to the vector to store the values. 167 @param object The object calling this function 168 @return The ConfigValueContainer 169 */ 170 template <typename T, class C> 171 ConfigValueContainer& getValue(std::vector<T>* value, C* object) 172 { 173 if ((this->callback_ && object) || this->bContainerIsNew_) 174 { 175 if (this->bContainerIsNew_) 176 this->bContainerIsNew_ = false; 177 178 std::vector<T> temp = *value; 179 value->clear(); 180 for (unsigned int i = 0; i < this->valueVector_.size(); ++i) 181 value->push_back(this->valueVector_[i]); 182 183 if (value->size() != temp.size()) 184 { 185 if (this->callback_ && object) 186 this->callback_->call(object); 187 else 188 this->bDoInitialCallback_ = true; 189 } 190 else 191 { 192 for (unsigned int i = 0; i < value->size(); ++i) 193 { 194 if ((*value)[i] != temp[i]) 195 { 196 if (this->callback_ && object) 197 this->callback_->call(object); 198 else 199 this->bDoInitialCallback_ = true; 200 break; 201 } 202 } 203 } 204 } 205 else 206 { 207 value->clear(); 208 for (unsigned int i = 0; i < this->valueVector_.size(); ++i) 209 value->push_back(this->valueVector_[i]); 210 } 211 return *this; 212 } 213 214 /** @brief Returns the name of this container. */ 99 215 inline const std::string& getName() const 100 216 { return this->varname_; } 217 /** @brief Returns true if this config-value is a vector */ 101 218 inline bool isVector() const 102 219 { return this->bIsVector_; } 220 /** @brief Returns the vectors size (or zero if it's not a vector). */ 103 221 inline unsigned int getVectorSize() const 104 222 { return this->valueVector_.size(); } 105 223 106 voiddescription(const std::string& description);224 ConfigValueContainer& description(const std::string& description); 107 225 const std::string& getDescription() const; 108 226 109 bool set(const MultiTypeMath& input); 110 bool tset(const MultiTypeMath& input); 111 112 bool set(unsigned int index, const MultiTypeMath& input); 113 bool tset(unsigned int index, const MultiTypeMath& input); 114 bool add(const MultiTypeMath& input); 227 /** 228 @brief Adds a callback function, that gets called after getValue() if the newly assigned value differs from the old value of the variable. 229 @param object The object to call the function 230 @param function The callback function 231 */ 232 template <class T> 233 inline ConfigValueContainer& callback(T* object, void (T::*function) (void)) 234 { 235 if (!this->callback_) 236 { 237 this->callback_ = new ConfigValueCallback<T>(function); 238 239 if (this->bDoInitialCallback_) 240 { 241 this->bDoInitialCallback_ = false; 242 this->callback_->call(object); 243 } 244 } 245 246 return (*this); 247 } 248 249 bool set(const MultiType& input); 250 bool tset(const MultiType& input); 251 252 bool set(unsigned int index, const MultiType& input); 253 bool tset(unsigned int index, const MultiType& input); 254 bool add(const MultiType& input); 115 255 bool remove(unsigned int index); 116 256 … … 120 260 /** @brief Converts the config-value to a string. @return The string */ 121 261 inline std::string toString() const 122 { return this->value_ .toString(); }262 { return this->value_; } 123 263 /** @brief Returns the typename of the assigned config-value. @return The typename */ 124 264 inline std::string getTypename() const … … 126 266 127 267 private: 128 bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiTypeMath&), const std::string& input); 268 void init(ConfigFileType type, Identifier* identifier, const std::string& varname); 269 void initValue(const MultiType& defvalue); 270 void initVector(); 271 bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input); 129 272 130 273 bool bIsVector_; //!< True if the container contains a std::vector … … 137 280 std::vector<std::string> defvalueStringVector_; //!< A vector, containg the strings of the default-values in case we're storing a vector 138 281 139 MultiType Mathvalue_; //!< The value140 std::vector<MultiType Math>valueVector_; //!< A vector, containg the values in case we're storing a vector282 MultiType value_; //!< The value 283 std::vector<MultiType> valueVector_; //!< A vector, containg the values in case we're storing a vector 141 284 142 285 bool bAddedDescription_; //!< True if a description was added 143 286 LanguageEntryLabel description_; //!< The description 287 ConfigValueCallbackBase* callback_; //!< A callback function to call after getValue if the value changed 288 289 bool bContainerIsNew_; //!< True if it's the first time getValue() gets called 290 bool bDoInitialCallback_; //!< True if the callback should be called as soon as it gets created 144 291 }; 145 292 } -
code/trunk/src/core/ConfigValueIncludes.h
r1543 r1747 47 47 @param defvalue The default-value of the variable 48 48 */ 49 #define SetConfigValue(varname, defvalue) \ 50 orxonox::ConfigValueContainer* container##varname = this->getIdentifier()->getConfigValueContainer(#varname); \ 49 #define SetConfigValueGeneric(type, varname, defvalue) \ 50 static orxonox::Identifier* identifier##varname = this->getIdentifier(); \ 51 orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \ 51 52 if (!container##varname) \ 52 53 { \ 53 container##varname = new orxonox::ConfigValueContainer(CFT_Settings, this->getIdentifier(), #varname, varname = defvalue); \54 this->getIdentifier()->addConfigValueContainer(#varname, container##varname); \54 container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, defvalue, varname); \ 55 identifier##varname->addConfigValueContainer(#varname, container##varname); \ 55 56 } \ 56 container##varname->getValue(&varname )57 container##varname->getValue(&varname, this) 57 58 58 /** 59 @brief Assigns the value, defined in the config-file, to the variable (or the default-value, if there is no entry in the file). 60 @param classname name in which the config value should be stored 61 @param varname The name of the variable 62 @param defvalue The default-value of the variable 63 */ 64 #define SetConfigValueGeneric(classname, varname, defvalue) \ 65 orxonox::ConfigValueContainer* container##varname = ClassIdentifier<classname>::getIdentifier()->getConfigValueContainer(#varname); \ 66 if (!container##varname) \ 67 { \ 68 container##varname = new orxonox::ConfigValueContainer(CFT_Settings, ClassIdentifier<classname>::getIdentifier(), #varname, varname = defvalue); \ 69 ClassIdentifier<classname>::getIdentifier()->addConfigValueContainer(#varname, container##varname); \ 70 } \ 71 container##varname->getValue(&varname) 59 #define SetConfigValue(varname, defvalue) SetConfigValueGeneric(CFT_Settings, varname, defvalue) 60 #define SetKeybindingValue(varname, defvalue) SetConfigValueGeneric(CFT_Keybindings, varname, defvalue) 61 72 62 73 63 /** … … 76 66 @param defvalue The default-value 77 67 */ 78 #define SetConfigValueVector(varname, defvalue) \ 79 orxonox::ConfigValueContainer* container##varname = this->getIdentifier()->getConfigValueContainer(#varname); \ 68 #define SetConfigValueVectorGeneric(type, varname, defvalue) \ 69 static orxonox::Identifier* identifier##varname = this->getIdentifier(); \ 70 orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \ 80 71 if (!container##varname) \ 81 72 { \ 82 std::vector<MultiTypeMath> temp; \ 83 for (unsigned int i = 0; i < defvalue.size(); i++) \ 84 temp.push_back(MultiTypeMath(defvalue[i])); \ 85 container##varname = new orxonox::ConfigValueContainer(CFT_Settings, this->getIdentifier(), #varname, temp); \ 86 container##varname->setVectorType(varname); \ 87 this->getIdentifier()->addConfigValueContainer(#varname, container##varname); \ 73 container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, defvalue); \ 74 identifier##varname->addConfigValueContainer(#varname, container##varname); \ 88 75 } \ 89 container##varname->getValue(&varname) 76 container##varname->getValue(&varname, this) 77 78 #define SetConfigValueVector(varname, defvalue) SetConfigValueVectorGeneric(CFT_Settings, varname, defvalue) 79 #define SetKeybindingValueVector(varname, defvalue) SetConfigValueVectorGeneric(CFT_Keybindings, varname, defvalue) 80 90 81 91 82 /** … … 98 89 { \ 99 90 container##varname##reset->reset(); \ 100 container##varname##reset->getValue(&varname ); \91 container##varname##reset->getValue(&varname, this); \ 101 92 } \ 102 93 else \ … … 104 95 COUT(2) << "Warning: Couldn't reset config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \ 105 96 } 97 106 98 107 99 /** … … 115 107 { \ 116 108 container##varname##modify##modifier->modifier(__VA_ARGS__); \ 117 container##varname##modify##modifier->getValue(&varname ); \109 container##varname##modify##modifier->getValue(&varname, this); \ 118 110 } \ 119 111 else \ -
code/trunk/src/core/ConsoleCommand.cc
r1505 r1747 45 45 } 46 46 47 ConsoleCommand& ConsoleCommand:: setArgumentCompleter(unsigned int param, ArgumentCompleter* completer)47 ConsoleCommand& ConsoleCommand::argumentCompleter(unsigned int param, ArgumentCompleter* completer) 48 48 { 49 49 if (param < 5) -
code/trunk/src/core/ConsoleCommand.h
r1549 r1747 38 38 39 39 40 #define SetConsoleCommand(classname, function, bCreateShortcut) \ 41 SetConsoleCommandGeneric(classname##function##consolecommand__, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function), bCreateShortcut) 40 #define SetConsoleCommand(classname, function, bCreateShortcut) \ 41 SetConsoleCommandAliasMulti(classname, function, #function, 0, bCreateShortcut) 42 #define SetConsoleCommandAlias(classname, function, name, bCreateShortcut) \ 43 SetConsoleCommandAliasMulti(classname, function, name, 0, bCreateShortcut) 44 #define SetConsoleCommandAliasMulti(classname, function, name, number, bCreateShortcut) \ 45 SetConsoleCommandGeneric(classname##function##consolecommand__##number, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name), bCreateShortcut) 42 46 43 47 #define SetConsoleCommandGeneric(fakevariable, classname, command, bCreateShortcut) \ 44 orxonox::ConsoleCommand& fakevariable = orxonox::ClassIdentifier<classname>::getIdentifier( )->addConsoleCommand(command, bCreateShortcut)48 orxonox::ConsoleCommand& fakevariable = orxonox::ClassIdentifier<classname>::getIdentifier(#classname)->addConsoleCommand(command, bCreateShortcut) 45 49 46 50 47 51 #define SetConsoleCommandShortcut(classname, function) \ 48 SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function)) 52 SetConsoleCommandShortcutAliasMulti(classname, function, #function, 0) 53 #define SetConsoleCommandShortcutAlias(classname, function, name) \ 54 SetConsoleCommandShortcutAliasMulti(classname, function, name, 0) 55 #define SetConsoleCommandShortcutAliasMulti(classname, function, name, number) \ 56 SetConsoleCommandShortcutGeneric(function##consolecommand__##number, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name)) 49 57 50 58 #define SetConsoleCommandShortcutExtern(function) \ 51 SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&function), #function)) 59 SetConsoleCommandShortcutExternAliasMulti(function, #function, 0) 60 #define SetConsoleCommandShortcutExternAlias(function, name) \ 61 SetConsoleCommandShortcutExternAliasMulti(function, name, 0) 62 #define SetConsoleCommandShortcutExternAliasMulti(function, name, number) \ 63 SetConsoleCommandShortcutGeneric(function##consolecommand__##number, orxonox::createConsoleCommand(orxonox::createFunctor(&function), name)) 52 64 53 65 #define SetConsoleCommandShortcutGeneric(fakevariable, command) \ … … 75 87 ConsoleCommand(FunctorStatic* functor, const std::string& name = ""); 76 88 77 inline ConsoleCommand& setDescription(const std::string& description)89 inline ConsoleCommand& description(const std::string& description) 78 90 { this->ExecutorStatic::setDescription(description); return (*this); } 79 inline ConsoleCommand& setDescriptionParam(int param, const std::string& description)91 inline ConsoleCommand& descriptionParam(int param, const std::string& description) 80 92 { this->ExecutorStatic::setDescriptionParam(param, description); return (*this); } 81 inline ConsoleCommand& setDescriptionReturnvalue(const std::string& description)93 inline ConsoleCommand& descriptionReturnvalue(const std::string& description) 82 94 { this->ExecutorStatic::setDescriptionReturnvalue(description); return (*this); } 83 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1)95 inline ConsoleCommand& defaultValues(const MultiType& param1) 84 96 { this->ExecutorStatic::setDefaultValues(param1); return (*this); } 85 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)97 inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2) 86 98 { this->ExecutorStatic::setDefaultValues(param1, param2); return (*this); } 87 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)99 inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) 88 100 { this->ExecutorStatic::setDefaultValues(param1, param2, param3); return (*this); } 89 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)101 inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) 90 102 { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4); return (*this); } 91 inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)103 inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) 92 104 { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4, param5); return (*this); } 93 inline ConsoleCommand& setDefaultValue(unsigned int index, const MultiTypeMath& param)105 inline ConsoleCommand& defaultValue(unsigned int index, const MultiType& param) 94 106 { this->ExecutorStatic::setDefaultValue(index, param); return (*this); } 95 107 96 inline ConsoleCommand& setAccessLevel(AccessLevel::Level level)108 inline ConsoleCommand& accessLevel(AccessLevel::Level level) 97 109 { this->accessLevel_ = level; return (*this); } 98 110 inline AccessLevel::Level getAccessLevel() const 99 111 { return this->accessLevel_; } 100 112 101 ConsoleCommand& setArgumentCompleter(unsigned int param, ArgumentCompleter* completer);113 ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer); 102 114 ArgumentCompleter* getArgumentCompleter(unsigned int param) const; 103 115 … … 110 122 { return this->argumentList_.end(); } 111 123 112 inline ConsoleCommand& setKeybindMode(KeybindMode::Enum mode)124 inline ConsoleCommand& keybindMode(KeybindMode::Enum mode) 113 125 { this->keybindMode_ = mode; return *this; } 114 126 inline KeybindMode::Enum getKeybindMode() const 115 127 { return this->keybindMode_; } 116 128 117 inline ConsoleCommand& setAxisParamIndex(int index)129 inline ConsoleCommand& axisParamIndex(int index) 118 130 { this->axisParamIndex_ = index; return *this; } 119 131 inline int getAxisParamIndex() const 120 132 { return this->axisParamIndex_; } 121 133 122 inline ConsoleCommand& setIsAxisRelative(bool val)134 inline ConsoleCommand& isAxisRelative(bool val) 123 135 { this->bAxisRelative_ = val; return *this; } 124 136 inline int getIsAxisRelative() const -
code/trunk/src/core/ConsoleCommandCompilation.cc
r1505 r1747 29 29 #include "ConsoleCommandCompilation.h" 30 30 #include "ConsoleCommand.h" 31 #include " Debug.h"31 #include "util/Debug.h" 32 32 #include "util/ExprParser.h" 33 33 34 34 namespace orxonox 35 35 { 36 SetConsoleCommandShortcutExtern(source). setArgumentCompleter(0, autocompletion::files());36 SetConsoleCommandShortcutExtern(source).argumentCompleter(0, autocompletion::files()); 37 37 SetConsoleCommandShortcutExtern(echo); 38 38 SetConsoleCommandShortcutExtern(puts); 39 39 40 SetConsoleCommandShortcutExtern(read). setArgumentCompleter(0, autocompletion::files());41 SetConsoleCommandShortcutExtern(append). setArgumentCompleter(0, autocompletion::files());42 SetConsoleCommandShortcutExtern(write). setArgumentCompleter(0, autocompletion::files());40 SetConsoleCommandShortcutExtern(read).argumentCompleter(0, autocompletion::files()); 41 SetConsoleCommandShortcutExtern(append).argumentCompleter(0, autocompletion::files()); 42 SetConsoleCommandShortcutExtern(write).argumentCompleter(0, autocompletion::files()); 43 43 44 44 SetConsoleCommandShortcutExtern(calculate); -
code/trunk/src/core/Core.cc
r1535 r1747 96 96 void Core::setConfigValues() 97 97 { 98 SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console"); 99 SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile"); 100 SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell"); 101 98 SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged); 99 SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged); 100 SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged); 101 SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged); 102 } 103 104 /** 105 @brief Callback function if the debug level has changed. 106 */ 107 void Core::debugLevelChanged() 108 { 102 109 // softDebugLevel_ is the maximum of the 3 variables 103 110 this->softDebugLevel_ = this->softDebugLevelConsole_; … … 107 114 this->softDebugLevel_ = this->softDebugLevelShell_; 108 115 109 110 std::string temp = this->language_; 111 SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text"); 112 113 if (this->language_ != temp) 114 { 115 // Read the translation file after the language was configured 116 Language::getLanguage().readTranslatedLanguageFile(); 117 } 116 OutputHandler::setSoftDebugLevel(OutputHandler::LD_All, this->softDebugLevel_); 117 OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_); 118 OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_); 119 OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell, this->softDebugLevelShell_); 120 } 121 122 /** 123 @brief Callback function if the language has changed. 124 */ 125 void Core::languageChanged() 126 { 127 // Read the translation file after the language was configured 128 Language::getLanguage().readTranslatedLanguageFile(); 118 129 } 119 130 … … 158 169 else if (device == OutputHandler::LD_Shell) 159 170 Core::getInstance().softDebugLevelShell_ = level; 171 172 OutputHandler::setSoftDebugLevel(device, level); 160 173 } 161 174 } … … 199 212 } 200 213 } 201 202 /**203 @brief Returns the soft debug level, stored in the only existing instance of the DebugLevel class, configured in the config-file.204 @return The soft debug level205 */206 int getSoftDebugLevel()207 {208 return orxonox::Core::getSoftDebugLevel();209 } -
code/trunk/src/core/Core.h
r1535 r1747 41 41 42 42 #include "OrxonoxClass.h" 43 #include " OutputHandler.h"43 #include "util/OutputHandler.h" 44 44 45 45 namespace orxonox … … 52 52 static bool& isCreatingCoreSettings(); 53 53 void setConfigValues(); 54 void debugLevelChanged(); 55 void languageChanged(); 54 56 55 57 static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); -
code/trunk/src/core/CoreIncludes.h
r1543 r1747 46 46 #include "Factory.h" 47 47 #include "ClassFactory.h" 48 #include " Debug.h"48 #include "util/Debug.h" 49 49 50 50 … … 55 55 */ 56 56 #define InternRegisterObject(ClassName, bRootClass) \ 57 this->setIdentifier(orxonox::ClassIdentifier<ClassName>::getIdentifier()->registerClass(this->getParents(), #ClassName, bRootClass)); \ 58 if (orxonox::Identifier::isCreatingHierarchy() && this->getParents()) \ 59 this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \ 60 orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this); \ 57 this->setIdentifier(orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)); \ 61 58 if (orxonox::Identifier::isCreatingHierarchy()) \ 62 return 59 { \ 60 if (this->getParents()) \ 61 { \ 62 orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeClassHierarchy(this->getParents(), bRootClass); \ 63 this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \ 64 } \ 65 this->setConfigValues(); \ 66 return; \ 67 } \ 68 orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this) 63 69 64 70 /** -
code/trunk/src/core/CorePrereqs.h
r1543 r1747 62 62 // Forward declarations 63 63 //----------------------------------------------------------------------- 64 class SignalHandler;65 66 64 namespace orxonox 67 65 { … … 111 109 class ConsoleCommand; 112 110 class Core; 113 class Error;114 111 class Executor; 115 112 template <class T> … … 125 122 template <class T> 126 123 class Iterator; 124 class IteratorBase; 127 125 class Language; 128 126 class LanguageEntry; … … 130 128 class Loader; 131 129 class MetaObjectList; 132 template <class T>133 130 class MetaObjectListElement; 134 131 class Namespace; … … 136 133 template <class T> 137 134 class ObjectList; 135 class ObjectListBase; 136 class ObjectListBaseElement; 138 137 template <class T> 139 138 class ObjectListElement; 139 template <class T> 140 class ObjectListIterator; 140 141 class OrxonoxClass; 141 class OutputBuffer;142 class OutputBufferListener;143 class OutputHandler;144 142 class Shell; 145 143 class ShellListener; -
code/trunk/src/core/Executor.cc
r1625 r1747 66 66 } 67 67 68 bool Executor::evaluate(const std::string& params, MultiType Mathparam[5], const std::string& delimiter) const68 bool Executor::evaluate(const std::string& params, MultiType param[5], const std::string& delimiter) const 69 69 { 70 70 unsigned int paramCount = this->functor_->getParamCount(); … … 172 172 } 173 173 174 Executor& Executor::setDefaultValues(const MultiType Math& param1)175 { 176 this->defaultValue_[0] = param1; 177 this->bAddedDefaultValue_[0] = true; 178 179 return (*this); 180 } 181 182 Executor& Executor::setDefaultValues(const MultiType Math& param1, const MultiTypeMath& param2)183 { 184 this->defaultValue_[0] = param1; 185 this->bAddedDefaultValue_[0] = true; 186 this->defaultValue_[1] = param2; 187 this->bAddedDefaultValue_[1] = true; 188 189 return (*this); 190 } 191 192 Executor& Executor::setDefaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)174 Executor& Executor::setDefaultValues(const MultiType& param1) 175 { 176 this->defaultValue_[0] = param1; 177 this->bAddedDefaultValue_[0] = true; 178 179 return (*this); 180 } 181 182 Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2) 183 { 184 this->defaultValue_[0] = param1; 185 this->bAddedDefaultValue_[0] = true; 186 this->defaultValue_[1] = param2; 187 this->bAddedDefaultValue_[1] = true; 188 189 return (*this); 190 } 191 192 Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) 193 193 { 194 194 this->defaultValue_[0] = param1; … … 202 202 } 203 203 204 Executor& Executor::setDefaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)204 Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) 205 205 { 206 206 this->defaultValue_[0] = param1; … … 216 216 } 217 217 218 Executor& Executor::setDefaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)218 Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) 219 219 { 220 220 this->defaultValue_[0] = param1; … … 232 232 } 233 233 234 Executor& Executor::setDefaultValue(unsigned int index, const MultiType Math& param)234 Executor& Executor::setDefaultValue(unsigned int index, const MultiType& param) 235 235 { 236 236 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) -
code/trunk/src/core/Executor.h
r1505 r1747 37 37 #include "util/Math.h" 38 38 #include "Functor.h" 39 #include " Debug.h"39 #include "util/Debug.h" 40 40 41 41 … … 64 64 { \ 65 65 COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl; \ 66 EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) MultiType Math(params)); \66 EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) MultiType(params)); \ 67 67 } \ 68 68 else if (this->bAddedDefaultValue_[0]) \ … … 90 90 } \ 91 91 \ 92 MultiType Mathparam[MAX_FUNCTOR_ARGUMENTS]; \92 MultiType param[MAX_FUNCTOR_ARGUMENTS]; \ 93 93 COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens ("; \ 94 94 for (unsigned int i = 0; i < tokens.size() && i < MAX_FUNCTOR_ARGUMENTS; i++) \ … … 145 145 inline void operator()() const 146 146 { (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 147 inline void operator()(const MultiType Math& param1) const147 inline void operator()(const MultiType& param1) const 148 148 { (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 149 inline void operator()(const MultiType Math& param1, const MultiTypeMath& param2) const149 inline void operator()(const MultiType& param1, const MultiType& param2) const 150 150 { (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 151 inline void operator()(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const151 inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const 152 152 { (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); } 153 inline void operator()(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const153 inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const 154 154 { (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); } 155 inline void operator()(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) const155 inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const 156 156 { (*this->functor_)(param1, param2, param3, param4, param5); } 157 157 158 158 bool parse(const std::string& params, const std::string& delimiter = " ") const; 159 159 160 bool evaluate(const std::string& params, MultiType Mathparam[5], const std::string& delimiter = " ") const;160 bool evaluate(const std::string& params, MultiType param[5], const std::string& delimiter = " ") const; 161 161 162 162 Executor& setDescription(const std::string& description); … … 177 177 inline FunctionType getType() const 178 178 { return this->functor_->getType(); } 179 inline MultiType MathgetReturnvalue() const179 inline MultiType getReturnvalue() const 180 180 { return this->functor_->getReturnvalue(); } 181 181 inline std::string getTypenameParam(unsigned int param) const … … 189 189 { return this->name_; } 190 190 191 Executor& setDefaultValues(const MultiType Math& param1);192 Executor& setDefaultValues(const MultiType Math& param1, const MultiTypeMath& param2);193 Executor& setDefaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3);194 Executor& setDefaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4);195 Executor& setDefaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5);196 Executor& setDefaultValue(unsigned int index, const MultiType Math& param);197 198 inline MultiType MathgetDefaultValue(unsigned int index) const191 Executor& setDefaultValues(const MultiType& param1); 192 Executor& setDefaultValues(const MultiType& param1, const MultiType& param2); 193 Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3); 194 Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4); 195 Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5); 196 Executor& setDefaultValue(unsigned int index, const MultiType& param); 197 198 inline MultiType getDefaultValue(unsigned int index) const 199 199 { 200 200 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) … … 216 216 Functor* functor_; 217 217 std::string name_; 218 MultiType MathdefaultValue_[MAX_FUNCTOR_ARGUMENTS];218 MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS]; 219 219 bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS]; 220 220 … … 245 245 inline void operator()(T* object) const 246 246 { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 247 inline void operator()(T* object, const MultiType Math& param1) const247 inline void operator()(T* object, const MultiType& param1) const 248 248 { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 249 inline void operator()(T* object, const MultiType Math& param1, const MultiTypeMath& param2) const249 inline void operator()(T* object, const MultiType& param1, const MultiType& param2) const 250 250 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 251 inline void operator()(T* object, const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const251 inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const 252 252 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); } 253 inline void operator()(T* object, const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const253 inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const 254 254 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); } 255 inline void operator()(T* object, const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) const255 inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const 256 256 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); } 257 257 … … 259 259 inline void operator()(const T* object) const 260 260 { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 261 inline void operator()(const T* object, const MultiType Math& param1) const261 inline void operator()(const T* object, const MultiType& param1) const 262 262 { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 263 inline void operator()(const T* object, const MultiType Math& param1, const MultiTypeMath& param2) const263 inline void operator()(const T* object, const MultiType& param1, const MultiType& param2) const 264 264 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); } 265 inline void operator()(const T* object, const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) const265 inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const 266 266 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); } 267 inline void operator()(const T* object, const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) const267 inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const 268 268 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); } 269 inline void operator()(const T* object, const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) const269 inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const 270 270 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); } 271 271 -
code/trunk/src/core/Factory.cc
r1505 r1747 34 34 #include "Factory.h" 35 35 #include "Identifier.h" 36 #include "Debug.h"37 36 #include "BaseObject.h" 37 #include "util/Debug.h" 38 38 39 39 namespace orxonox -
code/trunk/src/core/Functor.h
r1505 r1747 33 33 #include "CorePrereqs.h" 34 34 35 #include "util/MultiType Math.h"36 #include " Debug.h"35 #include "util/MultiType.h" 36 #include "util/Debug.h" 37 37 38 38 #define MAX_FUNCTOR_ARGUMENTS 5 … … 69 69 CreateTypeToStringTemplate(long); 70 70 CreateTypeToStringTemplate(unsigned long); 71 CreateTypeToStringTemplate(long long); 72 CreateTypeToStringTemplate(unsigned long long); 71 73 CreateTypeToStringTemplate(float); 72 74 CreateTypeToStringTemplate(double); … … 80 82 CreateTypeToStringTemplate(Degree); 81 83 82 template <> \83 inline std::string typeToString<std::string>() { return "string"; } \84 template <> \85 inline std::string typeToString<std::string&>() { return "string"; } \86 template <> \87 inline std::string typeToString<const std::string>() { return "string"; } \88 template <> \84 template <> 85 inline std::string typeToString<std::string>() { return "string"; } 86 template <> 87 inline std::string typeToString<std::string&>() { return "string"; } 88 template <> 89 inline std::string typeToString<const std::string>() { return "string"; } 90 template <> 89 91 inline std::string typeToString<const std::string&>() { return "string"; } 90 92 … … 95 97 virtual ~Functor() {} 96 98 97 virtual void operator()(const MultiType Math& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;99 virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0; 98 100 99 101 inline unsigned int getParamCount() const { return this->numParams_; } 100 102 inline bool hasReturnvalue() const { return this->hasReturnValue_; } 101 103 inline FunctionType getType() const { return this->type_; } 102 inline MultiType MathgetReturnvalue() const { return this->returnedValue_; }104 inline MultiType getReturnvalue() const { return this->returnedValue_; } 103 105 104 106 std::string getTypenameParam(unsigned int param) const { return (param >= 0 && param < 5) ? this->typeParam_[param] : ""; } 105 107 std::string getTypenameReturnvalue() const { return this->typeReturnvalue_; } 106 108 107 virtual void evaluateParam(unsigned int index, MultiType Math& param) const = 0;109 virtual void evaluateParam(unsigned int index, MultiType& param) const = 0; 108 110 109 111 protected: … … 111 113 bool hasReturnValue_; 112 114 FunctionType type_; 113 MultiType MathreturnedValue_;115 MultiType returnedValue_; 114 116 115 117 std::string typeReturnvalue_; … … 121 123 public: 122 124 virtual ~FunctorStatic() {} 123 virtual void operator()(const MultiType Math& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;125 virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0; 124 126 }; 125 127 … … 136 138 virtual ~FunctorMember() {} 137 139 138 virtual void operator()(T* object, const MultiType Math& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;139 virtual void operator()(const T* object, const MultiType Math& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0;140 141 virtual void operator()(const MultiType Math& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null)140 virtual void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0; 141 virtual void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0; 142 143 virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) 142 144 { 143 145 if (this->bConstObject_) … … 284 286 #define FUNCTOR_EVALUATE_PARAM0 285 287 #define FUNCTOR_EVALUATE_PARAM1 \ 286 if (index == 0) { P1 temp = param; param = temp; }288 if (index == 0) { param.convert<P1>(); } 287 289 #define FUNCTOR_EVALUATE_PARAM2 \ 288 if (index == 0) { P1 temp = param; param = temp; } \289 else if (index == 1) { P2 temp = param; param = temp; }290 if (index == 0) { param.convert<P1>(); } \ 291 else if (index == 1) { param.convert<P2>(); } 290 292 #define FUNCTOR_EVALUATE_PARAM3 \ 291 if (index == 0) { P1 temp = param; param = temp; } \292 else if (index == 1) { P2 temp = param; param = temp; } \293 else if (index == 2) { P3 temp = param; param = temp; }293 if (index == 0) { param.convert<P1>(); } \ 294 else if (index == 1) { param.convert<P2>(); } \ 295 else if (index == 2) { param.convert<P3>(); } 294 296 #define FUNCTOR_EVALUATE_PARAM4 \ 295 if (index == 0) { P1 temp = param; param = temp; } \296 else if (index == 1) { P2 temp = param; param = temp; } \297 else if (index == 2) { P3 temp = param; param = temp; } \298 else if (index == 3) { P4 temp = param; param = temp; }297 if (index == 0) { param.convert<P1>(); } \ 298 else if (index == 1) { param.convert<P2>(); } \ 299 else if (index == 2) { param.convert<P3>(); } \ 300 else if (index == 3) { param.convert<P4>(); } 299 301 #define FUNCTOR_EVALUATE_PARAM5 \ 300 if (index == 0) { P1 temp = param; param = temp; } \301 else if (index == 1) { P2 temp = param; param = temp; } \302 else if (index == 2) { P3 temp = param; param = temp; } \303 else if (index == 3) { P4 temp = param; param = temp; } \304 else if (index == 4) { P5 temp = param; param = temp; }302 if (index == 0) { param.convert<P1>(); } \ 303 else if (index == 1) { param.convert<P2>(); } \ 304 else if (index == 2) { param.convert<P3>(); } \ 305 else if (index == 3) { param.convert<P4>(); } \ 306 else if (index == 4) { param.convert<P5>(); } 305 307 306 308 … … 324 326 } \ 325 327 \ 326 void operator()(const MultiType Math& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \328 void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \ 327 329 { \ 328 330 FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \ 329 331 } \ 330 332 \ 331 virtual void evaluateParam(unsigned int index, MultiType Math& param) const \333 virtual void evaluateParam(unsigned int index, MultiType& param) const \ 332 334 { \ 333 335 FUNCTOR_EVALUATE_PARAM(numparams); \ … … 362 364 } \ 363 365 \ 364 void operator()(T* object, const MultiType Math& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \366 void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \ 365 367 { \ 366 368 FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \ 367 369 } \ 368 370 \ 369 void operator()(const T* object, const MultiType Math& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \371 void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \ 370 372 { \ 371 373 COUT(1) << "An error occurred in Functor.h:" << std::endl; \ … … 373 375 } \ 374 376 \ 375 virtual void evaluateParam(unsigned int index, MultiType Math& param) const \377 virtual void evaluateParam(unsigned int index, MultiType& param) const \ 376 378 { \ 377 379 FUNCTOR_EVALUATE_PARAM(numparams); \ … … 395 397 } \ 396 398 \ 397 void operator()(T* object, const MultiType Math& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \399 void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \ 398 400 { \ 399 401 FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \ 400 402 } \ 401 403 \ 402 void operator()(const T* object, const MultiType Math& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) \404 void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \ 403 405 { \ 404 406 FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \ 405 407 } \ 406 408 \ 407 virtual void evaluateParam(unsigned int index, MultiType Math& param) const \409 virtual void evaluateParam(unsigned int index, MultiType& param) const \ 408 410 { \ 409 411 FUNCTOR_EVALUATE_PARAM(numparams); \ -
code/trunk/src/core/IRC.cc
r1505 r1747 39 39 namespace orxonox 40 40 { 41 SetConsoleCommand(IRC, say, true).setAccessLevel(AccessLevel::User); 42 SetConsoleCommand(IRC, msg, false).setAccessLevel(AccessLevel::User); 43 SetConsoleCommand(IRC, nick, false).setAccessLevel(AccessLevel::User); 44 45 IRC* instance_irc = &IRC::getInstance(); 41 SetConsoleCommand(IRC, say, true).accessLevel(AccessLevel::User); 42 SetConsoleCommand(IRC, msg, false).accessLevel(AccessLevel::User); 43 SetConsoleCommand(IRC, nick, false).accessLevel(AccessLevel::User); 46 44 47 45 IRC::IRC() -
code/trunk/src/core/Identifier.cc
r1543 r1747 37 37 38 38 #include "Factory.h" 39 #include "ConfigValueContainer.h" 39 40 #include "ConsoleCommand.h" 40 41 #include "CommandExecutor.h" 42 #include "XMLPort.h" 41 43 42 44 namespace orxonox … … 52 54 Identifier::Identifier() 53 55 { 56 this->objects_ = new ObjectListBase(this); 57 54 58 this->bCreatedOneObject_ = false; 59 this->bSetName_ = false; 55 60 this->factory_ = 0; 56 61 … … 73 78 delete this->children_; 74 79 delete this->directChildren_; 80 delete this->objects_; 81 82 if (this->factory_) 83 delete this->factory_; 84 85 for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it) 86 delete (it->second); 87 for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it) 88 delete (it->second); 89 for (std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it) 90 delete (it->second); 91 for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it) 92 delete (it->second); 75 93 } 76 94 … … 81 99 @return The identifier (unique instance) 82 100 */ 83 Identifier *Identifier::getIdentifier(std::string &name, Identifier *proposal)101 Identifier* Identifier::getIdentifierSingleton(const std::string& name, Identifier* proposal) 84 102 { 85 103 static std::map<std::string, Identifier*> identifiers; //!< The map to store all Identifiers. 86 104 std::map<std::string, Identifier*>::const_iterator it = identifiers.find(name); 87 if (it == identifiers.end()) 88 { 89 // there isn't an entry yet, put the proposal in it 105 106 if (it != identifiers.end()) 107 { 108 // There is already an entry: return it and delete the proposal 109 delete proposal; 110 return (*it).second; 111 } 112 else 113 { 114 // There is no entry: put the proposal into the map and return it 90 115 identifiers[name] = proposal; 91 } 92 else 93 { 94 // this happens when a template exists twice --> delete the proposal 95 delete proposal; 96 } 97 return identifiers[name]; 116 return proposal; 117 } 98 118 } 99 119 … … 139 159 // Tell the parent we're one of it's direct children 140 160 (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this); 161 162 // Create the super-function dependencies 163 (*it)->createSuperFunctionCaller(); 141 164 } 165 } 166 } 167 168 /** 169 @brief Destroys all Identifiers. Called when exiting the program. 170 */ 171 void Identifier::destroyAllIdentifiers() 172 { 173 for (std::map<std::string, Identifier*>::iterator it = Identifier::getIdentifierMapIntern().begin(); it != Identifier::getIdentifierMapIntern().end(); ++it) 174 delete (it->second); 175 } 176 177 /** 178 @brief Sets the name of the class. 179 @param name The name 180 */ 181 void Identifier::setName(const std::string& name) 182 { 183 if (!this->bSetName_) 184 { 185 this->name_ = name; 186 this->bSetName_ = true; 187 Identifier::getIdentifierMapIntern()[name] = this; 188 Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this; 142 189 } 143 190 } … … 258 305 { 259 306 COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << "." << std::endl; 307 delete (it->second); 260 308 } 261 309 … … 305 353 { 306 354 COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << "." << std::endl; 355 delete (it->second); 307 356 } 308 357 … … 343 392 else 344 393 return 0; 394 } 395 396 /** 397 @brief Returns a XMLPortParamContainer that loads a parameter of this class. 398 @param paramname The name of the parameter 399 @return The container 400 */ 401 XMLPortParamContainer* Identifier::getXMLPortParamContainer(const std::string& paramname) 402 { 403 std::map<std::string, XMLPortParamContainer*>::const_iterator it = xmlportParamContainers_.find(paramname); 404 if (it != xmlportParamContainers_.end()) 405 return ((*it).second); 406 else 407 return 0; 408 } 409 410 /** 411 @brief Adds a new XMLPortParamContainer that loads a parameter of this class. 412 @param paramname The name of the parameter 413 @param container The container 414 */ 415 void Identifier::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) 416 { 417 this->xmlportParamContainers_[paramname] = container; 418 } 419 420 /** 421 @brief Returns a XMLPortObjectContainer that attaches an object to this class. 422 @param sectionname The name of the section that contains the attachable objects 423 @return The container 424 */ 425 XMLPortObjectContainer* Identifier::getXMLPortObjectContainer(const std::string& sectionname) 426 { 427 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = xmlportObjectContainers_.find(sectionname); 428 if (it != xmlportObjectContainers_.end()) 429 return ((*it).second); 430 else 431 return 0; 432 } 433 434 /** 435 @brief Adds a new XMLPortObjectContainer that attaches an object to this class. 436 @param sectionname The name of the section that contains the attachable objects 437 @param container The container 438 */ 439 void Identifier::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) 440 { 441 this->xmlportObjectContainers_[sectionname] = container; 345 442 } 346 443 -
code/trunk/src/core/Identifier.h
r1639 r1747 62 62 #include <stdlib.h> 63 63 64 #include "ObjectList.h" 65 #include "Debug.h" 64 #include "MetaObjectList.h" 66 65 #include "Iterator.h" 67 #include "MetaObjectList.h" 66 #include "Super.h" 67 #include "util/Debug.h" 68 68 #include "util/String.h" 69 69 … … 91 91 { 92 92 template <class T> 93 friend class ClassIdentifier;94 95 template <class T>96 93 friend class SubclassIdentifier; 97 94 … … 110 107 bool isDirectParentOf(const Identifier* identifier) const; 111 108 112 virtual const ObjectList<BaseObject>* getObjectList() const = 0;113 114 virtual void updateConfigValues() const = 0;109 /** @brief Returns the list of all existing objects of this class. @return The list */ 110 inline ObjectListBase* getObjects() const 111 { return this->objects_; } 115 112 116 113 /** @brief Returns the name of the class the Identifier belongs to. @return The name */ 117 114 inline const std::string& getName() const { return this->name_; } 118 115 void setName(const std::string& name); 116 117 virtual void updateConfigValues(bool updateChildren = true) const = 0; 119 118 120 119 /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */ … … 210 209 ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname); 211 210 212 v irtual void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) = 0;213 virtual XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname) = 0;214 215 v irtual void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) = 0;216 virtual XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname) = 0;211 void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container); 212 XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname); 213 214 void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container); 215 XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname); 217 216 218 217 ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut); … … 221 220 222 221 protected: 222 Identifier(); 223 Identifier(const Identifier& identifier); // don't copy 224 virtual ~Identifier(); 225 226 void initialize(std::set<const Identifier*>* parents); 227 static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal); 228 229 virtual void createSuperFunctionCaller() const = 0; 230 223 231 /** @brief Returns the map that stores all Identifiers. @return The map */ 224 232 static std::map<std::string, Identifier*>& getIdentifierMapIntern(); … … 226 234 static std::map<std::string, Identifier*>& getLowercaseIdentifierMapIntern(); 227 235 228 private:229 Identifier();230 Identifier(const Identifier& identifier); // don't copy231 virtual ~Identifier();232 void initialize(std::set<const Identifier*>* parents);233 234 236 /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */ 235 237 inline std::set<const Identifier*>& getChildrenIntern() const { return (*this->children_); } … … 237 239 inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); } 238 240 241 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) 242 ObjectListBase* objects_; //!< The list of all objects of this class 243 244 private: 239 245 /** 240 246 @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. … … 255 261 } 256 262 257 static Identifier* getIdentifier(std::string &name, Identifier *proposal);263 static void destroyAllIdentifiers(); 258 264 259 265 std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to … … 263 269 std::set<const Identifier*>* directChildren_; //!< The direct children of the class the Identifier belongs to 264 270 271 bool bSetName_; //!< True if the name is set 265 272 std::string name_; //!< The name of the class the Identifier belongs to 266 267 273 BaseFactory* factory_; //!< The Factory, able to create new objects of the given class (if available) 268 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents)269 274 static int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading) 270 275 unsigned int classID_; //!< The network ID to identify a class through the network … … 277 282 std::map<std::string, ConsoleCommand*> consoleCommands_; //!< All console commands of this class 278 283 std::map<std::string, ConsoleCommand*> consoleCommands_LC_; //!< All console commands of this class with their names in lowercase 284 285 std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_; //!< All loadable parameters 286 std::map<std::string, XMLPortObjectContainer*> xmlportObjectContainers_; //!< All attachable objects 279 287 }; 280 288 … … 297 305 class ClassIdentifier : public Identifier 298 306 { 307 #define SUPER_INTRUSIVE_DECLARATION_INCLUDE 308 #include "Super.h" 309 299 310 public: 300 ClassIdentifier<T>* registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass); 311 static ClassIdentifier<T> *getIdentifier(); 312 static ClassIdentifier<T> *getIdentifier(const std::string& name); 313 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass); 314 static bool isFirstCall(); 301 315 void addObject(T* object); 302 void setName(const std::string& name); 303 /** @brief Returns the list of all existing objects of this class. @return The list */ 304 inline ObjectList<T>* getObjects() const { return this->objects_; } 305 /** @brief Returns a list of all existing objects of this class. @return The list */ 306 inline ObjectList<BaseObject>* getObjectList() const { return (ObjectList<BaseObject>*)this->objects_; } 307 308 void updateConfigValues() const; 309 310 XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname); 311 void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container); 312 313 XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname); 314 void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container); 315 316 static ClassIdentifier<T> *getIdentifier(); 316 317 void updateConfigValues(bool updateChildren = true) const; 317 318 318 319 private: 319 ClassIdentifier();320 320 ClassIdentifier(const ClassIdentifier<T>& identifier) {} // don't copy 321 ~ClassIdentifier() {} // don't delete 322 323 ObjectList<T>* objects_; //!< The ObjectList, containing all objects of type T 324 bool bSetName_; //!< True if the name is set 325 std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_; //!< All loadable parameters 326 std::map<std::string, XMLPortClassObjectContainer<T, class O>*> xmlportObjectContainers_; //!< All attachable objects 321 ClassIdentifier() 322 { 323 SuperFunctionInitialization<0, T>::initialize(this); 324 } 325 ~ClassIdentifier() 326 { 327 SuperFunctionDestruction<0, T>::destroy(this); 328 } 327 329 328 330 static ClassIdentifier<T> *classIdentifier_s; … … 333 335 334 336 /** 335 @brief Constructor: Creates the ObjectList.336 */337 template <class T>338 ClassIdentifier<T>::ClassIdentifier()339 {340 // this->objects_ = ObjectList<T>::getList();341 this->objects_ = new ObjectList<T>();342 this->bSetName_ = false;343 }344 345 /**346 337 @brief Registers a class, which means that the name and the parents get stored. 347 338 @param parents A list, containing the Identifiers of all parents of the class 348 @param name A string, containing exactly the name of the class349 339 @param bRootClass True if the class is either an Interface or the BaseObject itself 350 @return The ClassIdentifier itself 351 */ 352 template <class T> 353 ClassIdentifier<T>* ClassIdentifier<T>::registerClass(std::set<const Identifier*>* parents, const std::string& name, bool bRootClass) 354 { 355 this->setName(name); 356 340 */ 341 template <class T> 342 void ClassIdentifier<T>::initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass) 343 { 357 344 // Check if at least one object of the given type was created 358 345 if (!this->bCreatedOneObject_ && Identifier::isCreatingHierarchy()) 359 346 { 360 347 // If no: We have to store the informations and initialize the Identifier 361 COUT(4) << "*** ClassIdentifier: Register Class in " << name<< "-Singleton -> Initialize Singleton." << std::endl;348 COUT(4) << "*** ClassIdentifier: Register Class in " << this->getName() << "-Singleton -> Initialize Singleton." << std::endl; 362 349 if (bRootClass) 363 this->initialize( NULL); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case.350 this->initialize(0); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case. 364 351 else 365 352 this->initialize(parents); 366 353 } 367 368 return this;369 354 } 370 355 371 356 /** 372 @brief Creates the only instance of this class for the template class T and retrieves a unique Identifier for the given name. 357 @brief Returns true if the function gets called the first time, false otherwise. 358 @return True if this function got called the first time. 359 */ 360 template <class T> 361 bool ClassIdentifier<T>::isFirstCall() 362 { 363 static bool bFirstCall = true; 364 365 if (bFirstCall) 366 { 367 bFirstCall = false; 368 return true; 369 } 370 else 371 { 372 return false; 373 } 374 } 375 376 /** 377 @brief Returns the only instance of this class. 373 378 @return The unique Identifier 374 379 */ … … 377 382 { 378 383 // check if the static field has already been filled 379 if (ClassIdentifier<T>:: classIdentifier_s == 0)384 if (ClassIdentifier<T>::isFirstCall()) 380 385 { 381 386 // Get the name of the class … … 383 388 384 389 // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used. 385 ClassIdentifier<T> *proposal = new ClassIdentifier<T>();390 ClassIdentifier<T>* proposal = new ClassIdentifier<T>(); 386 391 387 392 // Get the entry from the map 388 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)Identifier::getIdentifier(name, proposal); 393 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)Identifier::getIdentifierSingleton(name, proposal); 394 395 if (ClassIdentifier<T>::classIdentifier_s == proposal) 396 { 397 COUT(4) << "*** Identifier: Requested Identifier for " << name << " was not yet existing and got created." << std::endl; 398 } 399 else 400 { 401 COUT(4) << "*** Identifier: Requested Identifier for " << name << " was already existing and got assigned." << std::endl; 402 } 389 403 } 390 404 … … 394 408 395 409 /** 396 @brief Sets the name of the class. 397 @param name The name 398 */ 399 template <class T> 400 void ClassIdentifier<T>::setName(const std::string& name) 401 { 402 if (!this->bSetName_) 403 { 404 this->name_ = name; 405 this->bSetName_ = true; 406 Identifier::getIdentifierMapIntern()[name] = this; 407 Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this; 408 } 410 @brief Does the same as getIdentifier() but sets the name if this wasn't done yet. 411 @param name The name of this Identifier 412 @return The Identifier 413 */ 414 template <class T> 415 ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name) 416 { 417 ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); 418 identifier->setName(name); 419 return identifier; 409 420 } 410 421 … … 417 428 { 418 429 COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl; 419 object->getMetaList().add(this->objects_, this->objects_->add( object));430 object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object))); 420 431 } 421 432 … … 424 435 */ 425 436 template <class T> 426 void ClassIdentifier<T>::updateConfigValues() const 427 { 428 for (Iterator<T> it = this->objects_->start(); it; ++it) 429 ((T*)*it)->setConfigValues(); 430 } 431 432 /** 433 @brief Returns a XMLPortParamContainer that loads a parameter of this class. 434 @param paramname The name of the parameter 435 @return The container 436 */ 437 template <class T> 438 XMLPortParamContainer* ClassIdentifier<T>::getXMLPortParamContainer(const std::string& paramname) 439 { 440 typename std::map<std::string, XMLPortClassParamContainer<T>*>::const_iterator it = xmlportParamContainers_.find(paramname); 441 if (it != xmlportParamContainers_.end()) 442 return (XMLPortParamContainer*)((*it).second); 443 else 444 return 0; 445 } 446 447 /** 448 @brief Adds a new XMLPortParamContainer that loads a parameter of this class. 449 @param paramname The name of the parameter 450 @param container The container 451 */ 452 template <class T> 453 void ClassIdentifier<T>::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) 454 { 455 this->xmlportParamContainers_[paramname] = (XMLPortClassParamContainer<T>*)container; 456 } 457 458 /** 459 @brief Returns a XMLPortObjectContainer that attaches an object to this class. 460 @param sectionname The name of the section that contains the attachable objects 461 @return The container 462 */ 463 template <class T> 464 XMLPortObjectContainer* ClassIdentifier<T>::getXMLPortObjectContainer(const std::string& sectionname) 465 { 466 typename std::map<std::string, XMLPortClassObjectContainer<T, class O>*>::const_iterator it = xmlportObjectContainers_.find(sectionname); 467 if (it != xmlportObjectContainers_.end()) 468 return (XMLPortObjectContainer*)((*it).second); 469 else 470 return 0; 471 } 472 473 /** 474 @brief Adds a new XMLPortObjectContainer that attaches an object to this class. 475 @param sectionname The name of the section that contains the attachable objects 476 @param container The container 477 */ 478 template <class T> 479 void ClassIdentifier<T>::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) 480 { 481 this->xmlportObjectContainers_[sectionname] = (XMLPortClassObjectContainer<T, class O>*)container; 437 void ClassIdentifier<T>::updateConfigValues(bool updateChildren) const 438 { 439 if (!this->hasConfigValues()) 440 return; 441 442 for (ObjectListIterator<T> it = ObjectList<T>::begin(); it; ++it) 443 it->setConfigValues(); 444 445 if (updateChildren) 446 for (std::set<const Identifier*>::const_iterator it = this->getChildrenBegin(); it != this->getChildrenEnd(); ++it) 447 (*it)->updateConfigValues(false); 482 448 } 483 449 -
code/trunk/src/core/Iterator.h
r1625 r1747 31 31 @brief Definition and implementation of the Iterator class. 32 32 33 The Iterator of a given class allows to iterate through an ObjectList , containing all objects of that type.34 This is the only way to access the objects stored in an ObjectList.33 The Iterator of a given class allows to iterate through an ObjectList. Objects in 34 this list are casted to the template argument of the Iterator. 35 35 36 36 Usage: 37 for (Iterator< class> it = ObjectList<class>::start(); it != 0; ++it)37 for (Iterator<myClass> it = anyidentifier->getObjects().begin(); it != anyidentifier->getObjects().end(); ++it) 38 38 { 39 39 it->someFunction(...); 40 class* myObject = *it;40 myClass* myObject = *it; 41 41 } 42 43 Warning: Don't delete objects directly through the iterator.44 42 */ 45 43 … … 49 47 #include "CorePrereqs.h" 50 48 51 #include "ObjectList.h" 49 #include "ObjectListBase.h" 50 #include "ObjectListIterator.h" 51 #include "OrxonoxClass.h" 52 52 53 53 namespace orxonox 54 54 { 55 //! The iterator allows to iterate through an ObjectList of a given class.56 template <class T >55 //! The Iterator allows to iterate through a given ObjectList 56 template <class T = OrxonoxClass> 57 57 class Iterator 58 58 { … … 61 61 @brief Constructor: Sets the element, whereon the iterator points, to zero. 62 62 */ 63 Iterator()63 inline Iterator() 64 64 { 65 65 this->element_ = 0; 66 ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this); 67 } 68 69 /** 70 @brief Constructor: Sets the element, whereon the iterator points, to a given element. 71 @param element The element to start with 72 */ 73 Iterator(ObjectListElement<T>* element) 74 { 75 this->element_ = element; 76 ClassIdentifier<T>::getIdentifier()->getObjects()->registerIterator(this); 66 this->list_ = 0; 67 } 68 69 /** 70 @brief Constructor: Sets this element to the exported element. 71 @param exp The exported element 72 */ 73 inline Iterator(const ObjectListBase::Export& exp) 74 { 75 this->element_ = exp.element_; 76 this->list_ = exp.list_; 77 this->iterator_ = this->list_->registerIterator(this); 78 } 79 80 /** 81 @brief Constructor: Sets this element to the element of another Iterator. 82 @param other The other Iterator 83 */ 84 inline Iterator(const Iterator<T>& other) 85 { 86 this->element_ = other.element_; 87 this->list_ = other.list_; 88 this->iterator_ = this->list_->registerIterator(this); 89 } 90 91 /** 92 @brief Constructor: Sets this element to a given element 93 @param element The element 94 */ 95 template <class O> 96 inline Iterator(ObjectListElement<O>* element) 97 { 98 this->element_ = (element) ? (ObjectListBaseElement*)element : 0; 99 this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects(); 100 this->iterator_ = this->list_->registerIterator(this); 101 } 102 103 /** 104 @brief Constructor: Sets this element to the element an ObjectListIterator. 105 @param other The ObjectListIterator 106 */ 107 template <class O> 108 inline Iterator(const ObjectListIterator<O>& other) 109 { 110 this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0; 111 this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects(); 112 this->iterator_ = this->list_->registerIterator(this); 77 113 } 78 114 … … 80 116 @brief Unregisters the Iterator from the ObjectList. 81 117 */ 82 ~Iterator() 83 { 84 ClassIdentifier<T>::getIdentifier()->getObjects()->unregisterIterator(this); 85 } 86 87 /** 88 @brief Assigns an element to the iterator. 118 inline ~Iterator() 119 { 120 this->list_->unregisterIterator(this->iterator_); 121 } 122 123 /** 124 @brief Assigns an exported element. 125 @param exp The exported element 126 */ 127 inline const Iterator<T>& operator=(const ObjectListBase::Export& exp) 128 { 129 if (this->list_) 130 this->list_->unregisterIterator(this->iterator_); 131 132 this->element_ = exp.element_; 133 this->list_ = exp.list_; 134 this->iterator_ = this->list_->registerIterator(this); 135 136 return (*this); 137 } 138 139 /** 140 @brief Assigns the element of another Iterator. 141 @param other The other Iterator 142 */ 143 inline const Iterator<T>& operator=(const Iterator<T>& other) 144 { 145 if (this->list_) 146 this->list_->unregisterIterator(this->iterator_); 147 148 this->element_ = other.element_; 149 this->list_ = other.list_; 150 this->iterator_ = this->list_->registerIterator(this); 151 152 return (*this); 153 } 154 155 /** 156 @brief Assigns a given element. 89 157 @param element The element 90 158 */ 91 Iterator<T> operator=(ObjectListElement<T>* element) 92 { 93 this->element_ = element; 159 template <class O> 160 inline const Iterator<T>& operator=(ObjectListElement<O>* element) 161 { 162 if (this->list_) 163 this->list_->unregisterIterator(this->iterator_); 164 165 this->element_ = (element) ? (ObjectListBaseElement*)element : 0; 166 this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects(); 167 this->iterator_ = this->list_->registerIterator(this); 168 169 return (*this); 94 170 return *this; 171 } 172 173 /** 174 @brief Assigns the element of an ObjectListIterator. 175 @param other The ObjectListIterator 176 */ 177 template <class O> 178 inline const Iterator<T>& operator=(const ObjectListIterator<O>& other) 179 { 180 if (this->list_) 181 this->list_->unregisterIterator(this->iterator_); 182 183 this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0; 184 this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects(); 185 this->iterator_ = this->list_->registerIterator(this); 186 187 return (*this); 95 188 } 96 189 … … 99 192 @return The Iterator itself 100 193 */ 101 Iterator<T>operator++()194 inline const Iterator<T>& operator++() 102 195 { 103 196 if (this->element_) … … 110 203 @return The Iterator itself 111 204 */ 112 Iterator<T> operator++(int i)205 inline Iterator<T> operator++(int i) 113 206 { 114 207 Iterator<T> copy = *this; … … 122 215 @return The Iterator itself 123 216 */ 124 Iterator<T>operator--()217 inline const Iterator<T>& operator--() 125 218 { 126 219 if (this->element_) … … 133 226 @return The Iterator itself 134 227 */ 135 Iterator<T> operator--(int i)228 inline Iterator<T> operator--(int i) 136 229 { 137 230 Iterator<T> copy = *this; … … 145 238 @return The object the Iterator points at 146 239 */ 147 T* operator*()148 { 149 if (this->element_) 150 return this->element_->object_;240 inline T* operator*() const 241 { 242 if (this->element_) 243 return dynamic_cast<T*>(this->element_->objectBase_); 151 244 else 152 245 return 0; … … 157 250 @return The object the Iterator points at 158 251 */ 159 T* operator->() const160 { 161 if (this->element_) 162 return this->element_->object_;252 inline T* operator->() const 253 { 254 if (this->element_) 255 return dynamic_cast<T*>(this->element_->objectBase_); 163 256 else 164 257 return 0; 165 166 258 } 167 259 168 260 /** 169 261 @brief Overloading of the typecast-operator to bool: returns true if the iterator points to an existing object. 170 @return True if the iterator points to an existing object.171 */ 172 operator bool()262 @return True if the Iterator points to an existing object. 263 */ 264 inline operator bool() const 173 265 { 174 266 return (this->element_ != 0); … … 176 268 177 269 /** 178 @brief Overloading of the (it != int) operator: Used for (it != 0) instead of typecast-operator to bool. 179 @param compare The integer (must be zero, everything else makes no sense). 180 @return True if the iterator points to an existing object. 181 */ 182 bool operator!=(ObjectListElement<T>* compare) 183 { 184 return (this->element_ != compare); 185 } 186 187 private: 188 ObjectListElement<T>* element_; //!< The element the Iterator points at 270 @brief Overloading of the == operator to compare with another Iterator. 271 @param compare The other Iterator 272 @return True if the iterators point to the same element 273 */ 274 inline bool operator==(const Iterator<T>& compare) const 275 { 276 return (this->element_ == compare.element_); 277 } 278 279 /** 280 @brief Overloading of the != operator to compare with another Iterator. 281 @param compare The other Iterator 282 @return True if the iterators point to different elements 283 */ 284 inline bool operator!=(const Iterator<T>& compare) const 285 { 286 return (this->element_ != compare.element_); 287 } 288 289 /** 290 @brief Increments the Iterator if it points at the given object. 291 @param object The object to compare with 292 */ 293 inline void incrementIfEqual(OrxonoxClass* object) 294 { 295 if (this->element_ && this->element_->objectBase_ == object) 296 this->operator++(); 297 } 298 299 protected: 300 ObjectListBaseElement* element_; //!< The element the Iterator points at 301 ObjectListBase* list_; //!< The list wherein the element is 302 std::list<void*>::iterator iterator_; //!< The iterator in the notifying list of the ObjectList 189 303 }; 304 305 typedef Iterator<OrxonoxClass> BaseIterator; 190 306 } 191 307 308 // Include ObjectList.h so the user only has to include one file: Iterator.h 309 #include "ObjectList.h" 310 192 311 #endif /* _Iterator_H__ */ -
code/trunk/src/core/Language.cc
r1535 r1747 37 37 38 38 #include "Core.h" 39 40 #include "Debug.h" 39 #include "util/Debug.h" 41 40 42 41 namespace orxonox … … 98 97 // Read the default language file to create all known LanguageEntry objects 99 98 this->readDefaultLanguageFile(); 99 } 100 101 /** 102 @brief Destructor: Deletes all language entries. 103 */ 104 Language::~Language() 105 { 106 for (std::map<std::string, LanguageEntry*>::iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it) 107 delete (it->second); 100 108 } 101 109 -
code/trunk/src/core/Language.h
r1535 r1747 123 123 Language(); 124 124 Language(const Language& language); // don't copy 125 virtual ~Language() {}; // don't delete125 virtual ~Language(); 126 126 127 127 void readDefaultLanguageFile(); -
code/trunk/src/core/Loader.cc
r1625 r1747 32 32 #include "Identifier.h" 33 33 #include "Iterator.h" 34 #include " Debug.h"34 #include "ObjectList.h" 35 35 #include "CoreIncludes.h" 36 36 #include "Script.h" 37 37 #include "Namespace.h" 38 #include "util/Debug.h" 38 39 39 40 #include "tinyxml/ticpp.h" … … 91 92 void Loader::unload(const ClassTreeMask& mask) 92 93 { 93 for ( Iterator<BaseObject> it = ObjectList<BaseObject>::begin(); it; )94 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ) 94 95 { 95 96 if (mask.isIncluded(it->getIdentifier())) … … 165 166 void Loader::unload(const Level* level, const ClassTreeMask& mask) 166 167 { 167 for ( Iterator<BaseObject>it = ObjectList<BaseObject>::begin(); it; )168 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ) 168 169 { 169 170 if ((it->getLevel() == level) && mask.isIncluded(it->getIdentifier())) -
code/trunk/src/core/MetaObjectList.cc
r1505 r1747 33 33 34 34 #include "MetaObjectList.h" 35 #include "ObjectListBase.h" 36 #include "Identifier.h" 37 #include "util/Debug.h" 35 38 36 39 namespace orxonox 37 40 { 41 // ############################### 42 // ### MetaObjectListElement ### 43 // ############################### 44 /** 45 @brief Destructor: Removes the ObjectListBaseElement from the ObjectListBase by linking next_ and prev_ of the ObjectListBaseElement. 46 */ 47 MetaObjectListElement::~MetaObjectListElement() 48 { 49 COUT(5) << "*** MetaObjectList: Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << std::endl; 50 this->list_->notifyIterators(this->element_->objectBase_); 51 52 if (this->element_->next_) 53 this->element_->next_->prev_ = this->element_->prev_; 54 else 55 this->list_->last_ = this->element_->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list 56 57 if (this->element_->prev_) 58 this->element_->prev_->next_ = this->element_->next_; 59 else 60 this->list_->first_ = this->element_->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list 61 62 delete this->element_; 63 } 64 65 66 // ############################### 67 // ### MetaObjectList ### 68 // ############################### 38 69 /** 39 70 @brief Constructor: Sets first_ to zero. … … 49 80 MetaObjectList::~MetaObjectList() 50 81 { 51 BaseMetaObjectListElement* temp;82 MetaObjectListElement* temp; 52 83 while (this->first_) 53 84 { … … 57 88 } 58 89 } 90 91 /** 92 @brief Adds an ObjectList and an element of that list to the MetaObjectList. 93 @param list The ObjectList wherein the element is 94 @param element The element wherein the object is 95 */ 96 void MetaObjectList::add(ObjectListBase* list, ObjectListBaseElement* element) 97 { 98 MetaObjectListElement* temp = this->first_; 99 this->first_ = new MetaObjectListElement(list, element); 100 this->first_->next_ = temp; 101 } 59 102 } -
code/trunk/src/core/MetaObjectList.h
r1543 r1747 41 41 #include "CorePrereqs.h" 42 42 43 #include "ObjectList.h"44 #include "Identifier.h"45 #include "Debug.h"46 47 43 namespace orxonox 48 44 { 49 //! Base-class of MetaObjectListElement, because those is a template50 class BaseMetaObjectListElement51 {52 public:53 /** @brief Default destructor */54 virtual ~BaseMetaObjectListElement() {};55 56 BaseMetaObjectListElement* next_; //!< The next Element in the list57 };58 59 45 // ############################### 60 46 // ### MetaObjectListElement ### 61 47 // ############################### 62 48 //! The list-element of the MetaObjectList 63 template <class T> 64 class MetaObjectListElement : public BaseMetaObjectListElement 49 class _CoreExport MetaObjectListElement 65 50 { 66 51 public: 67 MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element); 68 virtual ~MetaObjectListElement(); 52 /** 53 @brief Constructor: Creates the list-element with given list and element. 54 */ 55 MetaObjectListElement(ObjectListBase* list, ObjectListBaseElement* element) : next_(0), element_(element), list_(list) {} 56 ~MetaObjectListElement(); 69 57 70 ObjectListElement<T>* element_; //!< The list element, containing the object 71 ObjectList<T>* list_; //!< The list, containing the element 58 MetaObjectListElement* next_; //!< The next Element in the list 59 ObjectListBaseElement* element_; //!< The list element, containing the object 60 ObjectListBase* list_; //!< The list, containing the element 72 61 }; 73 74 /**75 @brief Constructor: Creates the list-element with given list and element.76 */77 template <class T>78 MetaObjectListElement<T>::MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element)79 {80 this->element_ = element;81 this->list_ = list;82 this->next_ = 0;83 }84 85 /**86 @brief Destructor: Removes the ObjectListElement from the ObjectList by linking next_ and prev_ of the ObjectListElement.87 */88 template <class T>89 MetaObjectListElement<T>::~MetaObjectListElement()90 {91 COUT(5) << "*** MetaObjectList: Removing Object from " << ClassIdentifier<T>::getIdentifier()->getName() << "-list." << std::endl;92 this->list_->notifyIterators(this->element_);93 94 if (this->element_->next_)95 this->element_->next_->prev_ = this->element_->prev_;96 else97 this->list_->last_ = this->element_->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list98 99 if (this->element_->prev_)100 this->element_->prev_->next_ = this->element_->next_;101 else102 this->list_->first_ = this->element_->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list103 104 delete this->element_;105 }106 62 107 63 … … 109 65 // ### MetaObjectList ### 110 66 // ############################### 111 //! The MetaObjectList contains ObjectList Elements and their ObjectLists.67 //! The MetaObjectList contains ObjectListBaseElements and their ObjectListBases. 112 68 /** 113 69 The MetaObjectList is a single-linked list, containing all list-elements and their … … 120 76 MetaObjectList(); 121 77 ~MetaObjectList(); 122 template <class T> 123 void add(ObjectList<T>* list, ObjectListElement<T>* element); 78 void add(ObjectListBase* list, ObjectListBaseElement* element); 124 79 125 BaseMetaObjectListElement* first_; //!< The first element in the list80 MetaObjectListElement* first_; //!< The first element in the list 126 81 }; 127 128 /**129 @brief Adds an ObjectList and an element of that list to the MetaObjectList.130 @param list The ObjectList wherein the element is131 @param element The element wherein the object is132 */133 template <class T>134 void MetaObjectList::add(ObjectList<T>* list, ObjectListElement<T>* element)135 {136 BaseMetaObjectListElement* temp = this->first_;137 this->first_ = new MetaObjectListElement<T>(list, element);138 this->first_->next_ = temp;139 }140 82 } 141 83 -
code/trunk/src/core/Namespace.cc
r1505 r1747 60 60 void Namespace::XMLPort(Element& xmlelement, XMLPort::Mode mode) 61 61 { 62 BaseObject::XMLPort(xmlelement, mode);62 SUPER(Namespace, XMLPort, xmlelement, mode); 63 63 64 64 std::string name = this->getName(); -
code/trunk/src/core/NamespaceNode.cc
r1505 r1747 28 28 29 29 #include "NamespaceNode.h" 30 #include " Debug.h"30 #include "util/Debug.h" 31 31 32 32 namespace orxonox -
code/trunk/src/core/ObjectList.h
r1543 r1747 31 31 @brief Definition and implementation of the ObjectList class. 32 32 33 The ObjectList is a double-linked list, used by Identifiers to store all objects of a given class. 34 Newly created objects are added through the RegisterObject-macro in its constructor. 33 The ObjectList is a wrapper of an ObjectListBase of a given class. 35 34 Use Iterator<class> to iterate through all objects of the class. 36 35 */ … … 39 38 #define _ObjectList_H__ 40 39 41 #include <set>42 43 40 #include "CorePrereqs.h" 44 41 45 #include "Iterator.h"46 42 #include "Identifier.h" 43 #include "ObjectListIterator.h" 47 44 48 45 namespace orxonox 49 46 { 50 47 // ############################### 51 // ### ObjectListElement ###52 // ###############################53 //! The list-element of the ObjectList54 template <class T>55 class ObjectListElement56 {57 public:58 ObjectListElement(T* object);59 60 T* object_; //!< The object61 ObjectListElement* next_; //!< The next element in the list62 ObjectListElement* prev_; //!< The previous element in the list63 };64 65 /**66 @brief Constructor: Creates the list-element with an object.67 @param object The object to store68 */69 template <class T>70 ObjectListElement<T>::ObjectListElement(T* object)71 {72 this->object_ = object;73 this->next_ = 0;74 this->prev_ = 0;75 }76 77 78 // ###############################79 48 // ### ObjectList ### 80 49 // ############################### 81 //! The ObjectList contains all objects of agiven class.50 //! The ObjectList contains all objects of the given class. 82 51 /** 83 The ObjectList is used by Identifiers to store all objects of a given class.84 Use Iterator<class> to iterate through all objects in the list.52 Wraps the ObjectListBase of the corresponding Identifier. 53 Use ObjectListIterator<class> to iterate through all objects in the list. 85 54 */ 86 55 template <class T> … … 88 57 { 89 58 public: 90 ObjectList(); 91 ~ObjectList(); 59 typedef ObjectListIterator<T> iterator; 92 60 93 ObjectListElement<T>* add(T* object); 61 /** @brief Returns an Iterator to the first element in the list. @return The Iterator */ 62 inline static ObjectListElement<T>* begin() 63 { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->begin().element_); } 94 64 95 /** @brief Returns the first element in the list. @return The first element*/96 inline static Iterator<T> start()97 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->first_); }65 /** @brief Returns an Iterator to the element after the last element in the list. @return The Iterator */ 66 inline static ObjectListElement<T>* end() 67 { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->end().element_); } 98 68 99 /** @brief Returns the first element in the list. @return The first element*/100 inline static Iterator<T>begin()101 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->first_); }69 /** @brief Returns an Iterator to the last element in the list. @return The Iterator */ 70 inline static ObjectListElement<T>* rbegin() 71 { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rbegin().element_); } 102 72 103 /** @brief Returns the last element in the list. @return The last element */ 104 inline static Iterator<T> end() 105 { return Iterator<T>(ClassIdentifier<T>::getIdentifier()->getObjects()->last_); } 106 107 inline void registerIterator(Iterator<T>* iterator) 108 { this->iterators_.insert(this->iterators_.end(), (void*)iterator); } 109 inline void unregisterIterator(Iterator<T>* iterator) 110 { this->iterators_.erase((void*)iterator); } 111 void notifyIterators(ObjectListElement<T>* element); 112 113 ObjectListElement<T>* first_; //!< The first element in the list 114 ObjectListElement<T>* last_; //!< The last element in the list 115 116 private: 117 std::set<void*> iterators_; //!< A list of iterators pointing on an element in this list 73 /** @brief Returns an Iterator to the element before the first element in the list. @return The Iterator */ 74 inline static ObjectListElement<T>* rend() 75 { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rend().element_); } 118 76 }; 119 120 /**121 @brief Constructor: Sets default values.122 */123 template <class T>124 ObjectList<T>::ObjectList()125 {126 this->first_ = 0;127 this->last_ = 0;128 }129 130 /**131 @brief Destructor: Deletes all list-elements, but NOT THE OBJECTS.132 */133 template <class T>134 ObjectList<T>::~ObjectList()135 {136 ObjectListElement<T>* temp;137 while (this->first_)138 {139 temp = this->first_->next_;140 delete this->first_;141 this->first_ = temp;142 }143 }144 145 /**146 @brief Increases all Iterators that currently point on the given element (because it gets removed).147 @param element The element that gets removed148 */149 template <class T>150 void ObjectList<T>::notifyIterators(ObjectListElement<T>* element)151 {152 for (std::set<void*>::iterator it = this->iterators_.begin(); it != this->iterators_.end(); ++it)153 if ((*(*((Iterator<T>*)(*it)))) == element->object_)154 ++(*((Iterator<T>*)(*it)));155 }156 157 /**158 @brief Adds a new object to the end of the list.159 @param object The object to add160 @return The pointer to the new ObjectListElement, needed by the MetaObjectList of the added object161 */162 template <class T>163 ObjectListElement<T>* ObjectList<T>::add(T* object)164 {165 if (!this->last_)166 {167 // If the list is empty168 this->last_ = new ObjectListElement<T>(object);169 this->first_ = this->last_; // There's only one object in the list now170 }171 else172 {173 // If the list isn't empty174 ObjectListElement<T>* temp = this->last_;175 this->last_ = new ObjectListElement<T>(object);176 this->last_->prev_ = temp;177 temp->next_ = this->last_;178 }179 180 return this->last_;181 }182 77 } 183 78 -
code/trunk/src/core/OrxonoxClass.cc
r1505 r1747 39 39 { 40 40 /** @brief Constructor: Sets the default values. */ 41 OrxonoxClass::OrxonoxClass() : 42 identifier_(0), 43 parents_(0) 41 OrxonoxClass::OrxonoxClass() 44 42 { 43 this->identifier_ = 0; 44 this->parents_ = 0; 45 45 this->metaList_ = new MetaObjectList(); 46 47 this->setConfigValues();48 46 } 49 47 -
code/trunk/src/core/Shell.cc
r1540 r1747 34 34 #include "ConsoleCommand.h" 35 35 #include "input/InputInterfaces.h" 36 #include "util/OutputHandler.h" 36 37 37 38 #define SHELL_UPDATE_LISTENERS(function) \ … … 43 44 SetConsoleCommand(Shell, clearShell, true); 44 45 SetConsoleCommand(Shell, history, true); 46 47 SetConsoleCommandShortcut(OutputHandler, log); 48 SetConsoleCommandShortcut(OutputHandler, error); 49 SetConsoleCommandShortcut(OutputHandler, warning); 50 SetConsoleCommandShortcut(OutputHandler, info); 51 SetConsoleCommandShortcut(OutputHandler, debug); 45 52 46 53 Shell::Shell() … … 61 68 62 69 this->outputBuffer_.registerListener(this); 70 OutputHandler::getOutStream().setOutputBuffer(this->outputBuffer_); 63 71 64 72 this->setConfigValues(); … … 82 90 void Shell::setConfigValues() 83 91 { 84 SetConfigValue(maxHistoryLength_, 100) ;85 SetConfigValue(historyOffset_, 0) ;92 SetConfigValue(maxHistoryLength_, 100).callback(this, &Shell::commandHistoryLengthChanged); 93 SetConfigValue(historyOffset_, 0).callback(this, &Shell::commandHistoryOffsetChanged); 86 94 SetConfigValueVector(commandHistory_, std::vector<std::string>()); 87 95 } 96 97 void Shell::commandHistoryOffsetChanged() 98 { 88 99 if (this->historyOffset_ >= this->maxHistoryLength_) 89 100 this->historyOffset_ = 0; 101 } 102 103 void Shell::commandHistoryLengthChanged() 104 { 105 this->commandHistoryOffsetChanged(); 90 106 91 107 while (this->commandHistory_.size() > this->maxHistoryLength_) -
code/trunk/src/core/Shell.h
r1535 r1747 37 37 #include "OrxonoxClass.h" 38 38 #include "input/InputBuffer.h" 39 #include " OutputBuffer.h"39 #include "util/OutputBuffer.h" 40 40 41 41 namespace orxonox … … 67 67 68 68 virtual void setConfigValues(); 69 void commandHistoryOffsetChanged(); 70 void commandHistoryLengthChanged(); 69 71 70 72 void registerListener(ShellListener* listener); -
code/trunk/src/core/TclBind.cc
r1505 r1747 32 32 #include "ConsoleCommand.h" 33 33 #include "CommandExecutor.h" 34 #include "Debug.h"35 34 #include "TclThreadManager.h" 36 35 #include "TclBind.h" 36 #include "util/Debug.h" 37 37 #include "util/String.h" 38 38 39 39 namespace orxonox 40 40 { 41 SetConsoleCommandShortcut Generic(tcl, createConsoleCommand(createFunctor(&TclBind::tcl), "tcl"));42 SetConsoleCommandShortcut Generic(bgerror, createConsoleCommand(createFunctor(&TclBind::bgerror), "bgerror"));41 SetConsoleCommandShortcut(TclBind, tcl); 42 SetConsoleCommandShortcut(TclBind, bgerror); 43 43 44 44 TclBind::TclBind() … … 115 115 116 116 if (CommandExecutor::getLastEvaluation().hasReturnvalue()) 117 return CommandExecutor::getLastEvaluation().getReturnvalue(). toString();117 return CommandExecutor::getLastEvaluation().getReturnvalue().getString(); 118 118 119 119 return ""; -
code/trunk/src/core/TclThreadManager.cc
r1505 r1747 38 38 #include "ConsoleCommand.h" 39 39 #include "CommandExecutor.h" 40 #include "Debug.h"41 40 #include "TclBind.h" 42 41 #include "TclThreadManager.h" 42 #include "util/Debug.h" 43 43 #include "util/Convert.h" 44 44 … … 48 48 namespace orxonox 49 49 { 50 SetConsoleCommandShortcut Generic(tclexecute, createConsoleCommand(createFunctor(&TclThreadManager::execute), "tclexecute")).setArgumentCompleter(0, autocompletion::tclthreads());51 SetConsoleCommandShortcut Generic(tclquery, createConsoleCommand(createFunctor(&TclThreadManager::query), "tclquery" )).setArgumentCompleter(0, autocompletion::tclthreads());50 SetConsoleCommandShortcutAlias(TclThreadManager, execute, "tclexecute").argumentCompleter(0, autocompletion::tclthreads()); 51 SetConsoleCommandShortcutAlias(TclThreadManager, query, "tclquery" ).argumentCompleter(0, autocompletion::tclthreads()); 52 52 SetConsoleCommand(TclThreadManager, create, false); 53 SetConsoleCommand(TclThreadManager, destroy, false). setArgumentCompleter(0, autocompletion::tclthreads());54 SetConsoleCommand(TclThreadManager, execute, false). setArgumentCompleter(0, autocompletion::tclthreads());55 SetConsoleCommand(TclThreadManager, query, false). setArgumentCompleter(0, autocompletion::tclthreads());53 SetConsoleCommand(TclThreadManager, destroy, false).argumentCompleter(0, autocompletion::tclthreads()); 54 SetConsoleCommand(TclThreadManager, execute, false).argumentCompleter(0, autocompletion::tclthreads()); 55 SetConsoleCommand(TclThreadManager, query, false).argumentCompleter(0, autocompletion::tclthreads()); 56 56 SetConsoleCommand(TclThreadManager, status, false); 57 SetConsoleCommand(TclThreadManager, dump, false).setArgumentCompleter(0, autocompletion::tclthreads()); 58 SetConsoleCommand(TclThreadManager, flush, false).setArgumentCompleter(0, autocompletion::tclthreads()); 59 60 TclThreadManager* instance_tclthreadmanager = &TclThreadManager::getInstance(); 57 SetConsoleCommand(TclThreadManager, dump, false).argumentCompleter(0, autocompletion::tclthreads()); 58 SetConsoleCommand(TclThreadManager, flush, false).argumentCompleter(0, autocompletion::tclthreads()); 61 59 62 60 TclThreadManager::TclThreadManager() … … 72 70 // 73 71 #endif 72 } 73 74 TclThreadManager::~TclThreadManager() 75 { 76 unsigned int threadID; 77 { 78 boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_); 79 if (this->interpreterBundles_.begin() == this->interpreterBundles_.end()) 80 return; 81 else 82 threadID = this->interpreterBundles_.begin()->first; 83 } 84 this->destroy(threadID); 74 85 } 75 86 … … 508 519 509 520 if (CommandExecutor::getLastEvaluation().hasReturnvalue()) 510 output = CommandExecutor::getLastEvaluation().getReturnvalue(). toString();521 output = CommandExecutor::getLastEvaluation().getReturnvalue().getString(); 511 522 } 512 523 -
code/trunk/src/core/TclThreadManager.h
r1625 r1747 69 69 class _CoreExport TclThreadManager : public OrxonoxClass 70 70 { 71 friend class IRC; 72 friend class TclBind; 73 71 74 public: 72 75 static TclThreadManager& getInstance(); … … 81 84 static void flush(unsigned int threadID); 82 85 86 void error(const std::string& error); 87 void debug(const std::string& error); 88 89 virtual void tick(float dt); 90 91 std::list<unsigned int> getThreadList() const; 92 93 private: 94 TclThreadManager(); 95 TclThreadManager(const TclThreadManager& other); 96 ~TclThreadManager(); 97 83 98 static void tcl_execute(Tcl::object const &args); 84 99 static std::string tcl_query(int querierID, Tcl::object const &args); … … 89 104 TclInterpreterBundle* getInterpreterBundle(unsigned int threadID); 90 105 std::string dumpList(const std::list<unsigned int>& list); 91 void error(const std::string& error);92 void debug(const std::string& error);93 106 94 107 void pushCommandToQueue(const std::string& command); … … 105 118 std::string evalQuery(unsigned int querierID, const std::string& command); 106 119 std::string evalQuery(unsigned int querierID, unsigned int threadID, const std::string& command); 107 108 virtual void tick(float dt);109 110 std::list<unsigned int> getThreadList() const;111 112 private:113 TclThreadManager();114 TclThreadManager(const TclThreadManager& other);115 ~TclThreadManager() {}116 120 117 121 unsigned int threadCounter_; -
code/trunk/src/core/XMLPort.h
r1628 r1747 32 32 #include "CorePrereqs.h" 33 33 34 #include "util/Debug.h" 34 35 #include "util/XMLIncludes.h" 35 #include "util/MultiType Math.h"36 #include "util/MultiType.h" 36 37 #include "tinyxml/ticpp.h" 37 38 #include "Executor.h" 38 #include "Debug.h"39 39 #include "CoreIncludes.h" 40 40 #include "BaseObject.h" … … 42 42 43 43 #define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \ 44 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::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, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::createFunctor savetemplate (&classname::savefunction),#savefunction), xmlelement, mode)44 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode) 45 #define XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, ...) \ 46 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode) 47 47 48 48 #define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \ 49 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), 0, xmlelement, mode) 50 #define XMLPortParamLoadOnly_Template(classname, paramname, loadtemplate, loadfunction, xmlelement, mode) \ 51 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), 0, xmlelement, mode) 52 53 #define XMLPortParamGeneric(containername, classname, paramname, loadexecutor, saveexecutor, xmlelement, mode) \ 54 orxonox::XMLPortClassParamContainer<classname>* containername = (orxonox::XMLPortClassParamContainer<classname>*)(this->getIdentifier()->getXMLPortParamContainer(paramname)); \ 49 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), 0, xmlelement, mode) 50 #define XMLPortParamLoadOnlyTemplate(classname, paramname, loadfunction, xmlelement, mode, ...) \ 51 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), 0, xmlelement, mode) 52 53 #define XMLPortParamExtern(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode) \ 54 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction), xmlelement, mode); 55 #define XMLPortParamExternTemplate(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode, ...) \ 56 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction), xmlelement, mode); 57 58 #define XMLPortParamGeneric(containername, classname, objectclass, object, paramname, loadexecutor, saveexecutor, xmlelement, mode) \ 59 orxonox::XMLPortClassParamContainer<objectclass>* containername = (orxonox::XMLPortClassParamContainer<objectclass>*)(ClassIdentifier<classname>::getIdentifier()->getXMLPortParamContainer(paramname)); \ 55 60 if (!containername) \ 56 61 { \ 57 containername = new orxonox::XMLPortClassParamContainer< classname>(std::string(paramname), loadexecutor, saveexecutor); \58 this->getIdentifier()->addXMLPortParamContainer(paramname, containername); \62 containername = new orxonox::XMLPortClassParamContainer<objectclass>(std::string(paramname), ClassIdentifier<classname>::getIdentifier(), loadexecutor, saveexecutor); \ 63 ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \ 59 64 } \ 60 containername->port( this, xmlelement, mode)65 containername->port((BaseObject*)this, object, xmlelement, mode) 61 66 62 67 63 68 #define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \ 64 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::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, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::createFunctor savetemplate (&classname::savefunction),#savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)69 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore) 70 #define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \ 71 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore) 67 72 68 73 #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)); \74 orxonox::XMLPortClassObjectContainer<classname, objectclass>* containername = (orxonox::XMLPortClassObjectContainer<classname, objectclass>*)(ClassIdentifier<classname>::getIdentifier()->getXMLPortObjectContainer(sectionname)); \ 70 75 if (!containername) \ 71 76 { \ 72 containername = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(std::string(sectionname), loadexecutor, saveexecutor, bApplyLoaderMask, bLoadBefore); \73 this->getIdentifier()->addXMLPortObjectContainer(sectionname, containername); \77 containername = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(std::string(sectionname), ClassIdentifier<classname>::getIdentifier(), loadexecutor, saveexecutor, bApplyLoaderMask, bLoadBefore); \ 78 ClassIdentifier<classname>::getIdentifier()->addXMLPortObjectContainer(sectionname, containername); \ 74 79 } \ 75 80 containername->port(this, xmlelement, mode) … … 102 107 virtual const std::string& getDescription() = 0; 103 108 104 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType Math& param) = 0;105 virtual XMLPortParamContainer& defaultValues(const MultiType Math& param1) = 0;106 virtual XMLPortParamContainer& defaultValues(const MultiType Math& param1, const MultiTypeMath& param2) = 0;107 virtual XMLPortParamContainer& defaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) = 0;108 virtual XMLPortParamContainer& defaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) = 0;109 virtual XMLPortParamContainer& defaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) = 0;109 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) = 0; 110 virtual XMLPortParamContainer& defaultValues(const MultiType& param1) = 0; 111 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2) = 0; 112 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) = 0; 113 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) = 0; 114 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) = 0; 110 115 111 116 protected: 112 117 std::string paramname_; 113 118 ParseResult parseResult_; 114 119 Identifier* identifier_; 120 BaseObject* owner_; 115 121 }; 116 122 … … 126 132 127 133 public: 128 XMLPortClassParamContainer(const std::string paramname, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)134 XMLPortClassParamContainer(const std::string paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor) 129 135 { 130 136 this->paramname_ = paramname; 137 this->identifier_ = identifier; 131 138 this->loadexecutor_ = loadexecutor; 132 139 this->saveexecutor_ = saveexecutor; 133 140 } 134 141 135 XMLPortParamContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode) 136 { 142 XMLPortParamContainer& port(BaseObject* owner, T* object, Element& xmlelement, XMLPort::Mode mode) 143 { 144 this->owner_ = owner; 137 145 this->parseParams_.object = object; 138 146 this->parseParams_.xmlelement = &xmlelement; … … 146 154 if ((attribute.size() > 0) || (this->loadexecutor_->allDefaultValuesSet())) 147 155 { 148 COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << object->getIdentifier()->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")." << std::endl << ((BaseObject*)object)->getLoaderIndentation();156 COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation(); 149 157 if (this->loadexecutor_->parse(object, attribute, ",")) 150 158 this->parseResult_ = PR_finished; … … 158 166 { 159 167 COUT(1) << std::endl; 160 COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << object->getIdentifier()->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << ((BaseObject*)object)->getLevelfile() << ":" << std::endl;168 COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getLevelfile() << ":" << std::endl; 161 169 COUT(1) << ex.what() << std::endl; 162 170 } … … 173 181 } 174 182 175 XMLPortParamContainer& port( const ParseParams& parseParams)176 { 177 return this->port( parseParams.object, *parseParams.xmlelement, parseParams.mode);183 XMLPortParamContainer& port(BaseObject* owner, const ParseParams& parseParams) 184 { 185 return this->port(owner, parseParams.object, *parseParams.xmlelement, parseParams.mode); 178 186 } 179 187 … … 181 189 { 182 190 if (result == PR_waiting_for_default_values) 183 return this->port( params);191 return this->port(this->owner_, params); 184 192 else 185 193 return (*this); … … 191 199 { return this->loadexecutor_->getDescription(); } 192 200 193 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType Math& param)201 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) 194 202 { 195 203 if (!this->loadexecutor_->defaultValueSet(index)) … … 197 205 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 198 206 } 199 virtual XMLPortParamContainer& defaultValues(const MultiType Math& param1)207 virtual XMLPortParamContainer& defaultValues(const MultiType& param1) 200 208 { 201 209 if (!this->loadexecutor_->defaultValueSet(0)) … … 203 211 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 204 212 } 205 virtual XMLPortParamContainer& defaultValues(const MultiType Math& param1, const MultiTypeMath& param2)213 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2) 206 214 { 207 215 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1))) … … 209 217 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 210 218 } 211 virtual XMLPortParamContainer& defaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)219 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) 212 220 { 213 221 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2))) … … 215 223 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 216 224 } 217 virtual XMLPortParamContainer& defaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)225 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) 218 226 { 219 227 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3))) … … 221 229 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 222 230 } 223 virtual XMLPortParamContainer& defaultValues(const MultiType Math& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)231 virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) 224 232 { 225 233 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)) || (!this->loadexecutor_->defaultValueSet(4))) … … 257 265 bool bApplyLoaderMask_; 258 266 bool bLoadBefore_; 267 Identifier* identifier_; 259 268 }; 260 269 … … 263 272 { 264 273 public: 265 XMLPortClassObjectContainer(const std::string sectionname, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)274 XMLPortClassObjectContainer(const std::string sectionname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore) 266 275 { 267 276 this->sectionname_ = sectionname; 277 this->identifier_ = identifier; 268 278 this->loadexecutor_ = loadexecutor; 269 279 this->saveexecutor_ = saveexecutor; … … 305 315 { 306 316 newObject->XMLPort(*child, XMLPort::LoadObject); 307 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << object->getIdentifier()->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;317 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 308 318 } 309 319 else 310 320 { 311 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << object->getIdentifier()->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;321 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 312 322 } 313 323 … … 336 346 { 337 347 COUT(1) << std::endl; 338 COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << object->getIdentifier()->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->getLevelfile() << ":" << std::endl;348 COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->getLevelfile() << ":" << std::endl; 339 349 COUT(1) << ex.what() << std::endl; 340 350 } -
code/trunk/src/core/input/Button.cc
r1535 r1747 36 36 #include "util/SubString.h" 37 37 #include "util/String.h" 38 #include " core/Debug.h"38 #include "util/Debug.h" 39 39 #include "core/ConsoleCommand.h" 40 40 #include "core/CommandEvaluation.h" -
code/trunk/src/core/input/InputManager.cc
r1735 r1747 39 39 #include "core/CoreIncludes.h" 40 40 #include "core/ConfigValueIncludes.h" 41 #include "core/Debug.h"42 41 #include "core/CommandExecutor.h" 43 42 #include "core/ConsoleCommand.h" 44 43 #include "core/Shell.h" // hack! 44 #include "util/Debug.h" 45 45 46 46 #include "InputBuffer.h" … … 321 321 if (joySticksSize_) 322 322 { 323 std::vector< MultiTypeMath> coeffPos;324 std::vector< MultiTypeMath> coeffNeg;325 std::vector< MultiTypeMath> zero;323 std::vector<double> coeffPos; 324 std::vector<double> coeffNeg; 325 std::vector<int> zero; 326 326 coeffPos.resize(24); 327 327 coeffNeg.resize(24); … … 340 340 getIdentifier()->addConfigValueContainer("CoeffPos", cont); 341 341 } 342 cont->getValue(&coeffPos );342 cont->getValue(&coeffPos, this); 343 343 344 344 cont = getIdentifier()->getConfigValueContainer("CoeffNeg"); … … 348 348 getIdentifier()->addConfigValueContainer("CoeffNeg", cont); 349 349 } 350 cont->getValue(&coeffNeg );350 cont->getValue(&coeffNeg, this); 351 351 352 352 cont = getIdentifier()->getConfigValueContainer("Zero"); … … 356 356 getIdentifier()->addConfigValueContainer("Zero", cont); 357 357 } 358 cont->getValue(&zero );358 cont->getValue(&zero, this); 359 359 360 360 // copy values to our own variables -
code/trunk/src/core/input/KeyBinder.cc
r1567 r1747 36 36 #include <string> 37 37 #include "util/Convert.h" 38 #include " core/Debug.h"38 #include "util/Debug.h" 39 39 #include "core/ConfigValueIncludes.h" 40 40 #include "core/CoreIncludes.h" … … 216 216 if (!infile) 217 217 { 218 ConfigFileManager::get Singleton()->setFile(CFT_Keybindings, "def_keybindings.ini");219 ConfigFileManager::get Singleton()->save(CFT_Keybindings, "keybindings.ini");218 ConfigFileManager::getInstance()->setFile(CFT_Keybindings, "def_keybindings.ini"); 219 ConfigFileManager::getInstance()->save(CFT_Keybindings, "keybindings.ini"); 220 220 } 221 221 else 222 222 infile.close(); 223 ConfigFileManager::get Singleton()->setFile(CFT_Keybindings, "keybindings.ini");223 ConfigFileManager::getInstance()->setFile(CFT_Keybindings, "keybindings.ini"); 224 224 225 225 // parse key bindings … … 234 234 void KeyBinder::setConfigValues() 235 235 { 236 SetConfigValue Generic(KeyBinder,analogThreshold_, 0.05f) .description("Threshold for analog axes until which the state is 0.");237 SetConfigValue Generic(KeyBinder,mouseSensitivity_, 1.0f) .description("Mouse sensitivity.");238 SetConfigValue Generic(KeyBinder,bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value.");239 SetConfigValue Generic(KeyBinder,derivePeriod_, 0.05f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");240 SetConfigValue Generic(KeyBinder,mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived.");241 SetConfigValue Generic(KeyBinder,bClipMouse_, true).description("Whether or not to clip absolute value of mouse in non derive mode.");236 SetConfigValue(analogThreshold_, 0.05f) .description("Threshold for analog axes until which the state is 0."); 237 SetConfigValue(mouseSensitivity_, 1.0f) .description("Mouse sensitivity."); 238 SetConfigValue(bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value."); 239 SetConfigValue(derivePeriod_, 0.05f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier."); 240 SetConfigValue(mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived."); 241 SetConfigValue(bClipMouse_, true).description("Whether or not to clip absolute value of mouse in non derive mode."); 242 242 243 243 float oldThresh = buttonThreshold_; 244 SetConfigValue Generic(KeyBinder,buttonThreshold_, 0.80f).description("Threshold for analog axes until which the button is not pressed.");244 SetConfigValue(buttonThreshold_, 0.80f).description("Threshold for analog axes until which the button is not pressed."); 245 245 if (oldThresh != buttonThreshold_) 246 246 for (unsigned int i = 0; i < nHalfAxes_s; i++) … … 268 268 if (!cont) 269 269 { 270 cont = new ConfigValueContainer(CFT_Keybindings, ClassIdentifier<KeyBinder>::getIdentifier(), button.name_, "" );270 cont = new ConfigValueContainer(CFT_Keybindings, ClassIdentifier<KeyBinder>::getIdentifier(), button.name_, "", button.name_); 271 271 ClassIdentifier<KeyBinder>::getIdentifier()->addConfigValueContainer(button.name_, cont); 272 272 } 273 273 std::string old = button.bindingString_; 274 cont->getValue(&button.bindingString_ );274 cont->getValue(&button.bindingString_, this); 275 275 276 276 // keybinder stuff -
code/trunk/src/core/input/KeyDetector.cc
r1535 r1747 33 33 34 34 #include "KeyDetector.h" 35 #include " core/Debug.h"35 #include "util/Debug.h" 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/CommandExecutor.h"
Note: See TracChangeset
for help on using the changeset viewer.