Changeset 947 for code/branches/core2
- Timestamp:
- Mar 28, 2008, 10:13:58 PM (17 years ago)
- Location:
- code/branches/core2/src
- Files:
-
- 3 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/core/CMakeLists.txt
r895 r947 19 19 Namespace.cc 20 20 NamespaceNode.cc 21 CommandExecutor.cc 21 22 ) 22 23 -
code/branches/core2/src/orxonox/core/ConfigValueContainer.cc
r871 r947 181 181 @return True if the string was successfully parsed 182 182 */ 183 bool ConfigValueContainer::parseString(const std::string& input, MultiTypeMath& defvalue)183 bool ConfigValueContainer::parseString(const std::string& input, const MultiTypeMath& defvalue) 184 184 { 185 185 if (defvalue.getType() == MT_int) -
code/branches/core2/src/orxonox/core/ConfigValueContainer.h
r871 r947 102 102 const std::string& getDescription() const; 103 103 104 bool parseString(const std::string& input, MultiTypeMath& defvalue);104 bool parseString(const std::string& input, const MultiTypeMath& defvalue = MT_null); 105 105 bool valueToString(std::string* output, MultiTypeMath& input); 106 106 void resetConfigFileEntry(); … … 110 110 static bool isEmpty(const std::string& line); 111 111 static bool isComment(const std::string& line); 112 113 inline std::string getTypename() const 114 { return this->value_.getTypename(); } 112 115 113 116 private: -
code/branches/core2/src/orxonox/core/CorePrereqs.h
r902 r947 91 91 class ClassTreeMaskIterator; 92 92 class ClassTreeMaskNode; 93 class CommandExecutor; 93 94 class ConfigValueContainer; 94 95 class DebugLevel; 95 96 class Error; 96 97 class Executor; 98 template <class T> 99 class ExecutorMember; 100 class ExecutorStatic; 97 101 class Factory; 102 class Functor; 103 template <class T> 104 class FunctorMember; 105 class FunctorStatic; 98 106 class Identifier; 99 107 class IdentifierDistributor; -
code/branches/core2/src/orxonox/core/DebugLevel.cc
r871 r947 95 95 96 96 // Return a constant value while we're creating the object 97 return 4;97 return 5; 98 98 } 99 99 } -
code/branches/core2/src/orxonox/core/Executor.cc
r939 r947 32 32 namespace orxonox 33 33 { 34 Executor::Executor(Functor* functor, const std::string& name )34 Executor::Executor(Functor* functor, const std::string& name, AccessLevel::Level level) 35 35 { 36 36 this->functor_ = functor; 37 37 this->name_ = name; 38 this->accessLevel_ = level; 39 38 40 this->bAddedDescription_ = false; 39 41 this->bAddedDescriptionReturnvalue_ = false; … … 60 62 { 61 63 EXECUTOR_PARSE(normal); 62 }63 64 void Executor::setName(const std::string name)65 {66 this->name_ = name;67 }68 69 const std::string& Executor::getName() const70 {71 return this->name_;72 64 } 73 65 -
code/branches/core2/src/orxonox/core/Executor.h
r939 r947 129 129 return true 130 130 131 namespace AccessLevel 132 { 133 enum Level 134 { 135 None, 136 User, 137 Admin, 138 Offline, 139 Debug, 140 Disabled 141 }; 142 } 131 143 132 144 namespace orxonox … … 135 147 { 136 148 public: 137 Executor(Functor* functor, const std::string& name = "" );149 Executor(Functor* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None); 138 150 virtual ~Executor(); 139 151 … … 153 165 bool parse(const std::string& params, const std::string& delimiter = " ") const; 154 166 155 void setName(const std::string name);156 const std::string& getName() const;157 158 167 void setDescription(const std::string& description); 159 168 const std::string& getDescription() const; … … 165 174 const std::string& getDescriptionReturnvalue(int param) const; 166 175 167 inline int getParamCount() const176 inline unsigned int getParamCount() const 168 177 { return this->functor_->getParamCount(); } 169 178 inline bool hasReturnvalue() const … … 173 182 inline MultiTypeMath getReturnvalue() const 174 183 { return this->functor_->getReturnvalue(); } 175 inline std::string getTypenameParam( int param) const184 inline std::string getTypenameParam(unsigned int param) const 176 185 { return this->functor_->getTypenameParam(param); } 177 186 inline std::string getTypenameReturnvalue() const 178 187 { return this->functor_->getTypenameReturnvalue(); } 188 189 inline void setName(const std::string name) 190 { this->name_ = name; } 191 inline const std::string& getName() const 192 { return this->name_; } 193 194 inline void setAccessLevel(AccessLevel::Level level) 195 { this->accessLevel_ = level; } 196 inline AccessLevel::Level getAccessLevel() const 197 { return this->accessLevel_; } 179 198 180 199 void setDefaultValues(const MultiTypeMath& param1); … … 186 205 187 206 bool allDefaultValuesSet() const; 207 inline bool defaultValueSet(unsigned int index) const 208 { 209 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) 210 return this->bAddedDefaultValue_[index]; 211 212 return false; 213 } 188 214 189 215 protected: … … 201 227 bool bAddedDescriptionReturnvalue_; 202 228 bool bAddedDescriptionParam_[MAX_FUNCTOR_ARGUMENTS]; 229 230 AccessLevel::Level accessLevel_; 203 231 }; 204 232 … … 206 234 { 207 235 public: 208 ExecutorStatic(FunctorStatic* functor, const std::string& name = "" ) : Executor(functor, name) {}236 ExecutorStatic(FunctorStatic* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None) : Executor(functor, name, level) {} 209 237 virtual ~ExecutorStatic() {} 210 238 }; … … 214 242 { 215 243 public: 216 ExecutorMember(FunctorMember<T>* functor, const std::string& name = "" ) : Executor(functor, name) {}244 ExecutorMember(FunctorMember<T>* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None) : Executor(functor, name, level) {} 217 245 virtual ~ExecutorMember() {} 218 246 … … 260 288 }; 261 289 262 inline Executor* createExecutor(Functor* functor, const std::string& name = "" )263 { 264 return new Executor(functor, name );290 inline Executor* createExecutor(Functor* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None) 291 { 292 return new Executor(functor, name, level); 265 293 } 266 294 267 295 template <class T> 268 inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "" )269 { 270 return new ExecutorMember<T>(functor, name );296 inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None) 297 { 298 return new ExecutorMember<T>(functor, name, level); 271 299 } 272 300 273 inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "" )274 { 275 return new ExecutorStatic(functor, name );301 inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "", AccessLevel::Level level = AccessLevel::None) 302 { 303 return new ExecutorStatic(functor, name, level); 276 304 } 277 305 } -
code/branches/core2/src/orxonox/core/Functor.h
r931 r947 37 37 #define MAX_FUNCTOR_ARGUMENTS 5 38 38 39 enum FunctionType 39 namespace orxonox 40 40 { 41 FT_MEMBER, 42 FT_CONSTMEMBER, 43 FT_STATIC 44 }; 45 46 47 template <class T> 48 inline std::string typeToString(); 41 enum FunctionType 42 { 43 FT_MEMBER, 44 FT_CONSTMEMBER, 45 FT_STATIC 46 }; 47 48 49 template <class T> 50 inline std::string typeToString() { return "unknown"; } 49 51 50 52 #define CreateTypeToStringTemplate(type) \ … … 52 54 inline std::string typeToString<type>() { return #type; } 53 55 54 CreateTypeToStringTemplate(int); 55 CreateTypeToStringTemplate(unsigned int); 56 CreateTypeToStringTemplate(char); 57 CreateTypeToStringTemplate(unsigned char); 58 CreateTypeToStringTemplate(short); 59 CreateTypeToStringTemplate(unsigned short); 60 CreateTypeToStringTemplate(long); 61 CreateTypeToStringTemplate(unsigned long); 62 CreateTypeToStringTemplate(float); 63 CreateTypeToStringTemplate(double); 64 CreateTypeToStringTemplate(long double); 65 CreateTypeToStringTemplate(bool); 66 CreateTypeToStringTemplate(std::string); 67 CreateTypeToStringTemplate(orxonox::Vector2); 68 CreateTypeToStringTemplate(orxonox::Vector3); 69 CreateTypeToStringTemplate(orxonox::Quaternion); 70 CreateTypeToStringTemplate(orxonox::ColourValue); 71 CreateTypeToStringTemplate(orxonox::Radian); 72 CreateTypeToStringTemplate(orxonox::Degree); 73 74 75 class _CoreExport Functor 76 { 77 public: 78 Functor() {} 79 virtual ~Functor() {} 80 81 virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0; 82 83 inline unsigned int getParamCount() const { return this->numParams_; } 84 inline bool hasReturnvalue() const { return this->hasReturnValue_; } 85 inline FunctionType getType() const { return this->type_; } 86 inline MultiTypeMath getReturnvalue() const { return this->returnedValue_; } 87 88 std::string getTypenameParam(int param) const { return (param > 0 && param <= 5) ? this->typeParam_[param-1] : ""; } 89 std::string getTypenameReturnvalue() const { return this->typeReturnvalue_; } 90 91 protected: 92 unsigned int numParams_; 93 bool hasReturnValue_; 94 FunctionType type_; 95 MultiTypeMath returnedValue_; 96 97 std::string typeReturnvalue_; 98 std::string typeParam_[MAX_FUNCTOR_ARGUMENTS]; 99 }; 100 101 class _CoreExport FunctorStatic : public Functor 102 { 103 public: 104 virtual ~FunctorStatic() {} 105 virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0; 106 }; 107 108 template <class T> 109 class FunctorMember : public Functor 110 { 111 public: 112 FunctorMember() 113 { 114 constObject_ = 0; 115 object_ = 0; 116 bConstObject_ = false; 117 } 118 virtual ~FunctorMember() {} 119 120 virtual void operator()(T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0; 121 virtual void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0; 122 123 virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) 124 { 125 if (this->bConstObject_) 56 CreateTypeToStringTemplate(int); 57 CreateTypeToStringTemplate(unsigned int); 58 CreateTypeToStringTemplate(char); 59 CreateTypeToStringTemplate(unsigned char); 60 CreateTypeToStringTemplate(short); 61 CreateTypeToStringTemplate(unsigned short); 62 CreateTypeToStringTemplate(long); 63 CreateTypeToStringTemplate(unsigned long); 64 CreateTypeToStringTemplate(float); 65 CreateTypeToStringTemplate(double); 66 CreateTypeToStringTemplate(long double); 67 CreateTypeToStringTemplate(bool); 68 CreateTypeToStringTemplate(std::string); 69 CreateTypeToStringTemplate(orxonox::Vector2); 70 CreateTypeToStringTemplate(orxonox::Vector3); 71 CreateTypeToStringTemplate(orxonox::Quaternion); 72 CreateTypeToStringTemplate(orxonox::ColourValue); 73 CreateTypeToStringTemplate(orxonox::Radian); 74 CreateTypeToStringTemplate(orxonox::Degree); 75 76 77 class _CoreExport Functor 78 { 79 public: 80 Functor() {} 81 virtual ~Functor() {} 82 83 virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0; 84 85 inline unsigned int getParamCount() const { return this->numParams_; } 86 inline bool hasReturnvalue() const { return this->hasReturnValue_; } 87 inline FunctionType getType() const { return this->type_; } 88 inline MultiTypeMath getReturnvalue() const { return this->returnedValue_; } 89 90 std::string getTypenameParam(unsigned int param) const { return (param > 0 && param <= 5) ? this->typeParam_[param-1] : ""; } 91 std::string getTypenameReturnvalue() const { return this->typeReturnvalue_; } 92 93 protected: 94 unsigned int numParams_; 95 bool hasReturnValue_; 96 FunctionType type_; 97 MultiTypeMath returnedValue_; 98 99 std::string typeReturnvalue_; 100 std::string typeParam_[MAX_FUNCTOR_ARGUMENTS]; 101 }; 102 103 class _CoreExport FunctorStatic : public Functor 104 { 105 public: 106 virtual ~FunctorStatic() {} 107 virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0; 108 }; 109 110 template <class T> 111 class FunctorMember : public Functor 112 { 113 public: 114 FunctorMember() 126 115 { 127 if (this->constObject_) 128 (*this)(this->constObject_, param1, param2, param3, param4, param5); 116 constObject_ = 0; 117 object_ = 0; 118 bConstObject_ = false; 119 } 120 virtual ~FunctorMember() {} 121 122 virtual void operator()(T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0; 123 virtual void operator()(const T* object, const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) = 0; 124 125 virtual void operator()(const MultiTypeMath& param1 = MT_null, const MultiTypeMath& param2 = MT_null, const MultiTypeMath& param3 = MT_null, const MultiTypeMath& param4 = MT_null, const MultiTypeMath& param5 = MT_null) 126 { 127 if (this->bConstObject_) 128 { 129 if (this->constObject_) 130 (*this)(this->constObject_, param1, param2, param3, param4, param5); 131 else 132 { 133 COUT(1) << "An error occurred in Functor.h:" << std::endl; 134 COUT(1) << "Error: No const object set." << std::endl; 135 } 136 } 129 137 else 130 138 { 131 COUT(1) << "An error occurred in Functor.h:" << std::endl; 132 COUT(1) << "Error: No const object set." << std::endl; 139 if (this->object_) 140 (*this)(this->object_, param1, param2, param3, param4, param5); 141 else 142 { 143 COUT(1) << "An error occurred in Functor.h:" << std::endl; 144 COUT(1) << "Error: No object set." << std::endl; 145 } 133 146 } 134 147 } 135 else 148 149 void setObject(T* object) 136 150 { 137 if (this->object_) 138 (*this)(this->object_, param1, param2, param3, param4, param5); 139 else 140 { 141 COUT(1) << "An error occurred in Functor.h:" << std::endl; 142 COUT(1) << "Error: No object set." << std::endl; 143 } 151 this->bConstObject_ = false; 152 this->object_ = object; 144 153 } 145 } 146 147 void setObject(T* object) 148 { 149 this->bConstObject_ = false; 150 this->object_ = object; 151 } 152 153 void setObject(const T* object) 154 { 155 this->bConstObject_ = true; 156 this->constObject_ = object; 157 } 158 159 private: 160 const T* constObject_; 161 T* object_; 162 bool bConstObject_; 163 }; 154 155 void setObject(const T* object) 156 { 157 this->bConstObject_ = true; 158 this->constObject_ = object; 159 } 160 161 private: 162 const T* constObject_; 163 T* object_; 164 bool bConstObject_; 165 }; 164 166 165 167 … … 403 405 404 406 405 CREATE_ALL_STATIC_FUNCTORS(); 406 CREATE_ALL_MEMBER_FUNCTORS(); 407 CREATE_ALL_STATIC_FUNCTORS(); 408 CREATE_ALL_MEMBER_FUNCTORS(); 409 } 407 410 408 411 #endif /* _Functor_H__ */ -
code/branches/core2/src/orxonox/core/Identifier.cc
r876 r947 35 35 #include "Identifier.h" 36 36 #include "Factory.h" 37 #include "Executor.h" 38 #include "CommandExecutor.h" 37 39 38 40 namespace orxonox … … 50 52 this->bCreatedOneObject_ = false; 51 53 this->factory_ = 0; 54 55 this->bHasConfigValues_ = false; 56 this->bHasConsoleCommands_ = false; 52 57 53 58 this->children_ = new std::set<const Identifier*>(); … … 198 203 199 204 /** 205 @brief Returns the map that stores all Identifiers. 206 @return The map 207 */ 208 std::map<std::string, Identifier*>& Identifier::getIdentifierMapIntern() 209 { 210 static std::map<std::string, Identifier*> identifierMap; 211 return identifierMap; 212 } 213 214 /** 215 @brief Returns the map that stores all Identifiers. 216 @return The map 217 */ 218 std::map<std::string, Identifier*>& Identifier::getLowercaseIdentifierMapIntern() 219 { 220 static std::map<std::string, Identifier*> lowercaseIdentifierMap; 221 return lowercaseIdentifierMap; 222 } 223 224 /** 225 @brief Adds the ConfigValueContainer of a variable, given by the string of its name. 226 @param varname The name of the variablee 227 @param container The container 228 */ 229 void Identifier::addConfigValueContainer(const std::string& varname, ConfigValueContainer* container) 230 { 231 this->bHasConfigValues_ = true; 232 this->configValues_[varname] = container; 233 this->configValues_LC_[getLowercase(varname)] = container; 234 } 235 236 /** 200 237 @brief Returns the ConfigValueContainer of a variable, given by the string of its name. 201 238 @param varname The name of the variable … … 212 249 213 250 /** 214 @brief Adds the ConfigValueContainer of a variable, given by the string of its name. 215 @param varname The name of the variablee 216 @param container The container 217 */ 218 void Identifier::addConfigValueContainer(const std::string& varname, ConfigValueContainer* container) 219 { 220 this->configValues_[varname] = container; 221 } 222 251 @brief Returns the ConfigValueContainer of a variable, given by the string of its name in lowercase. 252 @param varname The name of the variable in lowercase 253 @return The ConfigValueContainer 254 */ 255 ConfigValueContainer* Identifier::getLowercaseConfigValueContainer(const std::string& varname) 256 { 257 std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_LC_.find(varname); 258 if (it != configValues_LC_.end()) 259 return ((*it).second); 260 else 261 return 0; 262 } 263 264 /** 265 @brief Adds a new console command of this class. 266 @param executor The executor of the command 267 @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command 268 @return The executor of the command 269 */ 270 ExecutorStatic& Identifier::addConsoleCommand(ExecutorStatic* executor, bool bCreateShortcut) 271 { 272 this->bHasConsoleCommands_ = true; 273 this->consoleCommands_[executor->getName()] = executor; 274 this->consoleCommands_LC_[getLowercase(executor->getName())] = executor; 275 276 if (bCreateShortcut) 277 CommandExecutor::addConsoleCommandShortcut(executor); 278 279 return (*executor); 280 } 281 282 /** 283 @brief Returns the executor of a console command with given name. 284 @brief name The name of the requested console command 285 @return The executor of the requested console command 286 */ 287 ExecutorStatic* Identifier::getConsoleCommand(const std::string& name) const 288 { 289 std::map<std::string, ExecutorStatic*>::const_iterator it = this->consoleCommands_.find(name); 290 if (it != this->consoleCommands_.end()) 291 return (*it).second; 292 else 293 return 0; 294 } 295 296 /** 297 @brief Returns the executor of a console command with given name in lowercase. 298 @brief name The name of the requested console command in lowercae 299 @return The executor of the requested console command 300 */ 301 ExecutorStatic* Identifier::getLowercaseConsoleCommand(const std::string& name) const 302 { 303 std::map<std::string, ExecutorStatic*>::const_iterator it = this->consoleCommands_LC_.find(name); 304 if (it != this->consoleCommands_LC_.end()) 305 return (*it).second; 306 else 307 return 0; 308 } 309 310 /** 311 @brief Lists the names of all Identifiers in a std::set<const Identifier*>. 312 @param out The outstream 313 @param list The list (or set) of Identifiers 314 @return The outstream 315 */ 223 316 std::ostream& operator<<(std::ostream& out, const std::set<const Identifier*>& list) 224 317 { -
code/branches/core2/src/orxonox/core/Identifier.h
r941 r947 62 62 #include "Debug.h" 63 63 #include "Iterator.h" 64 #include "util/String.h" 64 65 65 66 namespace orxonox … … 114 115 inline const std::string& getName() const { return this->name_; } 115 116 117 116 118 /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */ 117 119 inline const std::set<const Identifier*>& getParents() const { return this->parents_; } … … 142 144 inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); } 143 145 146 147 /** @brief Returns the map that stores all Identifiers. @return The map */ 148 static inline const std::map<std::string, Identifier*>& getIdentifierMap() { return Identifier::getIdentifierMapIntern(); } 149 /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers. @return The const_iterator */ 150 static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapBegin() { return Identifier::getIdentifierMap().begin(); } 151 /** @brief Returns a const_iterator to the end of the map that stores all Identifiers. @return The const_iterator */ 152 static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapEnd() { return Identifier::getIdentifierMap().end(); } 153 154 /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */ 155 static inline const std::map<std::string, Identifier*>& getLowercaseIdentifierMap() { return Identifier::getLowercaseIdentifierMapIntern(); } 156 /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */ 157 static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapBegin() { return Identifier::getLowercaseIdentifierMap().begin(); } 158 /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */ 159 static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapEnd() { return Identifier::getLowercaseIdentifierMap().end(); } 160 161 162 /** @brief Returns the map that stores all config values. @return The const_iterator */ 163 inline const std::map<std::string, ConfigValueContainer*>& getConfigValueMap() const { return this->configValues_; } 164 /** @brief Returns a const_iterator to the beginning of the map that stores all config values. @return The const_iterator */ 165 inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapBegin() const { return this->configValues_.begin(); } 166 /** @brief Returns a const_iterator to the end of the map that stores all config values. @return The const_iterator */ 167 inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapEnd() const { return this->configValues_.end(); } 168 169 /** @brief Returns the map that stores all config values with their names in lowercase. @return The const_iterator */ 170 inline const std::map<std::string, ConfigValueContainer*>& getLowercaseConfigValueMap() const { return this->configValues_LC_; } 171 /** @brief Returns a const_iterator to the beginning of the map that stores all config values with their names in lowercase. @return The const_iterator */ 172 inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapBegin() const { return this->configValues_LC_.begin(); } 173 /** @brief Returns a const_iterator to the end of the map that stores all config values with their names in lowercase. @return The const_iterator */ 174 inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapEnd() const { return this->configValues_LC_.end(); } 175 176 177 /** @brief Returns the map that stores all console commands. @return The const_iterator */ 178 inline const std::map<std::string, ExecutorStatic*>& getConsoleCommandMap() const { return this->consoleCommands_; } 179 /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */ 180 inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandMapBegin() const { return this->consoleCommands_.begin(); } 181 /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */ 182 inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandMapEnd() const { return this->consoleCommands_.end(); } 183 184 /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */ 185 inline const std::map<std::string, ExecutorStatic*>& getLowercaseConsoleCommandMap() const { return this->consoleCommands_LC_; } 186 /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */ 187 inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandMapBegin() const { return this->consoleCommands_LC_.begin(); } 188 /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */ 189 inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); } 190 191 192 /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */ 193 inline bool hasConfigValues() const { return this->bHasConfigValues_; } 194 /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */ 195 inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; } 196 144 197 /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */ 145 198 inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); } … … 151 204 void setNetworkID(unsigned int id); 152 205 206 void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container); 153 207 ConfigValueContainer* getConfigValueContainer(const std::string& varname); 154 void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container); 155 208 ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname); 209 210 virtual void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) = 0; 156 211 virtual XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname) = 0; 157 virtual void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) = 0; 158 212 213 virtual void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) = 0; 159 214 virtual XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname) = 0; 160 virtual void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) = 0; 215 216 ExecutorStatic& addConsoleCommand(ExecutorStatic* executor, bool bCreateShortcut); 217 ExecutorStatic* getConsoleCommand(const std::string& name) const; 218 ExecutorStatic* getLowercaseConsoleCommand(const std::string& name) const; 219 220 protected: 221 /** @brief Returns the map that stores all Identifiers. @return The map */ 222 static std::map<std::string, Identifier*>& getIdentifierMapIntern(); 223 /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */ 224 static std::map<std::string, Identifier*>& getLowercaseIdentifierMapIntern(); 161 225 162 226 private: … … 189 253 } 190 254 191 std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to 192 std::set<const Identifier*>* children_; //!< The children of the class the Identifier belongs to 193 194 std::set<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to 195 std::set<const Identifier*>* directChildren_; //!< The direct children of the class the Identifier belongs to 196 197 std::string name_; //!< The name of the class the Identifier belongs to 198 199 BaseFactory* factory_; //!< The Factory, able to create new objects of the given class (if available) 200 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) 201 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) 202 unsigned int classID_; //!< The network ID to identify a class through the network 203 std::map<std::string, ConfigValueContainer*> configValues_; //!< A map to link the string of configurable variables with their ConfigValueContainer 255 std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to 256 std::set<const Identifier*>* children_; //!< The children of the class the Identifier belongs to 257 258 std::set<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to 259 std::set<const Identifier*>* directChildren_; //!< The direct children of the class the Identifier belongs to 260 261 std::string name_; //!< The name of the class the Identifier belongs to 262 263 BaseFactory* factory_; //!< The Factory, able to create new objects of the given class (if available) 264 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) 265 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) 266 unsigned int classID_; //!< The network ID to identify a class through the network 267 268 bool bHasConfigValues_; //!< True if this class has at least one assigned config value 269 std::map<std::string, ConfigValueContainer*> configValues_; //!< A map to link the string of configurable variables with their ConfigValueContainer 270 std::map<std::string, ConfigValueContainer*> configValues_LC_; //!< A map to link the string of configurable variables with their ConfigValueContainer 271 272 bool bHasConsoleCommands_; //!< True if this class has at least one assigned console command 273 std::map<std::string, ExecutorStatic*> consoleCommands_; //!< All console commands of this class 274 std::map<std::string, ExecutorStatic*> consoleCommands_LC_; //!< All console commands of this class with their names in lowercase 204 275 }; 205 276 … … 246 317 ~ClassIdentifier() {} // don't delete 247 318 248 ObjectList<T>* objects_; //!< The ObjectList, containing all objects of type T249 bool bSetName_; //!< True if the name is set250 std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_; 251 std::map<std::string, XMLPortClassObjectContainer<T, class O>*> xmlportObjectContainers_; 319 ObjectList<T>* objects_; //!< The ObjectList, containing all objects of type T 320 bool bSetName_; //!< True if the name is set 321 std::map<std::string, XMLPortClassParamContainer<T>*> xmlportParamContainers_; //!< All loadable parameters 322 std::map<std::string, XMLPortClassObjectContainer<T, class O>*> xmlportObjectContainers_; //!< All attachable objects 252 323 }; 253 324 … … 300 371 this->name_ = name; 301 372 this->bSetName_ = true; 373 Identifier::getIdentifierMapIntern()[name] = this; 374 Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this; 302 375 } 303 376 } … … 324 397 } 325 398 399 /** 400 @brief Returns a XMLPortParamContainer that loads a parameter of this class. 401 @param paramname The name of the parameter 402 @return The container 403 */ 326 404 template <class T> 327 405 XMLPortParamContainer* ClassIdentifier<T>::getXMLPortParamContainer(const std::string& paramname) … … 334 412 } 335 413 414 /** 415 @brief Adds a new XMLPortParamContainer that loads a parameter of this class. 416 @param paramname The name of the parameter 417 @param container The container 418 */ 336 419 template <class T> 337 420 void ClassIdentifier<T>::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container) … … 340 423 } 341 424 425 /** 426 @brief Returns a XMLPortObjectContainer that attaches an object to this class. 427 @param sectionname The name of the section that contains the attachable objects 428 @return The container 429 */ 342 430 template <class T> 343 431 XMLPortObjectContainer* ClassIdentifier<T>::getXMLPortObjectContainer(const std::string& sectionname) … … 350 438 } 351 439 440 /** 441 @brief Adds a new XMLPortObjectContainer that attaches an object to this class. 442 @param sectionname The name of the section that contains the attachable objects 443 @param container The container 444 */ 352 445 template <class T> 353 446 void ClassIdentifier<T>::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container) -
code/branches/core2/src/orxonox/core/OutputHandler.cc
r871 r947 33 33 #include "DebugLevel.h" 34 34 #include "OutputHandler.h" 35 #include "ConsoleCommand.h" 35 36 36 37 namespace orxonox 37 38 { 39 ConsoleCommandShortcutGeneric(log, createExecutor(createFunctor(&OutputHandler::log), "log", AccessLevel::None)); 40 38 41 /** 39 42 @brief Constructor: Opens the logfile and writes the first line. -
code/branches/core2/src/orxonox/core/OutputHandler.h
r871 r947 58 58 59 59 static OutputHandler& getOutStream(); 60 61 /** @brief Puts some text on the outstream. @param text The text */ 62 static inline void log(const std::string& text) 63 { OutputHandler::getOutStream().output(text); } 60 64 61 65 /** @brief Returns a reference to the logfile. @return The logfile */ -
code/branches/core2/src/orxonox/core/XMLPort.h
r933 r947 42 42 43 43 #define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \ 44 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, createExecutor(createFunctor(&classname::loadfunction), #loadfunction), createExecutor(createFunctor(&classname::savefunction), #savefunction), xmlelement, mode)44 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), #savefunction), xmlelement, mode) 45 45 #define XMLPortParam_Template(classname, paramname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, mode) \ 46 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, paramname, createExecutor(createFunctor loadtemplate (&classname::loadfunction), #loadfunction), createExecutor(createFunctor savetemplate (&classname::savefunction), #savefunction), xmlelement, mode)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) 47 47 48 48 #define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \ 49 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, createExecutor(createFunctor(&classname::loadfunction), #loadfunction), 0, xmlelement, mode)49 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), #loadfunction), 0, xmlelement, mode) 50 50 #define XMLPortParamLoadOnly_Template(classname, paramname, loadtemplate, loadfunction, xmlelement, mode) \ 51 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, createExecutor(createFunctor loadtemplate (&classname::loadfunction), #loadfunction), 0, xmlelement, mode)51 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, paramname, orxonox::createExecutor(orxonox::createFunctor loadtemplate (&classname::loadfunction), #loadfunction), 0, xmlelement, mode) 52 52 53 53 #define XMLPortParamGeneric(containername, classname, paramname, loadexecutor, saveexecutor, xmlelement, mode) \ … … 62 62 63 63 #define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \ 64 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, createExecutor(createFunctor(&classname::loadfunction), #loadfunction), createExecutor(createFunctor(&classname::savefunction), #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)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 65 #define XMLPortObject_Template(classname, objectclass, sectionname, loadtemplate, loadfunction, savetemplate, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \ 66 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, createExecutor(createFunctor loadtemplate (&classname::loadfunction), #loadfunction), createExecutor(createFunctor savetemplate (&classname::savefunction), #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)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) 67 67 68 68 #define XMLPortObjectGeneric(containername, classname, objectclass, sectionname, loadexecutor, saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \ … … 143 143 this->loadexecutor_ = loadexecutor; 144 144 this->saveexecutor_ = saveexecutor; 145 146 this->setDefaultValue_[0] = false;147 this->setDefaultValue_[1] = false;148 this->setDefaultValue_[2] = false;149 this->setDefaultValue_[3] = false;150 this->setDefaultValue_[4] = false;151 145 } 152 146 … … 209 203 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiTypeMath& param) 210 204 { 211 if (!this->setDefaultValue_[index]) 212 { 213 this->setDefaultValue_[index] = true; 205 if (!this->loadexecutor_->defaultValueSet(index)) 214 206 this->loadexecutor_->setDefaultValue(index, param); 215 }216 207 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 217 208 } 218 209 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1) 219 210 { 220 if (!this->setDefaultValue_[0]) 221 { 222 this->setDefaultValue_[0] = true; 211 if (!this->loadexecutor_->defaultValueSet(0)) 223 212 this->loadexecutor_->setDefaultValues(param1); 224 }225 213 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 226 214 } 227 215 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2) 228 216 { 229 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1])) 230 { 231 this->setDefaultValue_[0] = true; 232 this->setDefaultValue_[1] = true; 217 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1))) 233 218 this->loadexecutor_->setDefaultValues(param1, param2); 234 }235 219 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 236 220 } 237 221 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) 238 222 { 239 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1]) || (!this->setDefaultValue_[2])) 240 { 241 this->setDefaultValue_[0] = true; 242 this->setDefaultValue_[1] = true; 243 this->setDefaultValue_[3] = true; 223 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2))) 244 224 this->loadexecutor_->setDefaultValues(param1, param2, param3); 245 }246 225 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 247 226 } 248 227 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) 249 228 { 250 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1]) || (!this->setDefaultValue_[2]) || (!this->setDefaultValue_[3])) 251 { 252 this->setDefaultValue_[0] = true; 253 this->setDefaultValue_[1] = true; 254 this->setDefaultValue_[3] = true; 255 this->setDefaultValue_[4] = true; 229 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3))) 256 230 this->loadexecutor_->setDefaultValues(param1, param2, param3, param4); 257 }258 231 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 259 232 } 260 233 virtual XMLPortParamContainer& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) 261 234 { 262 if ((!this->setDefaultValue_[0]) || (!this->setDefaultValue_[1]) || (!this->setDefaultValue_[2]) || (!this->setDefaultValue_[3]) || (!this->setDefaultValue_[4])) 263 { 264 this->setDefaultValue_[0] = true; 265 this->setDefaultValue_[1] = true; 266 this->setDefaultValue_[3] = true; 267 this->setDefaultValue_[4] = true; 268 this->setDefaultValue_[5] = true; 235 if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)) || (!this->loadexecutor_->defaultValueSet(4))) 269 236 this->loadexecutor_->setDefaultValues(param1, param2, param3, param4, param5); 270 }271 237 return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_); 272 238 } … … 276 242 ExecutorMember<T>* saveexecutor_; 277 243 ParseParams parseParams_; 278 bool setDefaultValue_[5];279 244 }; 280 245 -
code/branches/core2/src/orxonox/objects/Ambient.cc
r902 r947 41 41 #include "../Orxonox.h" 42 42 #include "core/XMLPort.h" 43 #include "core/ConsoleCommand.h" 43 44 44 45 #include "Ambient.h" … … 46 47 namespace orxonox 47 48 { 49 ConsoleCommand(Ambient, setAmbientLightTest, AccessLevel::Offline, false); 50 48 51 CreateFactory(Ambient); 52 53 Ambient* Ambient::instance_s; 49 54 50 55 Ambient::Ambient() 51 56 { 52 57 RegisterObject(Ambient); 58 Ambient::instance_s = this; 53 59 } 54 60 -
code/branches/core2/src/orxonox/objects/Ambient.h
r902 r947 18 18 void setAmbientLight(const ColourValue& colour); 19 19 20 static void setAmbientLightTest(const ColourValue& colour) 21 { Ambient::instance_s->setAmbientLight(colour); } 22 20 23 private: 21 24 static Ambient* instance_s; 22 25 23 26 }; -
code/branches/core2/src/orxonox/objects/SpaceShip.cc
r902 r947 45 45 #include "Projectile.h" 46 46 #include "core/XMLPort.h" 47 #include "core/ConsoleCommand.h" 47 48 48 49 #include "SpaceShip.h" … … 50 51 namespace orxonox 51 52 { 53 ConsoleCommand(SpaceShip, setMaxSpeedTest, AccessLevel::Debug, false); 54 52 55 CreateFactory(SpaceShip); 53 56 57 SpaceShip* SpaceShip::instance_s; 58 54 59 SpaceShip::SpaceShip() 55 60 { 56 61 RegisterObject(SpaceShip); 62 63 SpaceShip::instance_s = this; 57 64 58 65 this->setConfigValues(); -
code/branches/core2/src/orxonox/objects/SpaceShip.h
r902 r947 36 36 void setRotDamp(float value); 37 37 38 static void setMaxSpeedTest(float value) 39 { SpaceShip::instance_s->setMaxSpeed(value); } 40 38 41 bool mouseMoved(const OIS::MouseEvent &e); 39 42 bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id); … … 42 45 43 46 private: 47 static SpaceShip* instance_s; 48 44 49 Vector3 testvector_; 45 50 bool bInvertYAxis_; -
code/branches/core2/src/util/MultiTypeMath.cc
r933 r947 144 144 } 145 145 146 std::string MultiTypeMath::getTypename() const 147 { 148 if (this->type_ == MT_vector2) 149 return "Vector2"; 150 else if (this->type_ == MT_vector3) 151 return "Vector3"; 152 else if (this->type_ == MT_colourvalue) 153 return "ColourValue"; 154 else if (this->type_ == MT_quaternion) 155 return "Quaternion"; 156 else if (this->type_ == MT_radian) 157 return "Radian"; 158 else if (this->type_ == MT_degree) 159 return "Degree"; 160 else 161 return MultiTypeString::getTypename(); 162 } 163 146 164 std::string MultiTypeMath::toString() const 147 165 { -
code/branches/core2/src/util/MultiTypeMath.h
r933 r947 145 145 inline void getValue(orxonox::Degree* variable) const { (*variable) = orxonox::Degree (this->degree_); } 146 146 147 virtual std::string getTypename() const; 148 147 149 virtual std::string toString() const; 148 150 virtual bool fromString(const std::string value); -
code/branches/core2/src/util/MultiTypePrimitive.cc
r933 r947 167 167 } 168 168 169 std::string MultiTypePrimitive::getTypename() const 170 { 171 if (this->type_ == MT_void) 172 return "pointer"; 173 else if (this->type_ == MT_int) 174 return "int"; 175 else if (this->type_ == MT_uint) 176 return "unsigned int"; 177 else if (this->type_ == MT_char) 178 return "char"; 179 else if (this->type_ == MT_uchar) 180 return "unsigned char"; 181 else if (this->type_ == MT_short) 182 return "short"; 183 else if (this->type_ == MT_ushort) 184 return "unsigned short"; 185 else if (this->type_ == MT_long) 186 return "long"; 187 else if (this->type_ == MT_ulong) 188 return "unsigned long"; 189 else if (this->type_ == MT_float) 190 return "float"; 191 else if (this->type_ == MT_double) 192 return "double"; 193 else if (this->type_ == MT_longdouble) 194 return "long double"; 195 else if (this->type_ == MT_bool) 196 return "bool"; 197 else 198 return "unknown"; 199 } 200 169 201 std::string MultiTypePrimitive::toString() const 170 202 { -
code/branches/core2/src/util/MultiTypePrimitive.h
r933 r947 181 181 inline bool isA(MultiType type) const { return (this->type_ == type); } 182 182 183 virtual std::string getTypename() const; 184 183 185 virtual std::string toString() const; 184 186 virtual bool fromString(const std::string value); -
code/branches/core2/src/util/MultiTypeString.cc
r933 r947 104 104 } 105 105 106 std::string MultiTypeString::getTypename() const 107 { 108 if (this->type_ == MT_constchar) 109 return "string"; 110 else if (this->type_ == MT_string) 111 return "string"; 112 else if (this->type_ == MT_xmlelement) 113 return "XML-element"; 114 else 115 return MultiTypePrimitive::getTypename(); 116 } 117 106 118 std::string MultiTypeString::toString() const 107 119 { -
code/branches/core2/src/util/MultiTypeString.h
r933 r947 115 115 inline void getValue(orxonox::Element* variable) const { (*variable) = this->xmlelement_; } 116 116 117 virtual std::string getTypename() const; 118 117 119 virtual std::string toString() const; 118 120 virtual bool fromString(const std::string value); -
code/branches/core2/src/util/String.cc
r931 r947 25 25 * 26 26 */ 27 28 #include <cctype> 27 29 28 30 #include "String.h" … … 116 118 void lowercase(std::string* str) 117 119 { 118 static unsigned const char difference_between_A_and_a = 'A' - 'a'; 119 120 for (std::string::iterator it = (*str).begin(); it != (*str).end(); ++it) 121 if ((*it) >= 'A' && (*it) <= 'Z') 122 (*it) -= difference_between_A_and_a; 120 for (unsigned int i = 0; i < str->size(); ++i) 121 { 122 (*str)[i] = tolower((*str)[i]); 123 } 123 124 } 124 125 … … 141 142 void uppercase(std::string* str) 142 143 { 143 static unsigned const char difference_between_A_and_a = 'A' - 'a'; 144 145 for (std::string::iterator it = (*str).begin(); it != (*str).end(); ++it) 146 if ((*it) >= 'a' && (*it) <= 'z') 147 (*it) += difference_between_A_and_a; 144 for (unsigned int i = 0; i < str->size(); ++i) 145 { 146 (*str)[i] = toupper((*str)[i]); 147 } 148 148 } 149 149
Note: See TracChangeset
for help on using the changeset viewer.