Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 1, 2008, 2:51:02 PM (16 years ago)
Author:
rgrieder
Message:
  • Added debug overlay that is constantly shown in graphics mode. F2 toggles its visibility, but only in level mode for now.
  • Added ConstructionCallback to get informed about the construction of any object of a specific type. Use RegisterConstructionCallback(ThisClassName, TargetClassName, FunctionName); to register such a callback.
File:
1 edited

Legend:

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

    r2063 r2084  
    6363        this->bHasConfigValues_ = false;
    6464        this->bHasConsoleCommands_ = false;
     65        this->bHasConstructionCallback_ = false;
    6566
    6667        this->children_ = new std::set<const Identifier*>();
     
    508509
    509510    /**
     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;
     540    }
     541
     542    /**
    510543        @brief Lists the names of all Identifiers in a std::set<const Identifier*>.
    511544        @param out The outstream
Note: See TracChangeset for help on using the changeset viewer.