Changeset 947 for code/branches/core2/src/orxonox/core/Identifier.cc
- Timestamp:
- Mar 28, 2008, 10:13:58 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note: See TracChangeset
for help on using the changeset viewer.