Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 12, 2009, 1:46:26 PM (15 years ago)
Author:
rgrieder
Message:

Removing superfluous feature: construction callbacks.
If we ever need them again (which I highly doubt since you can achieve the same with an interface class), SVN is at our service.

Location:
code/branches/pch/src/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pch/src/core/CoreIncludes.h

    r2171 r3151  
    4646#include "Factory.h"
    4747#include "ClassFactory.h"
    48 #include "Functor.h"
    4948#include "util/Debug.h"
    5049
     
    129128    orxonox::Factory::getIdentifier(networkID)
    130129
    131 /**
    132     @brief Registers a member function as callback when an object of 'type' is created.
    133     @param
    134 */
    135 #define RegisterConstructionCallback(ThisClassName, TargetClassName, FunctionName) \
    136     orxonox::ClassIdentifier<TargetClassName>::getIdentifier()->addConstructionCallback( \
    137         orxonox::createFunctor(&ThisClassName::FunctionName)->setObject(this))
    138 
    139130#endif /* _CoreIncludes_H__ */
  • code/branches/pch/src/core/Identifier.cc

    r2662 r3151  
    6363        this->bHasConfigValues_ = false;
    6464        this->bHasConsoleCommands_ = false;
    65         this->bHasConstructionCallback_ = false;
    6665
    6766        this->children_ = new std::set<const Identifier*>();
     
    9392        for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)
    9493            delete (it->second);
    95         for (std::vector<Functor*>::iterator it = this->constructionCallbacks_.begin(); it != this->constructionCallbacks_.end(); ++it)
    96             delete *it;
    9794    }
    9895
     
    519516
    520517    /**
    521         @brief Adds a construction callback functor that gets called every time an object is created.
    522         @param functor Functor pointer to any function with no argument.
    523     */
    524     void Identifier::addConstructionCallback(Functor* functor)
    525     {
    526         for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
    527         {
    528             if (this->constructionCallbacks_[i] == functor)
    529                 return;
    530         }
    531         this->constructionCallbacks_.push_back(functor);
    532         this->bHasConstructionCallback_ = true;
    533     }
    534 
    535     /**
    536         @brief Removes a construction callback functor that gets called every time an object is created.
    537         @param functor Functor pointer to any function with no argument.
    538     */
    539     void Identifier::removeConstructionCallback(Functor* functor)
    540     {
    541         for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
    542         {
    543             if (this->constructionCallbacks_[i] == functor)
    544             {
    545                 this->constructionCallbacks_.erase(this->constructionCallbacks_.begin() + i);
    546             }
    547         }
    548         if (constructionCallbacks_.empty())
    549             this->bHasConstructionCallback_ = false;
    550     }
    551 
    552     /**
    553518        @brief Lists the names of all Identifiers in a std::set<const Identifier*>.
    554519        @param out The outstream
  • code/branches/pch/src/core/Identifier.h

    r3145 r3151  
    223223            /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */
    224224            inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }
    225             /** @brief Returns true if this class has at least one construction callback Functor registered. */
    226             inline bool hasConstructionCallback() const { return this->bHasConstructionCallback_; }
    227225
    228226            /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */
     
    251249            ConsoleCommand* getConsoleCommand(const std::string& name) const;
    252250            ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
    253 
    254             void addConstructionCallback(Functor* functor);
    255             void removeConstructionCallback(Functor* functor);
    256251
    257252            void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
     
    276271            /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */
    277272            inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }
    278 
    279             bool bHasConstructionCallback_;                                //!< True if at least one Functor is registered to get informed when an object of type T is created.
    280             std::vector<Functor*> constructionCallbacks_;                  //!< All construction callback Functors of this class.
    281273
    282274            ObjectListBase* objects_;                                      //!< The list of all objects of this class
     
    439431        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
    440432        object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
    441         if (this->bHasConstructionCallback_)
    442         {
    443             // Call all registered callbacks that a new object of type T has been created.
    444             // Do NOT deliver a T* pointer here because it's way too risky (object not yet fully created).
    445             for (unsigned int i = 0; i < this->constructionCallbacks_.size(); ++i)
    446                 (*constructionCallbacks_[i])();
    447         }
    448433    }
    449434
Note: See TracChangeset for help on using the changeset viewer.