Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9610


Ignore:
Timestamp:
Apr 1, 2013, 10:57:34 AM (12 years ago)
Author:
landauf
Message:

context is now a Listable itself as well

Location:
code/branches/core6
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core6/src/libraries/core/object/Context.cc

    r9609 r9610  
    3737namespace orxonox
    3838{
    39     Context::Context(Context* context) : parentContext_(context)
     39    Context::Context(Context* context) : Listable(this), parentContext_(context)
    4040    {
     41        // we have to call Listable(this) to avoid circular initialization when creating a Context because Listable calls Context::getRootContext() by
     42        // default AND we have to set the context again in the constructor because of other classes inheriting from Context (Listable is a virtual base
     43        // and each subclass must call its constructor individually, so either all subclasses add Listable(this) to their initialization list or we call
     44        // setContext(this) here).
     45        this->setContext(this);
    4146    }
    4247
    4348    Context::~Context()
    4449    {
     50        // unregister context from object lists before object lists are destroyed
     51        this->unregisterObject();
    4552        for (size_t i = 0; i < this->objectLists_.size(); ++i)
    4653            delete this->objectLists_[i];
  • code/branches/core6/src/libraries/core/object/Context.h

    r9608 r9610  
    3939#include <vector>
    4040
     41#include "Listable.h"
     42
    4143namespace orxonox
    4244{
    43     class _CoreExport Context
     45    class _CoreExport Context : virtual public Listable
    4446    {
    4547        public:
  • code/branches/core6/src/libraries/core/object/Listable.cc

    r9608 r9610  
    4848
    4949    /**
     50        @brief Constructor: Allocates space in the element list and assignes the context
     51    */
     52    Listable::Listable(Context* context)
     53    {
     54        this->context_ = context;
     55        this->elements_.reserve(6);
     56    }
     57
     58    /**
    5059        @brief Destructor: Removes the object from the object-lists
    5160    */
  • code/branches/core6/src/libraries/core/object/Listable.h

    r9608 r9610  
    5353        public:
    5454            Listable();
     55            Listable(Context* context);
    5556            virtual ~Listable();
    5657
  • code/branches/core6/test/core/CMakeLists.txt

    r9605 r9610  
    1616    command/CommandTest.cc
    1717    object/ClassFactoryTest.cc
     18    object/ContextTest.cc
    1819    object/DestroyableTest.cc
    1920    object/IteratorTest.cc
Note: See TracChangeset for help on using the changeset viewer.