Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 24, 2009, 11:32:39 AM (15 years ago)
Author:
rgrieder
Message:

Applied changes to the real sandbox this time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/src/libraries/core/Identifier.cc

    r5738 r5782  
    3838#include "util/StringUtils.h"
    3939#include "ConfigValueContainer.h"
    40 #include "ConsoleCommand.h"
    4140#include "Factory.h"
    42 #include "XMLPort.h"
    4341
    4442namespace orxonox
     
    6159        this->bSetName_ = false;
    6260        this->factory_ = 0;
    63         this->bLoadable_ = true;
    6461
    6562        this->bHasConfigValues_ = false;
    66         this->bHasConsoleCommands_ = false;
    6763
    6864        this->children_ = new std::set<const Identifier*>();
    6965        this->directChildren_ = new std::set<const Identifier*>();
    70 
    71         // Default network ID is the class ID
    72         this->networkID_ = this->classID_;
    7366    }
    7467
     
    8578            delete this->factory_;
    8679
    87         for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)
    88             delete (it->second);
    8980        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)
    9481            delete (it->second);
    9582    }
     
    188175                // Tell the parent we're one of it's direct children
    189176                (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this);
    190 
    191                 // Create the super-function dependencies
    192                 (*it)->createSuperFunctionCaller();
    193177            }
    194178        }
     
    240224
    241225    /**
    242         @brief Sets the network ID to a new value and changes the entry in the Factory.
    243         @param id The new network ID
    244     */
    245     void Identifier::setNetworkID(uint32_t id)
    246     {
    247         Factory::changeNetworkID(this, this->networkID_, id);
    248         this->networkID_ = id;
    249     }
    250 
    251     /**
    252226        @brief Returns true, if the Identifier is at least of the given type.
    253227        @param identifier The identifier to compare with
     
    371345
    372346    /**
    373         @brief Adds a new console command of this class.
    374         @param executor The executor of the command
    375         @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command
    376         @return The executor of the command
    377     */
    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 command
    400         @return The executor of the requested console command
    401     */
    402     ConsoleCommand* Identifier::getConsoleCommand(const std::string& name) const
    403     {
    404         std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name);
    405         if (it != this->consoleCommands_.end())
    406             return (*it).second;
    407         else
    408             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 lowercae
    414         @return The executor of the requested console command
    415     */
    416     ConsoleCommand* Identifier::getLowercaseConsoleCommand(const std::string& name) const
    417     {
    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         else
    422             return 0;
    423     }
    424 
    425     /**
    426         @brief Returns a XMLPortParamContainer that loads a parameter of this class.
    427         @param paramname The name of the parameter
    428         @return The container
    429     */
    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         else
    436             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 parameter
    442         @param container The container
    443     */
    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 objects
    459         @return The container
    460     */
    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         else
    467             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 objects
    473         @param container The container
    474     */
    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 event
    490         @return The container
    491     */
    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         else
    498             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 event
    504         @param container The container
    505     */
    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     /**
    519347        @brief Lists the names of all Identifiers in a std::set<const Identifier*>.
    520348        @param out The outstream
Note: See TracChangeset for help on using the changeset viewer.