Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2008, 12:40:27 AM (16 years ago)
Author:
landauf
Message:
  • added several "delete"s to the destructors of some core classes.
  • added Identifier::destroyAllIdentifiers() function, maybe this comes in handy in the future
  • moved XMLPort param and object containers from ClassIdentifier to Identifier
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/Identifier.cc

    r1676 r1682  
    3737
    3838#include "Factory.h"
     39#include "ConfigValueContainer.h"
    3940#include "ConsoleCommand.h"
    4041#include "CommandExecutor.h"
     
    7778        delete this->children_;
    7879        delete this->directChildren_;
     80        delete this->objects_;
     81
     82        if (this->factory_)
     83            delete this->factory_;
     84
     85        for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)
     86            delete (it->second);
     87        for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)
     88            delete (it->second);
     89        for (std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it)
     90            delete (it->second);
     91        for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)
     92            delete (it->second);
    7993    }
    8094
     
    153167
    154168    /**
     169        @brief Destroys all Identifiers. Called when exiting the program.
     170    */
     171    void Identifier::destroyAllIdentifiers()
     172    {
     173        for (std::map<std::string, Identifier*>::iterator it = Identifier::getIdentifierMapIntern().begin(); it != Identifier::getIdentifierMapIntern().end(); ++it)
     174            delete (it->second);
     175    }
     176
     177    /**
    155178        @brief Sets the name of the class.
    156179        @param name The name
     
    282305        {
    283306            COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << "." << std::endl;
     307            delete (it->second);
    284308        }
    285309
     
    329353        {
    330354            COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << "." << std::endl;
     355            delete (it->second);
    331356        }
    332357
     
    367392        else
    368393            return 0;
     394    }
     395
     396    /**
     397        @brief Returns a XMLPortParamContainer that loads a parameter of this class.
     398        @param paramname The name of the parameter
     399        @return The container
     400    */
     401    XMLPortParamContainer* Identifier::getXMLPortParamContainer(const std::string& paramname)
     402    {
     403        std::map<std::string, XMLPortParamContainer*>::const_iterator it = xmlportParamContainers_.find(paramname);
     404        if (it != xmlportParamContainers_.end())
     405            return ((*it).second);
     406        else
     407            return 0;
     408    }
     409
     410    /**
     411        @brief Adds a new XMLPortParamContainer that loads a parameter of this class.
     412        @param paramname The name of the parameter
     413        @param container The container
     414    */
     415    void Identifier::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)
     416    {
     417        this->xmlportParamContainers_[paramname] = container;
     418    }
     419
     420    /**
     421        @brief Returns a XMLPortObjectContainer that attaches an object to this class.
     422        @param sectionname The name of the section that contains the attachable objects
     423        @return The container
     424    */
     425    XMLPortObjectContainer* Identifier::getXMLPortObjectContainer(const std::string& sectionname)
     426    {
     427        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = xmlportObjectContainers_.find(sectionname);
     428        if (it != xmlportObjectContainers_.end())
     429            return ((*it).second);
     430        else
     431            return 0;
     432    }
     433
     434    /**
     435        @brief Adds a new XMLPortObjectContainer that attaches an object to this class.
     436        @param sectionname The name of the section that contains the attachable objects
     437        @param container The container
     438    */
     439    void Identifier::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)
     440    {
     441        this->xmlportObjectContainers_[sectionname] = container;
    369442    }
    370443
Note: See TracChangeset for help on using the changeset viewer.