Changeset 5782 for sandbox/src/libraries/core/Identifier.cc
- Timestamp:
- Sep 24, 2009, 11:32:39 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/src/libraries/core/Identifier.cc
r5738 r5782 38 38 #include "util/StringUtils.h" 39 39 #include "ConfigValueContainer.h" 40 #include "ConsoleCommand.h"41 40 #include "Factory.h" 42 #include "XMLPort.h"43 41 44 42 namespace orxonox … … 61 59 this->bSetName_ = false; 62 60 this->factory_ = 0; 63 this->bLoadable_ = true;64 61 65 62 this->bHasConfigValues_ = false; 66 this->bHasConsoleCommands_ = false;67 63 68 64 this->children_ = new std::set<const Identifier*>(); 69 65 this->directChildren_ = new std::set<const Identifier*>(); 70 71 // Default network ID is the class ID72 this->networkID_ = this->classID_;73 66 } 74 67 … … 85 78 delete this->factory_; 86 79 87 for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)88 delete (it->second);89 80 for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it) 90 delete (it->second);91 for (std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it)92 delete (it->second);93 for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)94 81 delete (it->second); 95 82 } … … 188 175 // Tell the parent we're one of it's direct children 189 176 (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this); 190 191 // Create the super-function dependencies192 (*it)->createSuperFunctionCaller();193 177 } 194 178 } … … 240 224 241 225 /** 242 @brief Sets the network ID to a new value and changes the entry in the Factory.243 @param id The new network ID244 */245 void Identifier::setNetworkID(uint32_t id)246 {247 Factory::changeNetworkID(this, this->networkID_, id);248 this->networkID_ = id;249 }250 251 /**252 226 @brief Returns true, if the Identifier is at least of the given type. 253 227 @param identifier The identifier to compare with … … 371 345 372 346 /** 373 @brief Adds a new console command of this class.374 @param executor The executor of the command375 @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command376 @return The executor of the command377 */378 ConsoleCommand& Identifier::addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut)379 {380 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(command->getName());381 if (it != this->consoleCommands_.end())382 {383 COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << "." << std::endl;384 delete (it->second);385 }386 387 this->bHasConsoleCommands_ = true;388 this->consoleCommands_[command->getName()] = command;389 this->consoleCommands_LC_[getLowercase(command->getName())] = command;390 391 if (bCreateShortcut)392 CommandExecutor::addConsoleCommandShortcut(command);393 394 return (*command);395 }396 397 /**398 @brief Returns the executor of a console command with given name.399 @brief name The name of the requested console command400 @return The executor of the requested console command401 */402 ConsoleCommand* Identifier::getConsoleCommand(const std::string& name) const403 {404 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name);405 if (it != this->consoleCommands_.end())406 return (*it).second;407 else408 return 0;409 }410 411 /**412 @brief Returns the executor of a console command with given name in lowercase.413 @brief name The name of the requested console command in lowercae414 @return The executor of the requested console command415 */416 ConsoleCommand* Identifier::getLowercaseConsoleCommand(const std::string& name) const417 {418 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name);419 if (it != this->consoleCommands_LC_.end())420 return (*it).second;421 else422 return 0;423 }424 425 /**426 @brief Returns a XMLPortParamContainer that loads a parameter of this class.427 @param paramname The name of the parameter428 @return The container429 */430 XMLPortParamContainer* Identifier::getXMLPortParamContainer(const std::string& paramname)431 {432 std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);433 if (it != this->xmlportParamContainers_.end())434 return ((*it).second);435 else436 return 0;437 }438 439 /**440 @brief Adds a new XMLPortParamContainer that loads a parameter of this class.441 @param paramname The name of the parameter442 @param container The container443 */444 void Identifier::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)445 {446 std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);447 if (it != this->xmlportParamContainers_.end())448 {449 COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << "." << std::endl;450 delete (it->second);451 }452 453 this->xmlportParamContainers_[paramname] = container;454 }455 456 /**457 @brief Returns a XMLPortObjectContainer that attaches an object to this class.458 @param sectionname The name of the section that contains the attachable objects459 @return The container460 */461 XMLPortObjectContainer* Identifier::getXMLPortObjectContainer(const std::string& sectionname)462 {463 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);464 if (it != this->xmlportObjectContainers_.end())465 return ((*it).second);466 else467 return 0;468 }469 470 /**471 @brief Adds a new XMLPortObjectContainer that attaches an object to this class.472 @param sectionname The name of the section that contains the attachable objects473 @param container The container474 */475 void Identifier::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)476 {477 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);478 if (it != this->xmlportObjectContainers_.end())479 {480 COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << "." << std::endl;481 delete (it->second);482 }483 484 this->xmlportObjectContainers_[sectionname] = container;485 }486 487 /**488 @brief Returns a XMLPortEventContainer that attaches an event to this class.489 @param sectionname The name of the section that contains the event490 @return The container491 */492 XMLPortObjectContainer* Identifier::getXMLPortEventContainer(const std::string& eventname)493 {494 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);495 if (it != this->xmlportEventContainers_.end())496 return ((*it).second);497 else498 return 0;499 }500 501 /**502 @brief Adds a new XMLPortEventContainer that attaches an event to this class.503 @param sectionname The name of the section that contains the event504 @param container The container505 */506 void Identifier::addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container)507 {508 std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);509 if (it != this->xmlportEventContainers_.end())510 {511 COUT(2) << "Warning: Overwriting XMLPortEventContainer in class " << this->getName() << "." << std::endl;512 delete (it->second);513 }514 515 this->xmlportEventContainers_[eventname] = container;516 }517 518 /**519 347 @brief Lists the names of all Identifiers in a std::set<const Identifier*>. 520 348 @param out The outstream
Note: See TracChangeset
for help on using the changeset viewer.