Changeset 1747
- Timestamp:
- Sep 9, 2008, 4:25:52 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 15 deleted
- 121 edited
- 15 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/audio/AudioIncludes.h
r1505 r1747 47 47 #include <vorbis/vorbisfile.h> 48 48 49 #include " core/Error.h"49 #include "util/Error.h" -
code/trunk/src/audio/AudioManager.cc
r1639 r1747 36 36 #include "AudioSource.h" 37 37 #include "AudioStream.h" 38 #include " core/Error.h"39 #include " core/Debug.h"38 #include "util/Error.h" 39 #include "util/Debug.h" 40 40 41 41 namespace audio -
code/trunk/src/audio/AudioManager.h
r1535 r1747 58 58 void setOri(std::vector<float> at, std::vector<float> up); 59 59 60 // Parses given xml string61 void loadParams();62 63 60 // Update 64 61 void tick(float dt); -
code/trunk/src/audio/AudioStream.cc
r1505 r1747 28 28 #include "AudioStream.h" 29 29 30 #include " core/Debug.h"31 #include " core/Error.h"30 #include "util/Debug.h" 31 #include "util/Error.h" 32 32 33 33 namespace audio -
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" -
code/trunk/src/network/ClientConnection.cc
r1534 r1747 45 45 46 46 #include "util/Sleep.h" 47 #include " core/Debug.h"47 #include "util/Debug.h" 48 48 49 49 namespace network … … 91 91 return getPacket(address); 92 92 }*/ 93 93 94 94 ENetEvent *ClientConnection::getEvent(){ 95 95 if(!buffer.isEmpty()) -
code/trunk/src/network/ConnectionManager.cc
r1735 r1747 45 45 #include "core/CoreIncludes.h" 46 46 #include "core/BaseObject.h" 47 #include "core/Iterator.h" 47 48 #include "objects/SpaceShip.h" 48 49 #include "util/Math.h" … … 66 67 { 67 68 //boost::thread_group network_threads; 68 69 69 70 ConnectionManager *ConnectionManager::instance_=0; 70 71 71 72 ConnectionManager::ConnectionManager():receiverThread_(0){ 72 73 assert(instance_==0); … … 77 78 } 78 79 boost::recursive_mutex ConnectionManager::enet_mutex; 79 80 80 81 // ConnectionManager::ConnectionManager(ClientInformation *head) : receiverThread_(0) { 81 82 // assert(instance_==0); … … 85 86 // bindAddress.port = NETWORK_PORT; 86 87 // } 87 88 88 89 ConnectionManager::ConnectionManager(int port){ 89 90 assert(instance_==0); … … 109 110 bindAddress.port = NETWORK_PORT; 110 111 } 111 112 112 113 ConnectionManager::~ConnectionManager(){ 113 114 instance_=0; … … 135 136 return packet; 136 137 }*/ 137 138 138 139 ENetEvent *ConnectionManager::getEvent(){ 139 140 if(!buffer.isEmpty()) … … 160 161 return true; 161 162 } 162 163 163 164 // bool ConnectionManager::addPacket(Packet::Packet *packet){ 164 165 // ClientInformation *temp = instance_->head_->findClient(packet->getClientID()); … … 170 171 // // TODO: finish implementation 171 172 // } 172 // 173 173 // 174 174 175 bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) { 175 176 boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex); … … 276 277 } 277 278 } 278 279 279 280 //### added some bugfixes here, but we cannot test them because 280 281 //### the server crashes everytime because of some gamestates … … 335 336 336 337 /** 337 * 338 * @param clientID 338 * 339 * @param clientID 339 340 */ 340 341 void ConnectionManager::syncClassid(unsigned int clientID) { … … 364 365 } 365 366 366 367 367 368 368 369 bool ConnectionManager::removeShip(ClientInformation *client){ 369 370 unsigned int id=client->getShipID(); 370 orxonox:: Iterator<orxonox::SpaceShip>it;371 for(it = orxonox::ObjectList<orxonox::SpaceShip>:: start(); it; ++it){371 orxonox::ObjectList<orxonox::SpaceShip>::iterator it; 372 for(it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); it; ++it){ 372 373 if(it->objectID!=id) 373 374 continue; … … 376 377 return true; 377 378 } 378 379 379 380 380 381 void ConnectionManager::disconnectClient(ClientInformation *client){ 381 382 { … … 386 387 removeShip(client); 387 388 } 388 389 389 390 390 391 } -
code/trunk/src/network/GamestateClient.cc
r1735 r1747 33 33 #include "core/CoreIncludes.h" 34 34 #include "core/BaseObject.h" 35 #include "core/Iterator.h" 35 36 #include "Synchronisable.h" 36 37 … … 68 69 return true; 69 70 } 70 71 71 72 int GamestateClient::processGamestates(){ 72 73 if(tempGamestate_==NULL) … … 89 90 * @return iterator pointing to the next object in the list 90 91 */ 91 void GamestateClient::removeObject(orxonox:: Iterator<Synchronisable>&it) {92 orxonox:: Iterator<Synchronisable>temp=it;92 void GamestateClient::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) { 93 orxonox::ObjectList<Synchronisable>::iterator temp=it; 93 94 ++it; 94 95 delete *temp; -
code/trunk/src/network/GamestateClient.h
r1735 r1747 42 42 43 43 #include <map> 44 // 44 // 45 45 #include "NetworkPrereqs.h" 46 46 #include "core/CorePrereqs.h" … … 58 58 GamestateClient(); 59 59 ~GamestateClient(); 60 60 61 61 bool add(packet::Gamestate *gs, int clientID); 62 62 bool ack(int gamestateID, int clientID); 63 63 64 64 int processGamestates(); 65 65 packet::Gamestate *getGamestate(); … … 67 67 private: 68 68 bool processGamestate(packet::Gamestate *gs); 69 void removeObject(orxonox:: Iterator<Synchronisable> &it);69 void removeObject(orxonox::ObjectListIterator<Synchronisable> &it); 70 70 void printGamestateMap(); 71 71 bool saveShipCache(); … … 78 78 orxonox::SpaceShip *myShip_; 79 79 unsigned char *shipCache_; 80 80 81 81 }; 82 82 -
code/trunk/src/network/Server.cc
r1735 r1747 50 50 #include "objects/SpaceShip.h" 51 51 #include "core/ConsoleCommand.h" 52 #include "core/Iterator.h" 52 53 #include "packet/Chat.h" 53 54 #include "packet/Packet.h" … … 58 59 #define MAX_FAILURES 20; 59 60 #define NETWORK_FREQUENCY 30 60 61 61 62 /** 62 63 * Constructor for default values (bindaddress is set to ENET_HOST_ANY … … 68 69 gamestates_ = new GamestateManager(); 69 70 } 70 71 71 72 Server::Server(int port){ 72 73 timeSinceLastUpdate_=0; … … 123 124 return message->process(); 124 125 } 125 126 126 127 /** 127 128 * This function sends out a message to all clients … … 175 176 return; 176 177 } 177 178 178 179 bool Server::queuePacket(ENetPacket *packet, int clientID){ 179 180 return connection->addPacket(packet, clientID); … … 230 231 return p->process(); 231 232 } 232 233 233 234 /** 234 235 * sends the gamestate … … 261 262 assert(gs->compressData()); 262 263 if ( !gs->send() ){ 263 COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 264 COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl; 264 265 temp->addFailure(); 265 266 }else … … 276 277 return true; 277 278 } 278 279 279 280 // void Server::processChat( chat *data, int clientId){ 280 281 // char *message = new char [strlen(data->message)+10+1]; … … 286 287 // delete data; 287 288 // } 288 289 289 290 bool Server::addClient(ENetEvent *event){ 290 291 ClientInformation *temp = ClientInformation::insertBack(new ClientInformation); … … 303 304 return createClient(temp->getID()); 304 305 } 305 306 306 307 bool Server::createClient(int clientID){ 307 308 ClientInformation *temp = ClientInformation::findClient(clientID); … … 325 326 return true; 326 327 } 327 328 328 329 bool Server::createShip(ClientInformation *client){ 329 330 if(!client) … … 351 352 no->create(); 352 353 no->setBacksync(true); 353 354 354 355 return true; 355 356 } 356 357 357 358 bool Server::disconnectClient(ENetEvent *event){ 358 359 COUT(4) << "removing client from list" << std::endl; 359 360 //return removeClient(head_->findClient(&(peer->address))->getID()); 360 361 361 362 //boost::recursive_mutex::scoped_lock lock(head_->mutex_); 362 orxonox:: Iterator<orxonox::SpaceShip> it = orxonox::ObjectList<orxonox::SpaceShip>::start();363 orxonox::ObjectList<orxonox::SpaceShip>::iterator it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); 363 364 ClientInformation *client = ClientInformation::findClient(&event->peer->address); 364 365 if(!client) … … 369 370 continue; 370 371 } 371 orxonox:: Iterator<orxonox::SpaceShip>temp=it;372 orxonox::ObjectList<orxonox::SpaceShip>::iterator temp=it; 372 373 ++it; 373 374 delete *temp; … … 386 387 gamestates_->removeClient(client); 387 388 } 388 389 389 390 } -
code/trunk/src/network/Synchronisable.h
r1735 r1747 92 92 Synchronisable(); 93 93 private: 94 /* bool removeObject( Iterator<Synchronisable>it);*/94 /* bool removeObject(ObjectList<Synchronisable>::iterator it);*/ 95 95 96 96 std::list<synchronisableVariable *> *syncList; -
code/trunk/src/network/packet/Gamestate.cc
r1740 r1747 30 30 #include "network/ClientInformation.h" 31 31 #include "network/GamestateHandler.h" 32 #include "core/Iterator.h" 32 33 33 34 #include <zlib.h> … … 79 80 unsigned char *mem=data_; 80 81 mem+=sizeof(GamestateHeader); 81 orxonox:: Iterator<Synchronisable>it;82 for(it = orxonox::ObjectList<Synchronisable>:: start(); it; ++it){82 orxonox::ObjectList<Synchronisable>::iterator it; 83 for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){ 83 84 tempsize=it->getSize2(mode); 84 85 … … 86 87 // start allocate additional memory 87 88 COUT(3) << "G.St.Man: need additional memory" << std::endl; 88 orxonox:: Iterator<Synchronisable>temp = it;89 orxonox::ObjectList<Synchronisable>::iterator temp = it; 89 90 int addsize=tempsize; 90 91 while(++temp) … … 124 125 unsigned char *mem=data_+sizeof(GamestateHeader); 125 126 // get the start of the Synchronisable list 126 orxonox:: Iterator<Synchronisable> it=orxonox::ObjectList<Synchronisable>::start();127 orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin(); 127 128 128 129 while(mem < data_+sizeof(GamestateHeader)+HEADER->normsize){ … … 318 319 int size=0; 319 320 // get the start of the Synchronisable list 320 orxonox:: Iterator<Synchronisable>it;321 orxonox::ObjectList<Synchronisable>::iterator it; 321 322 // get total size of gamestate 322 for(it = orxonox::ObjectList<Synchronisable>:: start(); it; ++it)323 for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it) 323 324 size+=it->getSize2(mode); // size of the actual data of the synchronisable 324 325 // size+=sizeof(GamestateHeader); … … 331 332 * @return iterator pointing to the next object in the list 332 333 */ 333 void Gamestate::removeObject(orxonox:: Iterator<Synchronisable>&it) {334 orxonox:: Iterator<Synchronisable>temp=it;334 void Gamestate::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) { 335 orxonox::ObjectList<Synchronisable>::iterator temp=it; 335 336 ++it; 336 337 delete *temp; -
code/trunk/src/network/packet/Gamestate.h
r1735 r1747 38 38 39 39 namespace packet { 40 40 41 41 struct GamestateHeader{ 42 42 ENUM::Type packetType; … … 51 51 52 52 /** 53 @author 53 @author 54 54 */ 55 55 class Gamestate: public Packet{ … … 57 57 Gamestate(); 58 58 Gamestate(unsigned char *data, int clientID); 59 59 60 60 ~Gamestate(); 61 61 62 62 bool collectData(int id, int mode=0x0); 63 63 bool spreadData(int mode=0x0); … … 69 69 bool compressData(); 70 70 bool decompressData(); 71 71 72 72 // Packet functions 73 73 virtual unsigned int getSize() const; 74 74 virtual bool process(); 75 75 76 76 77 77 private: 78 78 unsigned int calcGamestateSize(int mode=0x0); 79 void removeObject(orxonox:: Iterator<Synchronisable> &it);79 void removeObject(orxonox::ObjectListIterator<Synchronisable> &it); 80 80 81 81 82 82 //Bytestream *bs_; 83 83 //GamestateHeader *header_; -
code/trunk/src/orxonox/CMakeLists.txt
r1625 r1747 7 7 RadarViewable.cc 8 8 Settings.cc 9 SignalHandler.cc 9 10 10 11 overlays/OrxonoxOverlay.cc -
code/trunk/src/orxonox/GraphicsEngine.cc
r1625 r1747 47 47 #include "core/CoreIncludes.h" 48 48 #include "core/ConfigValueIncludes.h" 49 #include "core/ Debug.h"49 #include "core/Iterator.h" 50 50 #include "core/CommandExecutor.h" 51 51 #include "core/ConsoleCommand.h" 52 #include "util/Debug.h" 52 53 53 54 #include "overlays/console/InGameConsole.h" … … 97 98 SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical"); 98 99 99 unsigned int old = this->detailLevelParticle_; 100 SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high"); 101 102 if (this->detailLevelParticle_ != old) 103 for (Iterator<ParticleInterface> it = ObjectList<ParticleInterface>::begin(); it; ++it) 104 it->detailLevelChanged(this->detailLevelParticle_); 100 SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high").callback(this, &GraphicsEngine::detailLevelParticleChanged); 101 } 102 103 void GraphicsEngine::detailLevelParticleChanged() 104 { 105 for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it) 106 it->detailLevelChanged(this->detailLevelParticle_); 105 107 } 106 108 … … 441 443 void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw) 442 444 { 443 for ( Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)445 for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it) 444 446 it->windowMoved(); 445 447 } … … 453 455 void GraphicsEngine::windowResized(Ogre::RenderWindow *rw) 454 456 { 455 for ( Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)457 for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it) 456 458 it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight()); 457 459 } … … 463 465 void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw) 464 466 { 465 for ( Iterator<orxonox::WindowEventListener> it = ObjectList<orxonox::WindowEventListener>::start(); it; ++it)467 for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it) 466 468 it->windowFocusChanged(); 467 469 } -
code/trunk/src/orxonox/GraphicsEngine.h
r1625 r1747 56 56 public: 57 57 void setConfigValues(); 58 void detailLevelParticleChanged(); 58 59 bool setup(); 59 60 bool declareRessourceLocations(); -
code/trunk/src/orxonox/Main.cc
r1535 r1747 37 37 38 38 #include "util/OrxonoxPlatform.h" 39 #include " core/SignalHandler.h"39 #include "SignalHandler.h" 40 40 #include "Orxonox.h" 41 41 -
code/trunk/src/orxonox/Orxonox.cc
r1735 r1747 54 54 // core 55 55 #include "core/ConfigFileManager.h" 56 #include "core/Iterator.h" 56 57 #include "core/ConsoleCommand.h" 57 #include "core/Debug.h"58 58 #include "core/Loader.h" 59 59 #include "core/input/InputManager.h" 60 60 #include "core/TclBind.h" 61 61 #include "core/Core.h" 62 #include "util/Debug.h" 62 63 63 64 // audio … … 85 86 namespace orxonox 86 87 { 87 SetConsoleCommandShortcut(Orxonox, exit). setKeybindMode(KeybindMode::OnPress);88 SetConsoleCommandShortcut(Orxonox, slomo). setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0).setAxisParamIndex(0).setIsAxisRelative(false);89 SetConsoleCommandShortcut(Orxonox, setTimeFactor). setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0);88 SetConsoleCommandShortcut(Orxonox, exit).keybindMode(KeybindMode::OnPress); 89 SetConsoleCommandShortcut(Orxonox, slomo).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false); 90 SetConsoleCommandShortcut(Orxonox, setTimeFactor).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0); 90 91 91 92 /** … … 181 182 float change = factor / Orxonox::getSingleton()->getTimeFactor(); 182 183 Orxonox::getSingleton()->timefactor_ = factor; 183 for ( Iterator<ParticleInterface>it = ObjectList<ParticleInterface>::begin(); it; ++it)184 for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it) 184 185 it->setSpeedFactor(it->getSpeedFactor() * change); 185 186 … … 197 198 { 198 199 #ifdef _DEBUG 199 ConfigFileManager::get Singleton()->setFile(CFT_Settings, "orxonox_d.ini");200 ConfigFileManager::getInstance()->setFile(CFT_Settings, "orxonox_d.ini"); 200 201 #else 201 ConfigFileManager::get Singleton()->setFile(CFT_Settings, "orxonox.ini");202 ConfigFileManager::getInstance()->setFile(CFT_Settings, "orxonox.ini"); 202 203 #endif 203 204 Factory::createClassHierarchy(); … … 442 443 443 444 unsigned long frameCount = 0; 444 445 445 446 // TODO: this would very well fit into a configValue 446 447 const unsigned long refreshTime = 200000; … … 468 469 469 470 // Call those objects that need the real time 470 for ( Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)471 for (ObjectList<TickableReal>::iterator it = ObjectList<TickableReal>::begin(); it; ++it) 471 472 it->tick(dt); 472 473 // Call the scene objects 473 for ( Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)474 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 474 475 it->tick(dt * this->timefactor_); 475 476 -
code/trunk/src/orxonox/OrxonoxStableHeaders.h
r1631 r1747 92 92 93 93 #include "util/Convert.h" 94 #include "util/Debug.h" 94 95 #include "util/Math.h" 95 96 #include "util/Multitype.h" 96 #include "util/MultiTypeMath.h" 97 #include "util/OutputBuffer.h" 98 #include "util/OutputHandler.h" 97 99 #include "util/Sleep.h" 98 100 #include "util/String.h" … … 104 106 #include "core/CoreIncludes.h" 105 107 #include "core/ConfigValueIncludes.h" 106 #include "core/Debug.h"107 #include "core/OutputBuffer.h"108 #include "core/OutputHandler.h"109 108 #include "core/Executor.h" 110 109 #include "core/XMLPort.h" -
code/trunk/src/orxonox/Radar.cc
r1625 r1747 39 39 #include "core/CoreIncludes.h" 40 40 #include "core/ConsoleCommand.h" 41 #include "core/Iterator.h" 41 42 #include "RadarListener.h" 42 43 43 44 namespace orxonox 44 45 { 45 SetConsoleCommand(Radar, cycleNavigationFocus, true). setAccessLevel(AccessLevel::User);46 SetConsoleCommand(Radar, releaseNavigationFocus, true). setAccessLevel(AccessLevel::User);46 SetConsoleCommand(Radar, cycleNavigationFocus, true).accessLevel(AccessLevel::User); 47 SetConsoleCommand(Radar, releaseNavigationFocus, true).accessLevel(AccessLevel::User); 47 48 48 49 Radar* Radar::instance_s = 0; … … 106 107 } 107 108 108 for ( Iterator<RadarListener>itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)109 for (ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener) 109 110 { 110 111 (*itListener)->radarTick(dt); 111 112 112 for ( Iterator<RadarViewable>itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)113 for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement) 113 114 { 114 115 if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage()) … … 120 121 void Radar::cycleFocus() 121 122 { 122 if ( *(ObjectList<RadarViewable>::begin()) == 0)123 if (ObjectList<RadarViewable>::begin() == 0) 123 124 { 124 125 // list is empty … … 137 138 float nextDistance = FLT_MAX; 138 139 float minimumDistance = FLT_MAX; 139 Iterator<RadarViewable>itFallback = 0;140 141 for ( Iterator<RadarViewable>it = ObjectList<RadarViewable>::begin(); it; ++it)140 ObjectList<RadarViewable>::iterator itFallback = 0; 141 142 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it) 142 143 { 143 144 if (*it == SpaceShip::getLocalShip()) … … 181 182 // iterate through all Radar Objects 182 183 unsigned int i = 0; 183 for ( Iterator<RadarViewable> it = ObjectList<RadarViewable>::start(); it; ++it, ++i)184 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i) 184 185 { 185 186 COUT(3) << i++ << ": " << (*it)->getWorldPosition() << std::endl; -
code/trunk/src/orxonox/Radar.h
r1625 r1747 55 55 RadarBase() { } 56 56 }; 57 57 58 58 class _OrxonoxExport Radar : public Tickable, private virtual RadarBase 59 59 { … … 61 61 Radar(); 62 62 ~Radar(); 63 64 virtual void tick(float dt); 63 65 64 66 const RadarViewable* getFocus(); … … 75 77 private: 76 78 Radar(Radar& instance); 77 void tick(float dt);78 79 79 80 void releaseFocus(); … … 81 82 void cycleFocus(); 82 83 83 Iterator<RadarViewable> itFocus_;84 ObjectListIterator<RadarViewable> itFocus_; 84 85 RadarViewable* focus_; 85 86 std::map<std::string, RadarViewable::Shape> objectTypes_; 86 int objectTypeCounter_; 87 int objectTypeCounter_; 87 88 88 89 static Radar* instance_s; -
code/trunk/src/orxonox/RadarViewable.cc
r1625 r1747 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include "RadarViewable.h" 31 #include " core/Debug.h"31 #include "util/Debug.h" 32 32 #include "core/CoreIncludes.h" 33 33 #include "objects/WorldEntity.h" -
code/trunk/src/orxonox/RadarViewable.h
r1625 r1747 33 33 #include <string> 34 34 #include "util/Math.h" 35 #include " core/Debug.h"35 #include "util/Debug.h" 36 36 #include "core/OrxonoxClass.h" 37 37 -
code/trunk/src/orxonox/Settings.cc
r1535 r1747 68 68 void Settings::setConfigValues() 69 69 { 70 SetConfigValue(dataPath_, "../../Media/").description("Relative path to the game data."); 70 SetConfigValue(dataPath_, "../../Media/").description("Relative path to the game data.").callback(this, &Settings::dataPathChanged); 71 } 72 73 /** 74 @brief Callback function if the datapath has changed. 75 */ 76 void Settings::dataPathChanged() 77 { 71 78 if (dataPath_ != "" && dataPath_[dataPath_.size() - 1] != '/') 72 79 { -
code/trunk/src/orxonox/Settings.h
r1535 r1747 48 48 public: 49 49 void setConfigValues(); 50 void dataPathChanged(); 50 51 51 52 static const std::string& getDataPath(); -
code/trunk/src/orxonox/objects/Ambient.cc
r1625 r1747 39 39 #include "util/Convert.h" 40 40 #include "util/Math.h" 41 #include " core/Debug.h"41 #include "util/Debug.h" 42 42 #include "core/CoreIncludes.h" 43 #include "GraphicsEngine.h"44 43 #include "core/XMLPort.h" 45 44 #include "core/ConsoleCommand.h" 45 #include "GraphicsEngine.h" 46 46 47 47 namespace orxonox 48 48 { 49 SetConsoleCommand (Ambient, setAmbientLightTest, false).setDefaultValues(ColourValue(1, 1, 1, 1)).setAccessLevel(AccessLevel::Offline);49 SetConsoleCommandAlias(Ambient, setAmbientLightTest, "setAmbientLight", false).defaultValues(ColourValue(1, 1, 1, 1)).accessLevel(AccessLevel::Offline); 50 50 51 51 CreateFactory(Ambient); … … 64 64 } 65 65 66 bool Ambient::create(){ 67 GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_); 68 return Synchronisable::create(); 66 bool Ambient::create() 67 { 68 GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_); 69 return Synchronisable::create(); 69 70 } 70 71 void Ambient::registerAllVariables() {72 registerVar(&ambientLight_, sizeof(ColourValue), network::DATA);73 71 72 void Ambient::registerAllVariables() 73 { 74 registerVar(&ambientLight_, sizeof(ColourValue), network::DATA); 74 75 } 75 76 76 77 void Ambient::setAmbientLight(const ColourValue& colour) 77 78 { 78 79 ambientLight_=colour;79 GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour); 80 ambientLight_=colour; 80 81 } 81 82 … … 88 89 void Ambient::XMLPort(Element& xmlelement, XMLPort::Mode mode) 89 90 { 90 BaseObject::XMLPort(xmlelement, mode);91 SUPER(Ambient, XMLPort, xmlelement, mode); 91 92 92 XMLPortParam LoadOnly(Ambient, "colourvalue", setAmbientLight, xmlelement, mode);93 XMLPortParam(Ambient, "colourvalue", setAmbientLight, getAmbienetLight, xmlelement, mode); 93 94 create(); 94 95 } -
code/trunk/src/orxonox/objects/Ambient.h
r1735 r1747 45 45 46 46 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 void setAmbientLight(const ColourValue& colour);48 47 virtual bool create(); 49 48 void registerAllVariables(); 49 50 void setAmbientLight(const ColourValue& colour); 51 inline const ColourValue& getAmbienetLight() const 52 { return this->ambientLight_; } 50 53 51 54 static void setAmbientLightTest(const ColourValue& colour) -
code/trunk/src/orxonox/objects/Backlight.cc
r1608 r1747 103 103 void Backlight::tick(float dt) 104 104 { 105 WorldEntity::tick(dt);105 SUPER(Backlight, tick, dt); 106 106 107 107 if (this->isActive()) … … 147 147 void Backlight::changedVisibility() 148 148 { 149 WorldEntity::changedVisibility();149 SUPER(Backlight, changedVisibility); 150 150 151 151 this->billboard_.setVisible(this->isVisible()); -
code/trunk/src/orxonox/objects/BillboardProjectile.cc
r1559 r1747 63 63 void BillboardProjectile::changedVisibility() 64 64 { 65 Projectile::changedVisibility();65 SUPER(BillboardProjectile, changedVisibility); 66 66 this->billboard_.setVisible(this->isVisible()); 67 67 } -
code/trunk/src/orxonox/objects/Camera.cc
r1505 r1747 42 42 #include "util/Convert.h" 43 43 #include "util/Math.h" 44 #include " core/Debug.h"44 #include "util/Debug.h" 45 45 #include "core/CoreIncludes.h" 46 46 #include "GraphicsEngine.h" -
code/trunk/src/orxonox/objects/Model.cc
r1627 r1747 65 65 void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode) 66 66 { 67 WorldEntity::XMLPort(xmlelement, mode);67 SUPER(Model, XMLPort, xmlelement, mode); 68 68 69 XMLPortParam LoadOnly(Model, "mesh", setMesh, xmlelement, mode);69 XMLPortParam(Model, "mesh", setMesh, getMesh, xmlelement, mode); 70 70 71 71 Model::create(); 72 }73 74 void Model::setMesh(const std::string& meshname)75 {76 this->meshSrc_ = meshname;77 72 } 78 73 … … 98 93 void Model::changedVisibility() 99 94 { 100 WorldEntity::changedVisibility();95 SUPER(Model, changedVisibility); 101 96 if (this->isInitialized()) 102 97 this->mesh_.setVisible(this->isVisible()); -
code/trunk/src/orxonox/objects/Model.h
r1558 r1747 45 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 46 virtual void changedVisibility(); 47 void setMesh(const std::string& meshname); 47 inline void setMesh(const std::string& meshname) 48 { this->meshSrc_ = meshname; } 49 inline const std::string& getMesh() const 50 { return this->meshSrc_; } 48 51 virtual bool create(); 49 52 -
code/trunk/src/orxonox/objects/NPC.cc
r1625 r1747 31 31 32 32 #include "core/CoreIncludes.h" 33 #include "core/Iterator.h" 33 34 34 35 namespace orxonox { … … 56 57 movable_ = movable; 57 58 } 58 59 59 60 void NPC::registerAllVariables(){ 60 61 Model::registerAllVariables(); 61 62 registerVar(&movable_, sizeof(movable_), network::DATA); 62 63 } 63 64 64 65 65 66 /** … … 112 113 int numberOfNeighbour = 0; //number of observed neighbours 113 114 float distance = 0; // distance to the actual element 114 for( Iterator<WorldEntity> it = ObjectList<WorldEntity>::start(); it; ++it) { //go through all elements115 for(ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it; ++it) { //go through all elements 115 116 distance = getDistance(*it); //get distance between this and actual 116 117 if ((distance > 0) && (distance < SEPERATIONDISTANCE)) { //do only if actual is inside detectionradius … … 139 140 //float distance = 0; 140 141 //go through all elements 141 for( Iterator<NPC> it = ObjectList<NPC>::start(); it; ++it) { //just working with 3 elements at the moment142 for(ObjectList<NPC>::iterator it = ObjectList<NPC>::begin(); it; ++it) { //just working with 3 elements at the moment 142 143 float distance = getDistance(*it); //get distance between this and actual 143 144 if ((distance > 0) && (distance < ALIGNMENTDISTANCE)) { //check if actual element is inside detectionradius … … 159 160 //float distance = 0; 160 161 //go through all elements 161 for( Iterator<NPC> it = ObjectList<NPC>::start(); it; ++it) { //just working with 3 elements at the moment162 for(ObjectList<NPC>::iterator it = ObjectList<NPC>::begin(); it; ++it) { //just working with 3 elements at the moment 162 163 float distance = getDistance(*it); //get distance between this and actual 163 164 if ((distance > 0) && (distance < COHESIONDISTANCE)) { //check if actual element is inside detectionradius -
code/trunk/src/orxonox/objects/NPC.h
r1625 r1747 48 48 NPC(); 49 49 virtual ~NPC(); 50 v oid tick(float dt);50 virtual void tick(float dt); 51 51 void update(); 52 52 void setValues(Vector3 location, Vector3 speed, Vector3 acceleration, bool movable); -
code/trunk/src/orxonox/objects/ParticleProjectile.cc
r1563 r1747 32 32 #include "SpaceShip.h" 33 33 #include "core/CoreIncludes.h" 34 #include "core/ConfigValueIncludes.h" 34 35 35 36 namespace orxonox … … 52 53 this->particles_ = 0; 53 54 } 55 56 this->setConfigValues(); 54 57 } 55 58 … … 60 63 } 61 64 65 void ParticleProjectile::setConfigValues() 66 { 67 SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback((Projectile*)this, &ParticleProjectile::speedChanged); 68 } 69 62 70 void ParticleProjectile::changedVisibility() 63 71 { 64 BillboardProjectile::changedVisibility();72 SUPER(ParticleProjectile, changedVisibility); 65 73 this->particles_->setEnabled(this->isVisible()); 66 74 } -
code/trunk/src/orxonox/objects/ParticleProjectile.h
r1558 r1747 44 44 virtual ~ParticleProjectile(); 45 45 virtual void changedVisibility(); 46 void setConfigValues(); 46 47 47 48 private: -
code/trunk/src/orxonox/objects/Projectile.cc
r1602 r1747 35 35 #include "core/Executor.h" 36 36 #include "core/ConfigValueIncludes.h" 37 #include "core/Iterator.h" 37 38 #include "tools/ParticleInterface.h" 38 39 … … 43 44 namespace orxonox 44 45 { 45 float Projectile::speed_ = 5000;46 float Projectile::speed_s = 5000; 46 47 47 48 Projectile::Projectile(SpaceShip* owner) : owner_(owner) … … 73 74 SetConfigValue(damage_, 15.0).description("The damage caused by the projectile"); 74 75 SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive"); 75 SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second"); 76 SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback(this, &Projectile::speedChanged); 77 } 76 78 77 if(this->owner_) 78 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 79 void Projectile::speedChanged() 80 { 81 Projectile::speed_s = this->speed_; 82 if (this->owner_) 83 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 79 84 } 80 85 81 86 void Projectile::tick(float dt) 82 87 { 83 WorldEntity::tick(dt);88 SUPER(Projectile, tick, dt); 84 89 85 90 if (!this->isActive()) … … 87 92 88 93 float radius; 89 for ( Iterator<Model> it = ObjectList<Model>::start(); it; ++it)94 for (ObjectList<Model>::iterator it = ObjectList<Model>::begin(); it; ++it) 90 95 { 91 96 if ((*it) != this->owner_) 92 97 { 93 radius = it->getScale ().x * 3.0;98 radius = it->getScale3D().x * 3.0; 94 99 95 100 if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius)) -
code/trunk/src/orxonox/objects/Projectile.h
r1552 r1747 42 42 virtual ~Projectile(); 43 43 void setConfigValues(); 44 void speedChanged(); 44 45 void destroyObject(); 45 46 virtual void tick(float dt); 46 47 47 48 static float getSpeed() 48 { return Projectile::speed_ ; }49 { return Projectile::speed_s; } 49 50 50 51 protected: … … 55 56 std::string explosionTemplateName_; 56 57 std::string smokeTemplateName_; 57 static float speed_; 58 protected: 59 static float speed_s; 60 float speed_; 61 private: 58 62 float lifetime_; 59 63 float damage_; -
code/trunk/src/orxonox/objects/RotatingProjectile.cc
r1558 r1747 65 65 void RotatingProjectile::setConfigValues() 66 66 { 67 SetConfigValue(colour_, ColourValue(1.0, 0.0, 0.0)); 67 SetConfigValue(colour_, ColourValue(1.0, 0.0, 0.0)).callback(this, &RotatingProjectile::colourChanged); 68 } 68 69 69 this->rotatingBillboard1_.getBillboardSet()->getBillboard(0)->setColour(this->colour_); 70 this->rotatingBillboard2_.getBillboardSet()->getBillboard(0)->setColour(this->colour_); 70 void RotatingProjectile::colourChanged() 71 { 72 if (this->isInitialized()) 73 { 74 this->rotatingBillboard1_.getBillboardSet()->getBillboard(0)->setColour(this->colour_); 75 this->rotatingBillboard2_.getBillboardSet()->getBillboard(0)->setColour(this->colour_); 76 } 71 77 } 72 78 … … 81 87 } 82 88 83 Projectile::tick(dt);89 SUPER(RotatingProjectile, tick, dt); 84 90 } 85 91 86 92 void RotatingProjectile::changedVisibility() 87 93 { 88 BillboardProjectile::changedVisibility();94 SUPER(RotatingProjectile, changedVisibility); 89 95 this->rotatingBillboard1_.setVisible(this->isVisible()); 90 96 this->rotatingBillboard2_.setVisible(this->isVisible()); -
code/trunk/src/orxonox/objects/RotatingProjectile.h
r1558 r1747 14 14 virtual ~RotatingProjectile(); 15 15 void setConfigValues(); 16 void colourChanged(); 16 17 virtual void tick(float dt); 17 18 virtual void changedVisibility(); -
code/trunk/src/orxonox/objects/Skybox.cc
r1558 r1747 37 37 #include "GraphicsEngine.h" 38 38 #include "core/CoreIncludes.h" 39 #include "core/Debug.h"40 39 #include "core/XMLPort.h" 40 #include "util/Debug.h" 41 41 42 42 namespace orxonox … … 59 59 } 60 60 61 void Skybox::setSkyboxSrc(const std::string& src)62 {63 this->skyboxSrc_ = src;64 }65 66 61 /** 67 62 @brief XML loading and saving. … … 72 67 void Skybox::XMLPort(Element& xmlelement, XMLPort::Mode mode) 73 68 { 74 BaseObject::XMLPort(xmlelement, mode);69 SUPER(Skybox, XMLPort, xmlelement, mode); 75 70 76 XMLPortParam LoadOnly(Skybox, "src", setSkyboxSrc, xmlelement, mode);71 XMLPortParam(Skybox, "src", setSkyboxSrc, getSkyboxSrc, xmlelement, mode); 77 72 create(); 78 73 } … … 91 86 void Skybox::changedVisibility() 92 87 { 93 BaseObject::changedVisibility();88 SUPER(Skybox, changedVisibility); 94 89 GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(this->isVisible(), this->skyboxSrc_); 95 90 } -
code/trunk/src/orxonox/objects/Skybox.h
r1558 r1747 49 49 virtual bool create(); 50 50 void registerAllVariables(); 51 void setSkyboxSrc(const std::string &src); 51 52 inline void setSkyboxSrc(const std::string &src) 53 { this->skyboxSrc_ = src; } 54 inline const std::string& getSkyboxSrc() const 55 { return this->skyboxSrc_; } 52 56 53 57 private: -
code/trunk/src/orxonox/objects/SpaceShip.cc
r1735 r1747 37 37 #include "util/Convert.h" 38 38 #include "util/Math.h" 39 39 #include "util/Debug.h" 40 40 #include "core/CoreIncludes.h" 41 41 #include "core/ConfigValueIncludes.h" 42 #include "core/Debug.h" 42 #include "core/Iterator.h" 43 #include "core/input/InputManager.h" 43 44 #include "core/XMLPort.h" 44 45 #include "core/ConsoleCommand.h" 45 #include "network/Host.h"46 47 46 #include "tools/ParticleInterface.h" 48 49 #include "GraphicsEngine.h" 47 #include "network/Client.h" 48 #include "Backlight.h" 49 #include "CameraHandler.h" 50 #include "ParticleSpawner.h" 50 51 #include "RotatingProjectile.h" 51 52 #include "ParticleProjectile.h" 52 #include "ParticleSpawner.h" 53 #include "Backlight.h" 54 #include "CameraHandler.h" 53 #include "GraphicsEngine.h" 55 54 56 55 namespace orxonox 57 56 { 58 SetConsoleCommand(SpaceShip, setMaxSpeedTest, false). setAccessLevel(AccessLevel::Debug);59 SetConsoleCommand(SpaceShip, whereAmI, true). setAccessLevel(AccessLevel::User);60 SetConsoleCommand(SpaceShip, moveLongitudinal, true). setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);61 SetConsoleCommand(SpaceShip, moveLateral, true). setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);62 SetConsoleCommand(SpaceShip, moveYaw, true). setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);63 SetConsoleCommand(SpaceShip, movePitch, true). setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);64 SetConsoleCommand(SpaceShip, moveRoll, true). setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);65 SetConsoleCommand(SpaceShip, fire, true). setAccessLevel(AccessLevel::User).setKeybindMode(KeybindMode::OnHold);66 SetConsoleCommand Generic(test1, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed"), false).setAccessLevel(AccessLevel::Debug);67 SetConsoleCommand Generic(test2, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber"), false).setAccessLevel(AccessLevel::Debug);68 SetConsoleCommand Generic(test3, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl"), false).setAccessLevel(AccessLevel::Debug);57 SetConsoleCommand(SpaceShip, setMaxSpeedTest, false).accessLevel(AccessLevel::Debug); 58 SetConsoleCommand(SpaceShip, whereAmI, true).accessLevel(AccessLevel::User); 59 SetConsoleCommand(SpaceShip, moveLongitudinal, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold); 60 SetConsoleCommand(SpaceShip, moveLateral, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold); 61 SetConsoleCommand(SpaceShip, moveYaw, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold); 62 SetConsoleCommand(SpaceShip, movePitch, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold); 63 SetConsoleCommand(SpaceShip, moveRoll, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold); 64 SetConsoleCommand(SpaceShip, fire, true).accessLevel(AccessLevel::User).keybindMode(KeybindMode::OnHold); 65 SetConsoleCommandAliasMulti(SpaceShip, setMaxSpeedTest, "setMaxSpeed", 1, false).accessLevel(AccessLevel::Debug); 66 SetConsoleCommandAliasMulti(SpaceShip, setMaxSpeedTest, "setMaxBlubber", 2, false).accessLevel(AccessLevel::Debug); 67 SetConsoleCommandAliasMulti(SpaceShip, setMaxSpeedTest, "setRofl", 3, false).accessLevel(AccessLevel::Debug); 69 68 70 69 CreateFactory(SpaceShip); … … 74 73 75 74 SpaceShip *SpaceShip::getLocalShip(){ 76 Iterator<SpaceShip>it;77 for(it = ObjectList<SpaceShip>:: start(); it; ++it){75 ObjectList<SpaceShip>::iterator it; 76 for(it = ObjectList<SpaceShip>::begin(); it; ++it){ 78 77 if( (it)->myShip_ ) 79 78 return *it; … … 289 288 void SpaceShip::changedVisibility() 290 289 { 291 Model::changedVisibility();290 SUPER(SpaceShip, changedVisibility); 292 291 293 292 this->tt1_->setEnabled(this->isVisible()); … … 306 305 void SpaceShip::changedActivity() 307 306 { 308 Model::changedActivity();307 SUPER(SpaceShip, changedActivity); 309 308 310 309 this->tt1_->setEnabled(this->isVisible()); … … 392 391 void SpaceShip::XMLPort(Element& xmlelement, XMLPort::Mode mode) 393 392 { 394 Model::XMLPort(xmlelement, mode);395 396 XMLPortParam LoadOnly(SpaceShip, "camera", setCamera, xmlelement, mode);397 XMLPortParam LoadOnly(SpaceShip, "maxSpeed", setMaxSpeed, xmlelement, mode);398 XMLPortParam LoadOnly(SpaceShip, "maxSideAndBackSpeed", setMaxSideAndBackSpeed, xmlelement, mode);399 XMLPortParam LoadOnly(SpaceShip, "maxRotation", setMaxRotation, xmlelement, mode);400 XMLPortParam LoadOnly(SpaceShip, "transAcc", setTransAcc, xmlelement, mode);401 XMLPortParam LoadOnly(SpaceShip, "rotAcc", setRotAcc, xmlelement, mode);402 XMLPortParam LoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode);403 XMLPortParam LoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode);393 SUPER(SpaceShip, XMLPort, xmlelement, mode); 394 395 XMLPortParam(SpaceShip, "camera", setCamera, getCamera, xmlelement, mode); 396 XMLPortParam(SpaceShip, "maxSpeed", setMaxSpeed, getMaxSpeed, xmlelement, mode); 397 XMLPortParam(SpaceShip, "maxSideAndBackSpeed", setMaxSideAndBackSpeed, getMaxSideAndBackSpeed, xmlelement, mode); 398 XMLPortParam(SpaceShip, "maxRotation", setMaxRotation, getMaxRotation, xmlelement, mode); 399 XMLPortParam(SpaceShip, "transAcc", setTransAcc, getTransAcc, xmlelement, mode); 400 XMLPortParam(SpaceShip, "rotAcc", setRotAcc, getRotAcc, xmlelement, mode); 401 XMLPortParam(SpaceShip, "transDamp", setTransDamp, getTransDamp, xmlelement, mode); 402 XMLPortParam(SpaceShip, "rotDamp", setRotDamp, getRotDamp, xmlelement, mode); 404 403 405 404 myShip_=true; //TODO: this is a hack … … 535 534 536 535 537 WorldEntity::tick(dt);536 SUPER(SpaceShip, tick, dt); 538 537 539 538 this->roll(this->mouseXRotation_ * dt); -
code/trunk/src/orxonox/objects/SpaceShipAI.cc
r1608 r1747 44 44 namespace orxonox 45 45 { 46 SetConsoleCommand(SpaceShipAI, createEnemy, true). setDefaultValue(0, 1);47 SetConsoleCommand(SpaceShipAI, killEnemies, true). setDefaultValue(0, 0);46 SetConsoleCommand(SpaceShipAI, createEnemy, true).defaultValue(0, 1); 47 SetConsoleCommand(SpaceShipAI, killEnemies, true).defaultValue(0, 0); 48 48 49 49 CreateFactory(SpaceShipAI); … … 72 72 SpaceShipAI::~SpaceShipAI() 73 73 { 74 for ( Iterator<SpaceShipAI>it = ObjectList<SpaceShipAI>::begin(); it; ++it)74 for (ObjectList<SpaceShipAI>::iterator it = ObjectList<SpaceShipAI>::begin(); it; ++it) 75 75 it->shipDied(this); 76 76 } … … 78 78 void SpaceShipAI::XMLPort(Element& xmlelement, XMLPort::Mode mode) 79 79 { 80 S paceShip::XMLPort(xmlelement, mode);80 SUPER(SpaceShipAI, XMLPort, xmlelement, mode); 81 81 82 82 this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&SpaceShipAI::action))); … … 111 111 { 112 112 int i = 0; 113 for ( Iterator<SpaceShipAI>it = ObjectList<SpaceShipAI>::begin(); it; )113 for (ObjectList<SpaceShipAI>::iterator it = ObjectList<SpaceShipAI>::begin(); it; ) 114 114 { 115 115 (it++)->kill(); … … 229 229 this->doFire(); 230 230 231 S paceShip::tick(dt);231 SUPER(SpaceShipAI, tick, dt); 232 232 } 233 233 … … 263 263 this->forgetTarget(); 264 264 265 for ( Iterator<SpaceShip>it = ObjectList<SpaceShip>::begin(); it; ++it)265 for (ObjectList<SpaceShip>::iterator it = ObjectList<SpaceShip>::begin(); it; ++it) 266 266 { 267 267 if (it->getTeamNr() != this->getTeamNr()) -
code/trunk/src/orxonox/objects/SpaceShipAI.h
r1552 r1747 47 47 48 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 virtual void tick(float dt); 49 50 static void createEnemy(int num); 50 51 static void killEnemies(int num); … … 54 55 55 56 private: 56 virtual void tick(float dt);57 57 virtual ColourValue getProjectileColour() const; 58 58 -
code/trunk/src/orxonox/objects/Tickable.h
r1535 r1747 45 45 46 46 #include "core/OrxonoxClass.h" 47 #include "core/Super.h" 47 48 48 49 namespace orxonox … … 61 62 Tickable(); 62 63 }; 64 65 SUPER_FUNCTION(1, Tickable, tick, true); 63 66 64 67 //! The Tickable interface provides a tick(dt) function, that gets called every frame. -
code/trunk/src/orxonox/objects/WorldEntity.cc
r1625 r1747 95 95 } 96 96 97 98 97 void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll) 99 98 { … … 111 110 void WorldEntity::XMLPort(Element& xmlelement, XMLPort::Mode mode) 112 111 { 113 BaseObject::XMLPort(xmlelement, mode);112 SUPER(WorldEntity, XMLPort, xmlelement, mode); 114 113 115 XMLPortParam (WorldEntity, "position", setPositionLoader2, getPosition, xmlelement, mode);116 XMLPortParamLoadOnly(WorldEntity, "direction", setDirection Loader, xmlelement, mode);114 XMLPortParamExternTemplate(WorldEntity, Ogre::Node, this->node_, "position", setPosition, getPosition, xmlelement, mode, Ogre::Node, const Vector3&); 115 XMLPortParamLoadOnly(WorldEntity, "direction", setDirectionSimple, xmlelement, mode); 117 116 XMLPortParamLoadOnly(WorldEntity, "yawpitchroll", setYawPitchRoll, xmlelement, mode); 118 XMLPortParam(WorldEntity, "scale", set TotalScale, getScale, xmlelement, mode);119 XMLPortParam (WorldEntity, "rotationAxis", setRotationAxisLoader, getRotationAxis, xmlelement, mode);117 XMLPortParam(WorldEntity, "scale", setScale, getScale, xmlelement, mode); 118 XMLPortParamTemplate(WorldEntity, "rotationAxis", setRotationAxis, getRotationAxis, xmlelement, mode, WorldEntity, const Vector3&); 120 119 XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, mode); 121 120 … … 150 149 registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3); 151 150 // register scale of node 152 registerVar( (void*) &(this->getScale ().x), sizeof(this->getScale().x), network::DATA, 0x3);153 registerVar( (void*) &(this->getScale ().y), sizeof(this->getScale().y), network::DATA, 0x3);154 registerVar( (void*) &(this->getScale ().z), sizeof(this->getScale().z), network::DATA, 0x3);151 registerVar( (void*) &(this->getScale3D().x), sizeof(this->getScale3D().x), network::DATA, 0x3); 152 registerVar( (void*) &(this->getScale3D().y), sizeof(this->getScale3D().y), network::DATA, 0x3); 153 registerVar( (void*) &(this->getScale3D().z), sizeof(this->getScale3D().z), network::DATA, 0x3); 155 154 //register staticity 156 155 registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3); -
code/trunk/src/orxonox/objects/WorldEntity.h
r1625 r1747 65 65 inline void setPosition(const Vector3& pos) 66 66 { this->node_->setPosition(pos); } 67 inline void setPositionLoader1(const Vector3& pos)68 { this->node_->setPosition(pos); }69 inline void setPositionLoader2(Real x, Real y, Real z)70 { this->node_->setPosition(x, y, z); }71 67 inline void setPosition(Real x, Real y, Real z) 72 68 { this->node_->setPosition(x, y, z); } … … 108 104 inline void rotate(const Vector3& axis, const Radian& angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL) 109 105 { this->node_->rotate(axis, angle, relativeTo); } 110 inline void setDirection Loader(Real x, Real y, Real z)106 inline void setDirectionSimple(Real x, Real y, Real z) 111 107 { this->setDirection(x, y, z); } 112 108 inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector=Vector3::NEGATIVE_UNIT_Z) … … 117 113 { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); } 118 114 119 inline void setScale (const Vector3&scale)115 inline void setScale3D(const Vector3 &scale) 120 116 { this->node_->setScale(scale); } 121 inline void setScale (Real x, Real y, Real z)117 inline void setScale3D(Real x, Real y, Real z) 122 118 { this->node_->setScale(x, y, z); } 123 inline void setScale(Real scale) 119 inline const Vector3& getScale3D(void) const 120 { return this->node_->getScale(); } 121 inline void setScale(float scale) 124 122 { this->node_->setScale(scale, scale, scale); } 125 inline void setTotalScale(Real scale) 126 { this->node_->setScale(scale, scale, scale); } 127 inline const Vector3& getScale(void) const 128 { return this->node_->getScale(); } 129 inline void scale(const Vector3& scale) 123 inline float getScale() const 124 { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; } 125 inline void scale3D(const Vector3 &scale) 130 126 { this->node_->scale(scale); } 131 inline void scale (Real x, Real y, Real z)127 inline void scale3D(Real x, Real y, Real z) 132 128 { this->node_->scale(x, y, z); } 133 129 inline void scale(Real scale) … … 159 155 { return this->acceleration_; } 160 156 161 inline void setRotationAxisLoader(const Vector3& axis)162 { this->rotationAxis_ = axis; rotationAxis_.normalise(); }163 157 inline void setRotationAxis(const Vector3& axis) 164 { this->rotationAxis_ = axis; rotationAxis_.normalise(); }158 { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); } 165 159 inline void setRotationAxis(Real x, Real y, Real z) 166 160 { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); } -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r1633 r1747 51 51 std::map<std::string, OrxonoxOverlay*> OrxonoxOverlay::overlays_s; 52 52 53 SetConsoleCommand(OrxonoxOverlay, scaleOverlay, false). setAccessLevel(AccessLevel::User);54 SetConsoleCommand(OrxonoxOverlay, scrollOverlay, false). setAccessLevel(AccessLevel::User);55 SetConsoleCommand(OrxonoxOverlay, rotateOverlay, false). setAccessLevel(AccessLevel::User);53 SetConsoleCommand(OrxonoxOverlay, scaleOverlay, false).accessLevel(AccessLevel::User); 54 SetConsoleCommand(OrxonoxOverlay, scrollOverlay, false).accessLevel(AccessLevel::User); 55 SetConsoleCommand(OrxonoxOverlay, rotateOverlay, false).accessLevel(AccessLevel::User); 56 56 57 57 OrxonoxOverlay::OrxonoxOverlay() … … 84 84 @brief 85 85 Loads the OrxonoxOverlay. 86 86 87 87 This has to be called before usage, otherwise strange behaviour is 88 88 guaranteed! (there should be no segfaults however). … … 92 92 void OrxonoxOverlay::XMLPort(Element& xmlElement, XMLPort::Mode mode) 93 93 { 94 BaseObject::XMLPort(xmlElement, mode);94 SUPER(OrxonoxOverlay, XMLPort, xmlElement, mode); 95 95 96 96 if (mode == XMLPort::LoadObject) … … 267 267 if (angle > Ogre::Math::PI * 0.5) 268 268 angle = Ogre::Math::PI - angle; 269 269 270 270 // do some mathematical fiddling for a bounding box 271 271 Vector2 actualSize = size_ * sizeCorrection_; -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r1633 r1747 150 150 static void rotateOverlay(const std::string& name, const Degree& angle); 151 151 152 virtual void changedVisibility(); 153 152 154 protected: 153 virtual void changedVisibility();154 155 virtual void angleChanged(); 155 156 virtual void sizeCorrectionChanged(); -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r1633 r1747 35 35 #include "OverlayGroup.h" 36 36 37 #include " core/Debug.h"37 #include "util/Debug.h" 38 38 #include "core/ConsoleCommand.h" 39 39 #include "core/CoreIncludes.h" 40 #include "core/Iterator.h" 40 41 #include "core/XMLPort.h" 41 42 #include "OrxonoxOverlay.h" … … 45 46 CreateFactory(OverlayGroup); 46 47 47 SetConsoleCommand(OverlayGroup, toggleVisibility, false). setAccessLevel(AccessLevel::User);48 SetConsoleCommand(OverlayGroup, scaleGroup, false). setAccessLevel(AccessLevel::User);49 SetConsoleCommand(OverlayGroup, scrollGroup, false). setAccessLevel(AccessLevel::User);48 SetConsoleCommand(OverlayGroup, toggleVisibility, false).accessLevel(AccessLevel::User); 49 SetConsoleCommand(OverlayGroup, scaleGroup, false).accessLevel(AccessLevel::User); 50 SetConsoleCommand(OverlayGroup, scrollGroup, false).accessLevel(AccessLevel::User); 50 51 51 52 OverlayGroup::OverlayGroup() … … 62 63 void OverlayGroup::XMLPort(Element& xmlElement, XMLPort::Mode mode) 63 64 { 64 BaseObject::XMLPort(xmlElement, mode);65 SUPER(OverlayGroup, XMLPort, xmlElement, mode); 65 66 66 67 XMLPortParam(OverlayGroup, "scale", setScale, getScale, xmlElement, mode).defaultValues(Vector2(1.0, 1.0)); … … 135 136 /*static*/ void OverlayGroup::toggleVisibility(const std::string& name) 136 137 { 137 for ( Iterator<OverlayGroup>it = ObjectList<OverlayGroup>::begin(); it; ++it)138 for (ObjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it) 138 139 { 139 140 if ((*it)->getName() == name) … … 151 152 /*static*/ void OverlayGroup::scaleGroup(const std::string& name, float scale) 152 153 { 153 for ( Iterator<OverlayGroup>it = ObjectList<OverlayGroup>::begin(); it; ++it)154 for (ObjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it) 154 155 { 155 156 if ((*it)->getName() == name) … … 167 168 /*static*/ void OverlayGroup::scrollGroup(const std::string& name, const Vector2& scroll) 168 169 { 169 for ( Iterator<OverlayGroup>it = ObjectList<OverlayGroup>::begin(); it; ++it)170 for (ObjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it) 170 171 { 171 172 if ((*it)->getName() == name) -
code/trunk/src/orxonox/overlays/OverlayGroup.h
r1633 r1747 58 58 ~OverlayGroup() { } 59 59 60 v oid XMLPort(Element& xmlElement, XMLPort::Mode mode);60 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 61 61 62 62 static void toggleVisibility(const std::string& name); 63 63 static void scaleGroup(const std::string& name, float scale); 64 64 static void scrollGroup(const std::string& name, const Vector2& scroll); 65 66 void changedVisibility(); 65 67 66 68 private: … … 80 82 OrxonoxOverlay* getElement(unsigned int index); 81 83 82 void changedVisibility();83 84 84 std::map<std::string, OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 85 85 Vector2 scale_; //!< Current scale (independant of the elements). -
code/trunk/src/orxonox/overlays/OverlayText.cc
r1632 r1747 57 57 void OverlayText::XMLPort(Element& xmlElement, XMLPort::Mode mode) 58 58 { 59 OrxonoxOverlay::XMLPort(xmlElement, mode);59 SUPER(OverlayText, XMLPort, xmlElement, mode); 60 60 61 61 if (mode == XMLPort::LoadObject) -
code/trunk/src/orxonox/overlays/console/InGameConsole.cc
r1633 r1747 41 41 #include "util/Math.h" 42 42 #include "util/Convert.h" 43 #include " core/Debug.h"43 #include "util/Debug.h" 44 44 #include "core/CoreIncludes.h" 45 45 #include "core/ConfigValueIncludes.h" -
code/trunk/src/orxonox/overlays/console/InGameConsole.h
r1625 r1747 50 50 void setConfigValues(); 51 51 52 v oid tick(float dt);52 virtual void tick(float dt); 53 53 54 54 static InGameConsole& getInstance(); -
code/trunk/src/orxonox/overlays/debug/DebugFPSText.h
r1625 r1747 43 43 ~DebugFPSText(); 44 44 45 private: 46 void tick(float dt); 47 48 private: 45 virtual void tick(float dt); 49 46 }; 50 47 } -
code/trunk/src/orxonox/overlays/debug/DebugRTRText.h
r1625 r1747 43 43 ~DebugRTRText(); 44 44 45 private: 46 void tick(float dt); 45 virtual void tick(float dt); 47 46 }; 48 47 } -
code/trunk/src/orxonox/overlays/hud/HUDBar.cc
r1628 r1747 53 53 void BarColour::XMLPort(Element& xmlElement, XMLPort::Mode mode) 54 54 { 55 BaseObject::XMLPort(xmlElement, mode);55 SUPER(BarColour, XMLPort, xmlElement, mode); 56 56 57 57 XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode) … … 78 78 void HUDBar::XMLPort(Element& xmlElement, XMLPort::Mode mode) 79 79 { 80 OrxonoxOverlay::XMLPort(xmlElement, mode);80 SUPER(HUDBar, XMLPort, xmlElement, mode); 81 81 82 82 if (mode == XMLPort::LoadObject) -
code/trunk/src/orxonox/overlays/hud/HUDBar.h
r1627 r1747 47 47 ~BarColour() { } 48 48 49 v oid XMLPort(Element& xmlElement, XMLPort::Mode mode);49 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 50 50 51 51 void setColour(const ColourValue& colour) { this->colour_ = colour; } -
code/trunk/src/orxonox/overlays/hud/HUDNavigation.cc
r1628 r1747 69 69 void HUDNavigation::XMLPort(Element& xmlElement, XMLPort::Mode mode) 70 70 { 71 OrxonoxOverlay::XMLPort(xmlElement, mode);71 SUPER(HUDNavigation, XMLPort, xmlElement, mode); 72 72 73 73 if (mode == XMLPort::LoadObject) … … 87 87 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberStr())); 88 88 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 89 89 90 90 background_->addChild(navMarker_); 91 91 background_->addChild(aimMarker_); -
code/trunk/src/orxonox/overlays/hud/HUDNavigation.h
r1627 r1747 44 44 ~HUDNavigation(); 45 45 46 void XMLPort(Element& xmlElement, XMLPort::Mode mode); 46 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 47 virtual void tick(float dt); 47 48 48 49 private: … … 50 51 void angleChanged() { } 51 52 void positionChanged() { } 52 53 void tick(float dt);54 53 55 54 // XMLPort accessors -
code/trunk/src/orxonox/overlays/hud/HUDRadar.cc
r1628 r1747 66 66 void HUDRadar::XMLPort(Element& xmlElement, XMLPort::Mode mode) 67 67 { 68 OrxonoxOverlay::XMLPort(xmlElement, mode);68 SUPER(HUDRadar, XMLPort, xmlElement, mode); 69 69 70 70 if (mode == XMLPort::LoadObject) -
code/trunk/src/orxonox/overlays/hud/HUDRadar.h
r1625 r1747 48 48 ~HUDRadar(); 49 49 50 v oid XMLPort(Element& xmlElement, XMLPort::Mode mode);50 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 51 51 52 52 private: -
code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h
r1625 r1747 44 44 ~HUDSpeedBar(); 45 45 46 private: 47 void tick(float dt); 46 virtual void tick(float dt); 48 47 }; 49 48 } -
code/trunk/src/orxonox/tools/WindowEventListener.cc
r1625 r1747 38 38 WindowEventListener::WindowEventListener() 39 39 { 40 Register Object(WindowEventListener);40 RegisterRootObject(WindowEventListener); 41 41 } 42 42 } -
code/trunk/src/util/CMakeLists.txt
r1505 r1747 2 2 ArgReader.cc 3 3 Clipboard.cc 4 Error.cc 4 5 ExprParser.cc 5 6 Math.cc 6 MultiType Primitive.cc7 MultiTypeString.cc8 MultiTypeMath.cc7 MultiType.cc 8 OutputBuffer.cc 9 OutputHandler.cc 9 10 String.cc 10 11 SubString.cc -
code/trunk/src/util/Convert.h
r1625 r1747 41 41 42 42 #include "Math.h" 43 #include "Debug.h" 43 44 #include "SubString.h" 44 #include "MultiTypeMath.h"45 45 #include "String.h" 46 46 … … 75 75 enum { specialized = false }; 76 76 static bool convert(ToType* output, const FromType& input) 77 { return false; } 77 { 78 COUT(2) << "Warning: Couldn't convert a value: From \"" << typeid(FromType).name() << "\" to \"" << typeid(ToType).name() << "\"" << std::endl; 79 return false; 80 } 78 81 }; 79 82 … … 95 98 96 99 // Defines the levels of all types: Default is __high__ so you don't have to define every high-level type 97 template <class T> struct ConverterLevel { enum { level = __high__ }; }; 98 template <> struct ConverterLevel<std::string> { enum { level = __mid__ }; }; 99 template <> struct ConverterLevel<orxonox::Radian> { enum { level = __mid__ }; }; 100 template <> struct ConverterLevel<orxonox::Degree> { enum { level = __mid__ }; }; 101 template <> struct ConverterLevel<int> { enum { level = __low__ }; }; 102 template <> struct ConverterLevel<unsigned int> { enum { level = __low__ }; }; 103 template <> struct ConverterLevel<char> { enum { level = __low__ }; }; 104 template <> struct ConverterLevel<unsigned char> { enum { level = __low__ }; }; 105 template <> struct ConverterLevel<short> { enum { level = __low__ }; }; 106 template <> struct ConverterLevel<unsigned short> { enum { level = __low__ }; }; 107 template <> struct ConverterLevel<long> { enum { level = __low__ }; }; 108 template <> struct ConverterLevel<unsigned long> { enum { level = __low__ }; }; 109 template <> struct ConverterLevel<float> { enum { level = __low__ }; }; 110 template <> struct ConverterLevel<double> { enum { level = __low__ }; }; 111 template <> struct ConverterLevel<long double> { enum { level = __low__ }; }; 112 template <> struct ConverterLevel<bool> { enum { level = __low__ }; }; 100 template <class T> struct ConverterLevel { enum { level = __high__ }; }; 101 template <> struct ConverterLevel<std::string> { enum { level = __mid__ }; }; 102 template <> struct ConverterLevel<orxonox::Radian> { enum { level = __mid__ }; }; 103 template <> struct ConverterLevel<orxonox::Degree> { enum { level = __mid__ }; }; 104 template <> struct ConverterLevel<int> { enum { level = __low__ }; }; 105 template <> struct ConverterLevel<unsigned int> { enum { level = __low__ }; }; 106 template <> struct ConverterLevel<char> { enum { level = __low__ }; }; 107 template <> struct ConverterLevel<unsigned char> { enum { level = __low__ }; }; 108 template <> struct ConverterLevel<short> { enum { level = __low__ }; }; 109 template <> struct ConverterLevel<unsigned short> { enum { level = __low__ }; }; 110 template <> struct ConverterLevel<long> { enum { level = __low__ }; }; 111 template <> struct ConverterLevel<unsigned long> { enum { level = __low__ }; }; 112 template <> struct ConverterLevel<long long> { enum { level = __low__ }; }; 113 template <> struct ConverterLevel<unsigned long long> { enum { level = __low__ }; }; 114 template <> struct ConverterLevel<float> { enum { level = __low__ }; }; 115 template <> struct ConverterLevel<double> { enum { level = __low__ }; }; 116 template <> struct ConverterLevel<long double> { enum { level = __low__ }; }; 117 template <> struct ConverterLevel<bool> { enum { level = __low__ }; }; 113 118 114 119 … … 140 145 static bool convert(ToType* output, const FromType& input) 141 146 { 147 COUT(2) << "Warning: Couldn't convert a value: From \"" << typeid(FromType).name() << "\" to \"" << typeid(ToType).name() << "\"" << std::endl; 142 148 return false; 143 149 } … … 330 336 331 337 332 //////////////// 333 // MULTITYPES // 334 //////////////// 335 336 // convert from MultiTypePrimitive 337 template <class ToType> 338 struct ConverterSpecialized<MultiTypePrimitive, ToType, _FromType_> 339 { 340 enum { specialized = true }; 341 static bool convert(ToType* output, const MultiTypePrimitive& input) 342 { 343 if (input.getType() == MT_void) 344 return ConvertValue(output, input.getVoid()); 345 else if (input.getType() == MT_int) 346 return ConvertValue(output, input.getInt()); 347 else if (input.getType() == MT_uint) 348 return ConvertValue(output, input.getUnsignedInt()); 349 else if (input.getType() == MT_char) 350 return ConvertValue(output, input.getChar()); 351 else if (input.getType() == MT_uchar) 352 return ConvertValue(output, input.getUnsignedChar()); 353 else if (input.getType() == MT_short) 354 return ConvertValue(output, input.getShort()); 355 else if (input.getType() == MT_ushort) 356 return ConvertValue(output, input.getUnsignedShort()); 357 else if (input.getType() == MT_long) 358 return ConvertValue(output, input.getLong()); 359 else if (input.getType() == MT_ulong) 360 return ConvertValue(output, input.getUnsignedLong()); 361 else if (input.getType() == MT_float) 362 return ConvertValue(output, input.getFloat()); 363 else if (input.getType() == MT_double) 364 return ConvertValue(output, input.getDouble()); 365 else if (input.getType() == MT_longdouble) 366 return ConvertValue(output, input.getLongDouble()); 367 else if (input.getType() == MT_bool) 368 return ConvertValue(output, input.getBool()); 369 else 370 return false; 371 } 372 }; 373 374 // convert from MultiTypeString 375 template <class ToType> 376 struct ConverterSpecialized<MultiTypeString, ToType, _FromType_> 377 { 378 enum { specialized = true }; 379 static bool convert(ToType* output, const MultiTypeString& input) 380 { 381 if (input.getType() == MT_constchar) 382 return ConvertValue(output, input.getConstChar()); 383 else if (input.getType() == MT_string) 384 return ConvertValue(output, input.getString()); 385 else 386 return ConvertValue(output, (MultiTypePrimitive)input); 387 } 388 }; 389 390 // convert from MultiTypeMath 391 template <class ToType> 392 struct ConverterSpecialized<MultiTypeMath, ToType, _FromType_> 393 { 394 enum { specialized = true }; 395 static bool convert(ToType* output, const MultiTypeMath& input) 396 { 397 if (input.getType() == MT_vector2) 398 return ConvertValue(output, input.getVector2()); 399 else if (input.getType() == MT_vector3) 400 return ConvertValue(output, input.getVector3()); 401 else if (input.getType() == MT_vector4) 402 return ConvertValue(output, input.getVector4()); 403 else if (input.getType() == MT_quaternion) 404 return ConvertValue(output, input.getQuaternion()); 405 else if (input.getType() == MT_colourvalue) 406 return ConvertValue(output, input.getColourValue()); 407 else if (input.getType() == MT_radian) 408 return ConvertValue(output, input.getRadian()); 409 else if (input.getType() == MT_degree) 410 return ConvertValue(output, input.getDegree()); 411 else 412 return ConvertValue(output, (MultiTypeString)input); 338 ////////// 339 // MATH // 340 ////////// 341 // convert everything to Degree 342 template <class FromType> 343 struct ConverterSpecialized<FromType, Ogre::Degree, _ToType_> 344 { 345 enum { specialized = true }; 346 static bool convert(Ogre::Degree* output, const FromType& input) 347 { 348 float angle = 0; 349 bool success = ConvertValue<FromType, float>(&angle, input); 350 (*output) = angle; 351 return success; 352 } 353 }; 354 355 // convert everything to Radian 356 template <class FromType> 357 struct ConverterSpecialized<FromType, Ogre::Radian, _ToType_> 358 { 359 enum { specialized = true }; 360 static bool convert(Ogre::Radian* output, const FromType& input) 361 { 362 float angle = 0; 363 bool success = ConvertValue<FromType, float>(&angle, input); 364 (*output) = angle; 365 return success; 413 366 } 414 367 }; -
code/trunk/src/util/MultiType.h
r1505 r1747 25 25 * ... 26 26 * 27 * Inspiration: MultiType by Benjamin Grauer28 27 */ 29 28 … … 33 32 #include "UtilPrereqs.h" 34 33 35 enum _UtilExport MultiType 34 #include <boost/static_assert.hpp> 35 36 #include "Math.h" 37 38 enum MT_Type 36 39 { 37 40 MT_null, 38 MT_void,39 MT_int,40 MT_uint,41 41 MT_char, 42 42 MT_uchar, 43 43 MT_short, 44 44 MT_ushort, 45 MT_int, 46 MT_uint, 45 47 MT_long, 46 48 MT_ulong, 49 MT_longlong, 50 MT_ulonglong, 47 51 MT_float, 48 52 MT_double, 49 53 MT_longdouble, 50 54 MT_bool, 51 MT_ constchar,55 MT_void, 52 56 MT_string, 53 MT_xmlelement,54 57 MT_vector2, 55 58 MT_vector3, … … 57 60 MT_colourvalue, 58 61 MT_quaternion, 59 MT_ degree,60 MT_ radian62 MT_radian, 63 MT_degree 61 64 }; 62 65 63 union _UtilExport MultiTypeValue66 class _UtilExport MultiType 64 67 { 65 void* void_; 66 int int_; 67 unsigned int uint_; 68 char char_; 69 unsigned char uchar_; 70 short short_; 71 unsigned short ushort_; 72 long long_; 73 unsigned long ulong_; 74 float float_; 75 double double_; 76 long double longdouble_; 77 bool bool_; 68 _UtilExport friend std::ostream& operator<<(std::ostream& outstream, const MultiType& mt); 69 template <typename T> friend struct MT_Value; 70 71 struct _UtilExport MT_ValueBase 72 { 73 MT_ValueBase(MT_Type type) : type_(type) {} 74 virtual ~MT_ValueBase() {} 75 76 virtual MT_ValueBase* clone() const = 0; 77 78 virtual void reset() = 0; 79 virtual void assimilate(const MultiType& other) = 0; 80 const MT_Type& getType() const { return this->type_; } 81 82 virtual void setValue(const char& value) = 0; 83 virtual void setValue(const unsigned char& value) = 0; 84 virtual void setValue(const short& value) = 0; 85 virtual void setValue(const unsigned short& value) = 0; 86 virtual void setValue(const int& value) = 0; 87 virtual void setValue(const unsigned int& value) = 0; 88 virtual void setValue(const long& value) = 0; 89 virtual void setValue(const unsigned long& value) = 0; 90 virtual void setValue(const long long& value) = 0; 91 virtual void setValue(const unsigned long long& value) = 0; 92 virtual void setValue(const float& value) = 0; 93 virtual void setValue(const double& value) = 0; 94 virtual void setValue(const long double& value) = 0; 95 virtual void setValue(const bool& value) = 0; 96 virtual void setValue( void* const& value) = 0; 97 virtual void setValue(const std::string& value) = 0; 98 virtual void setValue(const orxonox::Vector2& value) = 0; 99 virtual void setValue(const orxonox::Vector3& value) = 0; 100 virtual void setValue(const orxonox::Vector4& value) = 0; 101 virtual void setValue(const orxonox::ColourValue& value) = 0; 102 virtual void setValue(const orxonox::Quaternion& value) = 0; 103 virtual void setValue(const orxonox::Radian& value) = 0; 104 virtual void setValue(const orxonox::Degree& value) = 0; 105 106 virtual operator char() const = 0; 107 virtual operator unsigned char() const = 0; 108 virtual operator short() const = 0; 109 virtual operator unsigned short() const = 0; 110 virtual operator int() const = 0; 111 virtual operator unsigned int() const = 0; 112 virtual operator long() const = 0; 113 virtual operator unsigned long() const = 0; 114 virtual operator long long() const = 0; 115 virtual operator unsigned long long() const = 0; 116 virtual operator float() const = 0; 117 virtual operator double() const = 0; 118 virtual operator long double() const = 0; 119 virtual operator bool() const = 0; 120 virtual operator void*() const = 0; 121 virtual operator std::string() const = 0; 122 virtual operator orxonox::Vector2() const = 0; 123 virtual operator orxonox::Vector3() const = 0; 124 virtual operator orxonox::Vector4() const = 0; 125 virtual operator orxonox::ColourValue() const = 0; 126 virtual operator orxonox::Quaternion() const = 0; 127 virtual operator orxonox::Radian() const = 0; 128 virtual operator orxonox::Degree() const = 0; 129 130 virtual void toString(std::ostream& outstream) const = 0; 131 132 MT_Type type_; 133 }; 134 135 public: 136 inline MultiType() : value_(0) {} 137 inline MultiType(const char& value) : value_(0) { this->assignValue(value); } 138 inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } 139 inline MultiType(const short& value) : value_(0) { this->assignValue(value); } 140 inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } 141 inline MultiType(const int& value) : value_(0) { this->assignValue(value); } 142 inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } 143 inline MultiType(const long& value) : value_(0) { this->assignValue(value); } 144 inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } 145 inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } 146 inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } 147 inline MultiType(const float& value) : value_(0) { this->assignValue(value); } 148 inline MultiType(const double& value) : value_(0) { this->assignValue(value); } 149 inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } 150 inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } 151 inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } 152 inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } 153 inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } 154 inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } 155 inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } 156 inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } 157 inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } 158 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } 159 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } 160 inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } 161 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } 162 inline MultiType(MT_Type type) : value_(0) { this->setType(type); } 163 164 inline ~MultiType() { if (this->value_) { delete this->value_; } } 165 166 template <typename V> inline MultiType& operator=(const V& value) { this->setValue(value); return (*this); } 167 inline MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } 168 inline MultiType& operator=(MT_Type type) { this->setType(type); return (*this); } 169 170 inline void setValue(const char& value); 171 inline void setValue(const unsigned char& value); 172 inline void setValue(const short& value); 173 inline void setValue(const unsigned short& value); 174 inline void setValue(const int& value); 175 inline void setValue(const unsigned int& value); 176 inline void setValue(const long& value); 177 inline void setValue(const unsigned long& value); 178 inline void setValue(const long long& value); 179 inline void setValue(const unsigned long long& value); 180 inline void setValue(const float& value); 181 inline void setValue(const double& value); 182 inline void setValue(const long double& value); 183 inline void setValue(const bool& value); 184 inline void setValue( void* const& value); 185 inline void setValue(const std::string& value); 186 inline void setValue(const orxonox::Vector2& value); 187 inline void setValue(const orxonox::Vector3& value); 188 inline void setValue(const orxonox::Vector4& value); 189 inline void setValue(const orxonox::ColourValue& value); 190 inline void setValue(const orxonox::Quaternion& value); 191 inline void setValue(const orxonox::Radian& value); 192 inline void setValue(const orxonox::Degree& value); 193 template <typename V> inline void setValue(V* value) { if (this->value_) { this->value_->setValue((void*)value); } else { this->assignValue((void*)value); } } 194 void setValue(const MultiType& other) { if (this->value_) { this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } } } 195 template <typename T, typename V> inline void setValue(const V& value) { this->setType<T>(); this->setValue(value); } 196 inline void setValue(const char* value); 197 198 inline void copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; } 199 200 template <typename T> inline void convert() { this->setValue<T>((T)(*this)); } 201 inline void convert(const MultiType& other) { this->convert(other.getType()); } 202 void convert(MT_Type type); 203 204 inline void reset() { if (this->value_) { delete this->value_; this->value_ = 0; } } 205 206 template <typename T> inline void setType() { this->assignValue(T()); } 207 inline void setType(const MultiType& other) { this->setType(other.getType()); } 208 inline void setType(MT_Type type) { this->reset(); this->convert(type); } 209 210 inline MT_Type getType() const { return (this->value_) ? this->value_->type_ : MT_null; } 211 inline bool isType(MT_Type type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_null); } 212 template <typename T> inline bool isType() const { return false; } 213 std::string getTypename() const; 214 215 operator char() const; 216 operator unsigned char() const; 217 operator short() const; 218 operator unsigned short() const; 219 operator int() const; 220 operator unsigned int() const; 221 operator long() const; 222 operator unsigned long() const; 223 operator long long() const; 224 operator unsigned long long() const; 225 operator float() const; 226 operator double() const; 227 operator long double() const; 228 operator bool() const; 229 operator void*() const; 230 operator std::string() const; 231 operator orxonox::Vector2() const; 232 operator orxonox::Vector3() const; 233 operator orxonox::Vector4() const; 234 operator orxonox::ColourValue() const; 235 operator orxonox::Quaternion() const; 236 operator orxonox::Radian() const; 237 operator orxonox::Degree() const; 238 template <class T> operator T*() const { return ((T*)this->operator void*()); } 239 240 inline void getValue(char* value) const { if (this->value_) { (*value) = (*this->value_); } } 241 inline void getValue(unsigned char* value) const { if (this->value_) { (*value) = (*this->value_); } } 242 inline void getValue(short* value) const { if (this->value_) { (*value) = (*this->value_); } } 243 inline void getValue(unsigned short* value) const { if (this->value_) { (*value) = (*this->value_); } } 244 inline void getValue(int* value) const { if (this->value_) { (*value) = (*this->value_); } } 245 inline void getValue(unsigned int* value) const { if (this->value_) { (*value) = (*this->value_); } } 246 inline void getValue(long* value) const { if (this->value_) { (*value) = (*this->value_); } } 247 inline void getValue(unsigned long* value) const { if (this->value_) { (*value) = (*this->value_); } } 248 inline void getValue(long long* value) const { if (this->value_) { (*value) = (*this->value_); } } 249 inline void getValue(unsigned long long* value) const { if (this->value_) { (*value) = (*this->value_); } } 250 inline void getValue(float* value) const { if (this->value_) { (*value) = (*this->value_); } } 251 inline void getValue(double* value) const { if (this->value_) { (*value) = (*this->value_); } } 252 inline void getValue(long double* value) const { if (this->value_) { (*value) = (*this->value_); } } 253 inline void getValue(bool* value) const { if (this->value_) { (*value) = (*this->value_); } } 254 inline void getValue(void* value) const { if (this->value_) { value = (*this->value_); } } 255 inline void getValue(std::string* value) const { if (this->value_) { (*value) = this->value_->operator std::string(); } } 256 inline void getValue(orxonox::Vector2* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector2(); } } 257 inline void getValue(orxonox::Vector3* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector3(); } } 258 inline void getValue(orxonox::Vector4* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector4(); } } 259 inline void getValue(orxonox::ColourValue* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::ColourValue(); } } 260 inline void getValue(orxonox::Quaternion* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Quaternion(); } } 261 inline void getValue(orxonox::Radian* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Radian(); } } 262 inline void getValue(orxonox::Degree* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Degree(); } } 263 264 inline char getChar() const { return this->operator char(); } 265 inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } 266 inline short getShort() const { return this->operator short(); } 267 inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } 268 inline int getInt() const { return this->operator int(); } 269 inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } 270 inline long getLong() const { return this->operator long(); } 271 inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } 272 inline long long getLongLong() const { return this->operator long long(); } 273 inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } 274 inline float getFloat() const { return this->operator float(); } 275 inline double getDouble() const { return this->operator double(); } 276 inline long double getLongDouble() const { return this->operator long double(); } 277 inline bool getBool() const { return this->operator bool(); } 278 inline void* getVoid() const { return this->operator void*(); } 279 inline std::string getString() const { return this->operator std::string(); } 280 inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } 281 inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } 282 inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } 283 inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } 284 inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } 285 inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } 286 inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } 287 template <typename T> inline T* getPointer() const { return ((T*)this->getVoid()); } 288 289 private: 290 inline void assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_char) { this->value_->setValue(value); } else { this->changeValueContainer<char>(value); } } 291 inline void assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_uchar) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); } } 292 inline void assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_short) { this->value_->setValue(value); } else { this->changeValueContainer<short>(value); } } 293 inline void assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_ushort) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); } } 294 inline void assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_int) { this->value_->setValue(value); } else { this->changeValueContainer<int>(value); } } 295 inline void assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_uint) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); } } 296 inline void assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_long) { this->value_->setValue(value); } else { this->changeValueContainer<long>(value); } } 297 inline void assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_ulong) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); } } 298 inline void assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_longlong) { this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); } } 299 inline void assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_ulonglong) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); } } 300 inline void assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_float) { this->value_->setValue(value); } else { this->changeValueContainer<float>(value); } } 301 inline void assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_double) { this->value_->setValue(value); } else { this->changeValueContainer<double>(value); } } 302 inline void assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_longdouble) { this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); } } 303 inline void assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_bool) { this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); } } 304 inline void assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_void) { this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); } } 305 inline void assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_string) { this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); } } 306 inline void assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_vector2) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); } } 307 inline void assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_vector3) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); } } 308 inline void assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_vector4) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); } } 309 inline void assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); } } 310 inline void assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_quaternion) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); } } 311 inline void assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_radian) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); } } 312 inline void assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_degree) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); } } 313 314 template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); } 315 template <typename T> void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); } 316 317 MT_ValueBase* value_; 78 318 }; 79 319 320 _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; } 321 322 template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_char); } 323 template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_uchar); } 324 template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_short); } 325 template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_ushort); } 326 template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_int); } 327 template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_uint); } 328 template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_long); } 329 template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_ulong); } 330 template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_longlong); } 331 template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_ulonglong); } 332 template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_float); } 333 template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_double); } 334 template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_longdouble); } 335 template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_bool); } 336 template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_void); } 337 template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_string); } 338 template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_vector2); } 339 template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_vector3); } 340 template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_vector4); } 341 template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_colourvalue); } 342 template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_quaternion); } 343 template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_radian); } 344 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_degree); } 345 346 template <> inline void MultiType::convert<std::string>() { this->setValue<std::string> (this->operator std::string()); } 347 template <> inline void MultiType::convert<orxonox::Vector2>() { this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } 348 template <> inline void MultiType::convert<orxonox::Vector3>() { this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } 349 template <> inline void MultiType::convert<orxonox::Vector4>() { this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } 350 template <> inline void MultiType::convert<orxonox::ColourValue>() { this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } 351 template <> inline void MultiType::convert<orxonox::Quaternion>() { this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } 352 template <> inline void MultiType::convert<orxonox::Radian>() { this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } 353 template <> inline void MultiType::convert<orxonox::Degree>() { this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } 354 355 template <> inline void MultiType::convert<const std::string&>() { this->convert<std::string>(); } 356 template <> inline void MultiType::convert<const orxonox::Vector2&>() { this->convert<orxonox::Vector2>(); } 357 template <> inline void MultiType::convert<const orxonox::Vector3&>() { this->convert<orxonox::Vector3>(); } 358 template <> inline void MultiType::convert<const orxonox::Vector4&>() { this->convert<orxonox::Vector4>(); } 359 template <> inline void MultiType::convert<const orxonox::ColourValue&>() { this->convert<orxonox::ColourValue>(); } 360 template <> inline void MultiType::convert<const orxonox::Quaternion&>() { this->convert<orxonox::Quaternion>(); } 361 template <> inline void MultiType::convert<const orxonox::Radian&>() { this->convert<orxonox::Radian>(); } 362 template <> inline void MultiType::convert<const orxonox::Degree&>() { this->convert<orxonox::Degree>(); } 363 364 template <> void MultiType::createNewValueContainer(const char& value); 365 template <> void MultiType::createNewValueContainer(const unsigned char& value); 366 template <> void MultiType::createNewValueContainer(const short& value); 367 template <> void MultiType::createNewValueContainer(const unsigned short& value); 368 template <> void MultiType::createNewValueContainer(const int& value); 369 template <> void MultiType::createNewValueContainer(const unsigned int& value); 370 template <> void MultiType::createNewValueContainer(const long& value); 371 template <> void MultiType::createNewValueContainer(const unsigned long& value); 372 template <> void MultiType::createNewValueContainer(const long long& value); 373 template <> void MultiType::createNewValueContainer(const unsigned long long& value); 374 template <> void MultiType::createNewValueContainer(const float& value); 375 template <> void MultiType::createNewValueContainer(const double& value); 376 template <> void MultiType::createNewValueContainer(const bool& value); 377 template <> void MultiType::createNewValueContainer(const long double& value); 378 template <> void MultiType::createNewValueContainer( void* const& value); 379 template <> void MultiType::createNewValueContainer(const std::string& value); 380 template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value); 381 template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value); 382 template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value); 383 template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value); 384 template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value); 385 template <> void MultiType::createNewValueContainer(const orxonox::Radian& value); 386 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value); 387 388 inline void MultiType::setValue(const char& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 389 inline void MultiType::setValue(const unsigned char& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 390 inline void MultiType::setValue(const short& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 391 inline void MultiType::setValue(const unsigned short& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 392 inline void MultiType::setValue(const int& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 393 inline void MultiType::setValue(const unsigned int& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 394 inline void MultiType::setValue(const long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 395 inline void MultiType::setValue(const unsigned long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 396 inline void MultiType::setValue(const long long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 397 inline void MultiType::setValue(const unsigned long long& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 398 inline void MultiType::setValue(const float& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 399 inline void MultiType::setValue(const double& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 400 inline void MultiType::setValue(const long double& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 401 inline void MultiType::setValue(const bool& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 402 inline void MultiType::setValue( void* const& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 403 inline void MultiType::setValue(const std::string& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 404 inline void MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 405 inline void MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 406 inline void MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 407 inline void MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 408 inline void MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 409 inline void MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 410 inline void MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } 411 412 inline void MultiType::setValue(const char* value) { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->assignValue(std::string(value)); } } 413 80 414 #endif /* _MultiType_H__ */ -
code/trunk/src/util/UtilPrereqs.h
r1735 r1747 62 62 class ArgReader; 63 63 class Convert; 64 class MultiTypePrimitive; 65 class MultiTypeString; 66 class MultiTypeMath; 67 template <class T> 68 class String2Number; 64 class ExprParser; 65 class MultiType; 69 66 class SubString; 67 namespace orxonox 68 { 69 class OutputBuffer; 70 class OutputBufferListener; 71 class Error; 72 class OutputHandler; 73 } 74 70 75 #endif /* _UtilPrereqs_H__ */ -
code/trunk/visual_studio/core_properties.vsprops
r1572 r1747 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalOptions="/MP2" 10 11 PreprocessorDefinitions="CORE_SHARED_BUILD" 11 12 /> -
code/trunk/visual_studio/network_properties.vsprops
r1293 r1747 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalOptions="/MP2" 10 11 PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD;WIN32_LEAN_AND_MEAN" 11 12 /> -
code/trunk/visual_studio/orxonox_properties.vsprops
r1572 r1747 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalOptions="/MP2" 10 11 PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD" 11 12 UsePrecompiledHeader="2" -
code/trunk/visual_studio/vc8/core.vcproj
r1631 r1747 161 161 </File> 162 162 <File 163 RelativePath="..\..\src\core\Error.cc"164 >165 </File>166 <File167 163 RelativePath="..\..\src\core\Language.cc" 168 164 > … … 173 169 </File> 174 170 <File 175 RelativePath="..\..\src\core\OutputBuffer.cc"176 >177 </File>178 <File179 RelativePath="..\..\src\core\OutputHandler.cc"180 >181 </File>182 <File183 171 RelativePath="..\..\src\core\Script.cc" 184 >185 </File>186 <File187 RelativePath="..\..\src\core\SignalHandler.cc"188 172 > 189 173 </File> … … 253 237 > 254 238 </File> 239 <File 240 RelativePath="..\..\src\core\ObjectListBase.cc" 241 > 242 </File> 255 243 </Filter> 256 244 <Filter … … 365 353 </File> 366 354 <File 367 RelativePath="..\..\src\core\Debug.h"368 >369 </File>370 <File371 RelativePath="..\..\src\core\Error.h"372 >373 </File>374 <File375 355 RelativePath="..\..\src\core\Language.h" 376 356 > … … 381 361 </File> 382 362 <File 383 RelativePath="..\..\src\core\OutputBuffer.h"384 >385 </File>386 <File387 RelativePath="..\..\src\core\OutputHandler.h"388 >389 </File>390 <File391 363 RelativePath="..\..\src\core\Script.h" 392 364 > … … 397 369 </File> 398 370 <File 399 RelativePath="..\..\src\core\S ignalHandler.h"371 RelativePath="..\..\src\core\Super.h" 400 372 > 401 373 </File> … … 524 496 </File> 525 497 <File 498 RelativePath="..\..\src\core\IteratorBase.h" 499 > 500 </File> 501 <File 526 502 RelativePath="..\..\src\core\MetaObjectList.h" 527 503 > … … 529 505 <File 530 506 RelativePath="..\..\src\core\ObjectList.h" 507 > 508 </File> 509 <File 510 RelativePath="..\..\src\core\ObjectListBase.h" 531 511 > 532 512 </File> -
code/trunk/visual_studio/vc8/orxonox.vcproj
r1625 r1747 189 189 </File> 190 190 <File 191 RelativePath="..\..\src\orxonox\SignalHandler.cc" 192 > 193 </File> 194 <Filter 195 Name="hud" 196 <File 191 197 RelativePath="..\..\src\orxonox\RadarListener.cc" 192 198 > … … 558 564 <File 559 565 RelativePath="..\..\src\orxonox\Settings.h" 566 > 567 </File> 568 <File 569 RelativePath="..\..\src\orxonox\SignalHandler.h" 560 570 > 561 571 </File> -
code/trunk/visual_studio/vc8/util.vcproj
r1735 r1747 161 161 </File> 162 162 <File 163 RelativePath="..\..\src\util\Error.cc" 164 > 165 </File> 166 <File 163 167 RelativePath="..\..\src\util\ExprParser.cc" 164 168 > … … 169 173 </File> 170 174 <File 171 RelativePath="..\..\src\util\MultiType Math.cc"172 > 173 </File> 174 <File 175 RelativePath="..\..\src\util\ MultiTypePrimitive.cc"176 > 177 </File> 178 <File 179 RelativePath="..\..\src\util\ MultiTypeString.cc"175 RelativePath="..\..\src\util\MultiType.cc" 176 > 177 </File> 178 <File 179 RelativePath="..\..\src\util\OutputBuffer.cc" 180 > 181 </File> 182 <File 183 RelativePath="..\..\src\util\OutputHandler.cc" 180 184 > 181 185 </File> … … 211 215 </File> 212 216 <File 217 RelativePath="..\..\src\util\Debug.h" 218 > 219 </File> 220 <File 221 RelativePath="..\..\src\util\Error.h" 222 > 223 </File> 224 <File 213 225 RelativePath="..\..\src\util\ExprParser.h" 214 226 > … … 223 235 </File> 224 236 <File 225 RelativePath="..\..\src\util\MultiTypeMath.h" 226 > 227 </File> 228 <File 229 RelativePath="..\..\src\util\MultiTypePrimitive.h" 230 > 231 </File> 232 <File 233 RelativePath="..\..\src\util\MultiTypeString.h" 237 RelativePath="..\..\src\util\MultiTypeValue.h" 234 238 > 235 239 </File> 236 240 <File 237 241 RelativePath="..\..\src\util\OrxonoxPlatform.h" 242 > 243 </File> 244 <File 245 RelativePath="..\..\src\util\OutputBuffer.h" 246 > 247 </File> 248 <File 249 RelativePath="..\..\src\util\OutputHandler.h" 238 250 > 239 251 </File>
Note: See TracChangeset
for help on using the changeset viewer.