Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 220


Ignore:
Timestamp:
Nov 19, 2007, 11:01:25 PM (17 years ago)
Author:
landauf
Message:
  • fixed a small bug in the object hierarchy
  • new objects are now added to all class-lists they're derived from (until now they were only added to the list of their class). this means: i'm replacing the tree-structure by a mountain-one, which costs more memory but allows faster iteration.
Location:
code/branches/objecthierarchie/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchie/src/BaseObject.h

    r219 r220  
    5050            inline bool isDirectParentOf(BaseIdentifier<class B> identifier)
    5151                { this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); }
    52 /*
     52
    5353            inline bool isA(OrxonoxClass* object)
    5454                { this->getIdentifier()->isA(object->getIdentifier()); }
    5555            inline bool isDirectlyA(OrxonoxClass* object)
    56                 { this->getIdentifier()->isDirectlyA(object->getIdentifier); }
     56                { this->getIdentifier()->isDirectlyA(object->getIdentifier()); }
    5757            inline bool isChildOf(OrxonoxClass* object)
    58                 { this->getIdentifier()->isChildOf(object->getIdentifier); }
     58                { this->getIdentifier()->isChildOf(object->getIdentifier()); }
    5959            inline bool isDirectChildOf(OrxonoxClass* object)
    60                 { this->getIdentifier()->isDirectChildOf(object->getIdentifier); }
     60                { this->getIdentifier()->isDirectChildOf(object->getIdentifier()); }
    6161            inline bool isParentOf(OrxonoxClass* object)
    62                 { this->getIdentifier()->isParentOf(object->getIdentifier); }
     62                { this->getIdentifier()->isParentOf(object->getIdentifier()); }
    6363            inline bool isDirectParentOf(OrxonoxClass* object)
    64                 { this->getIdentifier()->isDirectParentOf(object->getIdentifier); }
    65 */
     64                { this->getIdentifier()->isDirectParentOf(object->getIdentifier()); }
     65
    6666    };
    6767}
  • code/branches/objecthierarchie/src/Identifier.cc

    r219 r220  
    7878    void Identifier::addObject(OrxonoxClass* object)
    7979    {
    80         std::cout << "*** Added " << this->name_ << " to list.\n";
     80        std::cout << "*** Added object to " << this->name_ << "-list.\n";
    8181        this->objects_.add(object);
    8282    }
     
    8484    void Identifier::removeObject(OrxonoxClass* object)
    8585    {
    86         std::cout << "*** Removed " << this->name_ << " from list.\n";
     86        std::cout << "*** Removed object from " << this->name_ << "-list.\n";
    8787        this->objects_.remove(object);
     88
     89        IdentifierListElement* temp = this->directParents_.first_;
     90        while (temp)
     91        {
     92            temp->identifier_->removeObject(object);
     93            temp = temp->next_;
     94        }
    8895    }
    8996
  • code/branches/objecthierarchie/src/Identifier.h

    r219 r220  
    149149                ClassFactory::add(name, pointer_s);
    150150
    151                 pointer_s->initialize(parents);
     151                if (!bRootClass)
     152                    pointer_s->initialize(parents);
     153                else
     154                    pointer_s->initialize(NULL);
    152155            }
    153156            else
  • code/branches/objecthierarchie/src/IdentifierIncludes.h

    r219 r220  
    66
    77
    8 #define registerRootObject(ClassName) \
    9     std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
     8#define internRegisterRootObject(ClassName, bAbstract) \
    109    if (Identifier::isCreatingHierarchy() && !this->getParents()) \
    1110        this->setParents(new IdentifierList()); \
    12     if (this->getIdentifier()) \
    13         this->getIdentifier()->removeObject(this); \
    14     this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, true, false)); \
     11    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, true, bAbstract)); \
    1512    if (Identifier::isCreatingHierarchy() && this->getParents()) \
    1613        this->getParents()->add(this->getIdentifier()); \
    1714    this->getIdentifier()->addObject(this)
    1815
     16#define registerRootObject(ClassName) \
     17    std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
     18    internRegisterRootObject(ClassName, false)
     19
    1920#define registerAbstractRootObject(ClassName) \
    20     std::cout << "*** Register Root-Object: " << #ClassName << "\n"; \
    21     if (Identifier::isCreatingHierarchy() && !this->getParents()) \
    22         this->setParents(new IdentifierList()); \
    23     if (this->getIdentifier()) \
    24         this->getIdentifier()->removeObject(this); \
    25     this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, true, true)); \
     21    std::cout << "*** Register abstract Root-Object: " << #ClassName << "\n"; \
     22    internRegisterRootObject(ClassName, true)
     23
     24#define internRegisterObject(ClassName, bAbstract) \
     25    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, false, bAbstract)); \
    2626    if (Identifier::isCreatingHierarchy() && this->getParents()) \
    2727        this->getParents()->add(this->getIdentifier()); \
     
    3030#define registerObject(ClassName) \
    3131    std::cout << "*** Register Object: " << #ClassName << "\n"; \
    32     this->getIdentifier()->removeObject(this); \
    33     this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, false, false)); \
    34     if (Identifier::isCreatingHierarchy() && this->getParents()) \
    35         this->getParents()->add(this->getIdentifier()); \
    36     this->getIdentifier()->addObject(this)
     32    internRegisterObject(ClassName, false)
    3733
    3834#define registerAbstractObject(ClassName) \
    39     std::cout << "*** Register Object: " << #ClassName << "\n"; \
    40     this->getIdentifier()->removeObject(this); \
    41     this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, false, true)); \
    42     if (Identifier::isCreatingHierarchy() && this->getParents()) \
    43         this->getParents()->add(this->getIdentifier()); \
    44     this->getIdentifier()->addObject(this)
     35    std::cout << "*** Register abstract Object: " << #ClassName << "\n"; \
     36    internRegisterObject(ClassName, true)
    4537
    4638#define unregisterObject() \
Note: See TracChangeset for help on using the changeset viewer.