Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 1, 2008, 7:04:09 PM (16 years ago)
Author:
landauf
Message:

merged objecthierarchy branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/Identifier.cc

    r1856 r2087  
    5959        this->bSetName_ = false;
    6060        this->factory_ = 0;
     61        this->bLoadable_ = true;
    6162
    6263        this->bHasConfigValues_ = false;
    6364        this->bHasConsoleCommands_ = false;
     65        this->bHasConstructionCallback_ = false;
    6466
    6567        this->children_ = new std::set<const Identifier*>();
     
    213215        @return The new object
    214216    */
    215     BaseObject* Identifier::fabricate()
     217    BaseObject* Identifier::fabricate(BaseObject* creator)
    216218    {
    217219        if (this->factory_)
    218220        {
    219             return this->factory_->fabricate(); // We have to return a BaseObject, because we don't know the exact type.
     221            return this->factory_->fabricate(creator); // We have to return a BaseObject, because we don't know the exact type.
    220222        }
    221223        else
     
    420422    XMLPortParamContainer* Identifier::getXMLPortParamContainer(const std::string& paramname)
    421423    {
    422         std::map<std::string, XMLPortParamContainer*>::const_iterator it = xmlportParamContainers_.find(paramname);
    423         if (it != xmlportParamContainers_.end())
     424        std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);
     425        if (it != this->xmlportParamContainers_.end())
    424426            return ((*it).second);
    425427        else
     
    434436    void Identifier::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)
    435437    {
     438        std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);
     439        if (it != this->xmlportParamContainers_.end())
     440        {
     441            COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << "." << std::endl;
     442            delete (it->second);
     443        }
     444
    436445        this->xmlportParamContainers_[paramname] = container;
    437446    }
     
    444453    XMLPortObjectContainer* Identifier::getXMLPortObjectContainer(const std::string& sectionname)
    445454    {
    446         std::map<std::string, XMLPortObjectContainer*>::const_iterator it = xmlportObjectContainers_.find(sectionname);
    447         if (it != xmlportObjectContainers_.end())
     455        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);
     456        if (it != this->xmlportObjectContainers_.end())
    448457            return ((*it).second);
    449458        else
     
    458467    void Identifier::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)
    459468    {
     469        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);
     470        if (it != this->xmlportObjectContainers_.end())
     471        {
     472            COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << "." << std::endl;
     473            delete (it->second);
     474        }
     475
    460476        this->xmlportObjectContainers_[sectionname] = container;
     477    }
     478
     479    /**
     480        @brief Returns a XMLPortEventContainer that attaches an event to this class.
     481        @param sectionname The name of the section that contains the event
     482        @return The container
     483    */
     484    XMLPortObjectContainer* Identifier::getXMLPortEventContainer(const std::string& eventname)
     485    {
     486        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);
     487        if (it != this->xmlportEventContainers_.end())
     488            return ((*it).second);
     489        else
     490            return 0;
     491    }
     492
     493    /**
     494        @brief Adds a new XMLPortEventContainer that attaches an event to this class.
     495        @param sectionname The name of the section that contains the event
     496        @param container The container
     497    */
     498    void Identifier::addXMLPortEventContainer(const std::string& eventname, XMLPortObjectContainer* container)
     499    {
     500        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportEventContainers_.find(eventname);
     501        if (it != this->xmlportEventContainers_.end())
     502        {
     503            COUT(2) << "Warning: Overwriting XMLPortEventContainer in class " << this->getName() << "." << std::endl;
     504            delete (it->second);
     505        }
     506
     507        this->xmlportEventContainers_[eventname] = container;
     508    }
     509
     510    /**
     511        @brief Adds a construction callback functor that gets called every time an object is created.
     512        @param functor Functor pointer to any function with no argument.
     513    */
     514    void Identifier::addConstructionCallback(Functor* functor)
     515    {
     516        for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
     517        {
     518            if (this->constructionCallbacks_[i] == functor)
     519                return;
     520        }
     521        this->constructionCallbacks_.push_back(functor);
     522        this->bHasConstructionCallback_ = true;
     523    }
     524
     525    /**
     526        @brief Removes a construction callback functor that gets called every time an object is created.
     527        @param functor Functor pointer to any function with no argument.
     528    */
     529    void Identifier::removeConstructionCallback(Functor* functor)
     530    {
     531        for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
     532        {
     533            if (this->constructionCallbacks_[i] == functor)
     534            {
     535                this->constructionCallbacks_.erase(this->constructionCallbacks_.begin() + i);
     536            }
     537        }
     538        if (constructionCallbacks_.empty())
     539            this->bHasConstructionCallback_ = false;
    461540    }
    462541
Note: See TracChangeset for help on using the changeset viewer.