- Timestamp:
- Aug 25, 2010, 7:07:08 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/Identifier.cc
r7204 r7216 40 40 #include "ClassFactory.h" 41 41 #include "XMLPort.h" 42 #include "command/ConsoleCommand.h"43 42 44 43 namespace orxonox … … 64 63 65 64 this->bHasConfigValues_ = false; 66 this->bHasConsoleCommands_ = false;67 65 68 66 // Default network ID is the class ID … … 80 78 delete this->factory_; 81 79 82 for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)83 delete (it->second);84 80 for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it) 85 81 delete (it->second); … … 433 429 434 430 /** 435 @brief Adds a new console command of this class.436 @param executor The executor of the command437 @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command438 @return The executor of the command439 */440 ConsoleCommand& Identifier::addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut)441 {442 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(command->getName());443 if (it != this->consoleCommands_.end())444 {445 COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << '.' << std::endl;446 delete (it->second);447 }448 449 this->bHasConsoleCommands_ = true;450 this->consoleCommands_[command->getName()] = command;451 this->consoleCommands_LC_[getLowercase(command->getName())] = command;452 453 if (bCreateShortcut)454 CommandExecutor::addConsoleCommandShortcut(command);455 456 return (*command);457 }458 459 /**460 @brief Returns the executor of a console command with given name.461 @brief name The name of the requested console command462 @return The executor of the requested console command463 */464 ConsoleCommand* Identifier::getConsoleCommand(const std::string& name) const465 {466 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name);467 if (it != this->consoleCommands_.end())468 return it->second;469 else470 return 0;471 }472 473 /**474 @brief Returns the executor of a console command with given name in lowercase.475 @brief name The name of the requested console command in lowercae476 @return The executor of the requested console command477 */478 ConsoleCommand* Identifier::getLowercaseConsoleCommand(const std::string& name) const479 {480 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name);481 if (it != this->consoleCommands_LC_.end())482 return it->second;483 else484 return 0;485 }486 487 /**488 431 @brief Returns a XMLPortParamContainer that loads a parameter of this class. 489 432 @param paramname The name of the parameter
Note: See TracChangeset
for help on using the changeset viewer.