Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 13, 2009, 5:05:17 PM (16 years ago)
Author:
dafrick
Message:

Hopefully merged trunk successfully into pickup branch.

Location:
code/branches/pickup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup

  • code/branches/pickup/src/libraries/core/OrxonoxClass.cc

    r5738 r5935  
    3636#include "MetaObjectList.h"
    3737#include "Identifier.h"
     38#include "WeakPtr.h"
    3839
    3940namespace orxonox
     
    4546        this->parents_ = 0;
    4647        this->metaList_ = new MetaObjectList();
     48        this->referenceCount_ = 0;
     49        this->requestedDestruction_ = false;
    4750    }
    4851
     
    5053    OrxonoxClass::~OrxonoxClass()
    5154    {
     55//        if (!this->requestedDestruction_)
     56//            COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ")" << std::endl;
     57
     58        assert(this->referenceCount_ <= 0);
     59
    5260        delete this->metaList_;
    5361
     
    5563        if (this->parents_)
    5664            delete this->parents_;
     65           
     66        // reset all weak pointers pointing to this object
     67        for (std::set<WeakPtr<OrxonoxClass>*>::iterator it = this->weakPointers_.begin(); it != this->weakPointers_.end(); )
     68            (*(it++))->objectDeleted();
     69    }
     70
     71    /** @brief Deletes the object if no smart pointers point to this object. Otherwise schedules the object to be deleted as soon as possible. */
     72    void OrxonoxClass::destroy()
     73    {
     74        this->requestedDestruction_ = true;
     75        if (this->referenceCount_ == 0)
     76            delete this;
    5777    }
    5878
     
    7898
    7999    /** @brief Returns true if the objects class is of the given type or a derivative. */
    80     template <class B> bool OrxonoxClass::isA(const SubclassIdentifier<B>* identifier)
    81         { return this->getIdentifier()->isA(identifier->getIdentifier()); }
    82     /** @brief Returns true if the objects class is exactly of the given type. */
    83     template <class B> bool OrxonoxClass::isExactlyA(const SubclassIdentifier<B>* identifier)
    84         { return this->getIdentifier()->isExactlyA(identifier->getIdentifier()); }
    85     /** @brief Returns true if the objects class is a child of the given type. */
    86     template <class B> bool OrxonoxClass::isChildOf(const SubclassIdentifier<B>* identifier)
    87         { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
    88     /** @brief Returns true if the objects class is a direct child of the given type. */
    89     template <class B> bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<B>* identifier)
    90         { return this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); }
    91     /** @brief Returns true if the objects class is a parent of the given type. */
    92     template <class B> bool OrxonoxClass::isParentOf(const SubclassIdentifier<B>* identifier)
    93         { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
    94     /** @brief Returns true if the objects class is a direct parent of the given type. */
    95     template <class B> bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<B>* identifier)
    96         { return this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); }
    97 
    98 
    99     /** @brief Returns true if the objects class is of the given type or a derivative. */
    100     template <class B> bool OrxonoxClass::isA(const SubclassIdentifier<B> identifier)
    101         { return this->getIdentifier()->isA(identifier.getIdentifier()); }
    102     /** @brief Returns true if the objects class is exactly of the given type. */
    103     template <class B> bool OrxonoxClass::isExactlyA(const SubclassIdentifier<B> identifier)
    104         { return this->getIdentifier()->isExactlyA(identifier.getIdentifier()); }
    105     /** @brief Returns true if the objects class is a child of the given type. */
    106     template <class B> bool OrxonoxClass::isChildOf(const SubclassIdentifier<B> identifier)
    107         { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
    108     /** @brief Returns true if the objects class is a direct child of the given type. */
    109     template <class B> bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<B> identifier)
    110         { return this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); }
    111     /** @brief Returns true if the objects class is a parent of the given type. */
    112     template <class B> bool OrxonoxClass::isParentOf(const SubclassIdentifier<B> identifier)
    113         { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
    114     /** @brief Returns true if the objects class is a direct parent of the given type. */
    115     template <class B> bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<B> identifier)
    116         { return this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); }
    117 
    118 
    119     /** @brief Returns true if the objects class is of the given type or a derivative. */
    120100    bool OrxonoxClass::isA(const OrxonoxClass* object)
    121101        { return this->getIdentifier()->isA(object->getIdentifier()); }
Note: See TracChangeset for help on using the changeset viewer.