Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 243


Ignore:
Timestamp:
Nov 25, 2007, 4:07:56 AM (16 years ago)
Author:
landauf
Message:

removed the "directParent" feature - it was a clever but unnecessary feature.

Location:
code/branches/objecthierarchie/src
Files:
6 edited

Legend:

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

    r242 r243  
    1818            inline bool isChildOf(const Identifier* identifier)
    1919                { this->getIdentifier()->isChildOf(identifier); }
    20             inline bool isDirectChildOf(const Identifier* identifier)
    21                 { this->getIdentifier()->isDirectChildOf(identifier); }
    2220            inline bool isParentOf(const Identifier* identifier)
    2321                { this->getIdentifier()->isParentOf(identifier); }
    24             inline bool isDirectParentOf(const Identifier* identifier)
    25                 { this->getIdentifier()->isDirectParentOf(identifier); }
    2622
    2723            inline bool isA(const SubclassIdentifier<class B>* identifier)
     
    3127            inline bool isChildOf(const SubclassIdentifier<class B>* identifier)
    3228                { this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
    33             inline bool isDirectChildOf(const SubclassIdentifier<class B>* identifier)
    34                 { this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); }
    3529            inline bool isParentOf(const SubclassIdentifier<class B>* identifier)
    3630                { this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
    37             inline bool isDirectParentOf(const SubclassIdentifier<class B>* identifier)
    38                 { this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); }
    3931
    4032            inline bool isA(const SubclassIdentifier<class B> identifier)
     
    4436            inline bool isChildOf(const SubclassIdentifier<class B> identifier)
    4537                { this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
    46             inline bool isDirectChildOf(const SubclassIdentifier<class B> identifier)
    47                 { this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); }
    4838            inline bool isParentOf(const SubclassIdentifier<class B> identifier)
    4939                { this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
    50             inline bool isDirectParentOf(const SubclassIdentifier<class B> identifier)
    51                 { this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); }
    5240
    5341            inline bool isA(const OrxonoxClass* object)
     
    5745            inline bool isChildOf(const OrxonoxClass* object)
    5846                { this->getIdentifier()->isChildOf(object->getIdentifier()); }
    59             inline bool isDirectChildOf(const OrxonoxClass* object)
    60                 { this->getIdentifier()->isDirectChildOf(object->getIdentifier()); }
    6147            inline bool isParentOf(const OrxonoxClass* object)
    6248                { this->getIdentifier()->isParentOf(object->getIdentifier()); }
    63             inline bool isDirectParentOf(const OrxonoxClass* object)
    64                 { this->getIdentifier()->isDirectParentOf(object->getIdentifier()); }
    6549
    6650            std::string name_; // test
  • code/branches/objecthierarchie/src/Identifier.cc

    r241 r243  
    1212        this->bCreatedOneObject_ = false;
    1313
    14         this->directChildren_ = new IdentifierList;
    15         this->allChildren_ = new IdentifierList;
     14        this->children_ = new IdentifierList;
    1615    }
    1716
     
    2019        delete &this->name_;
    2120
    22         delete this->directChildren_;
    23         delete this->allChildren_;
     21        delete this->children_;
    2422    }
    2523
     
    3331            this->bCreatedOneObject_ = true;
    3432
    35             IdentifierListElement* temp1;
    36             IdentifierListElement* temp2;
    37             IdentifierListElement* temp3;
    38 
    39             temp1 = parents->first_;
     33            IdentifierListElement* temp1 = parents->first_;
    4034            while (temp1)
    4135            {
    42                 temp2 = temp1->identifier_->directParents_.first_;
    43                 while (temp2)
    44                 {
    45                     temp3 = parents->first_;
    46                     while(temp3)
    47                     {
    48                         if (temp3->identifier_ == temp2->identifier_)
    49                             temp3->bDirect_ = false;
    50 
    51                         temp3 = temp3->next_;
    52                     }
    53 
    54                     temp2 = temp2->next_;
    55                 }
    56                 temp1 = temp1->next_;
    57             }
    58 
    59             temp1 = parents->first_;
    60             while (temp1)
    61             {
    62                 if (temp1->bDirect_)
    63                 {
    64                     this->directParents_.add(temp1->identifier_);
    65                     temp1->identifier_->getDirectChildren().add(this);
    66                 }
    67 
    68                 this->allParents_.add(temp1->identifier_);
    69                 temp1->identifier_->getAllChildren().add(this);
     36                this->parents_.add(temp1->identifier_);
     37                temp1->identifier_->getChildren().add(this);
    7038
    7139                temp1 = temp1->next_;
     
    7644    bool Identifier::isA(const Identifier* identifier) const
    7745    {
    78         return (identifier == this || this->allParents_.isInList(identifier));
     46        return (identifier == this || this->parents_.isInList(identifier));
    7947    }
    8048
     
    8654    bool Identifier::isChildOf(const Identifier* identifier) const
    8755    {
    88         return this->allParents_.isInList(identifier);
    89     }
    90 
    91     bool Identifier::isDirectChildOf(const Identifier* identifier) const
    92     {
    93         return this->directParents_.isInList(identifier);
     56        return this->parents_.isInList(identifier);
    9457    }
    9558
    9659    bool Identifier::isParentOf(const Identifier* identifier) const
    9760    {
    98         return this->allChildren_->isInList(identifier);
    99     }
    100 
    101     bool Identifier::isDirectParentOf(const Identifier* identifier) const
    102     {
    103         return this->directChildren_->isInList(identifier);
     61        return this->children_->isInList(identifier);
    10462    }
    10563}
  • code/branches/objecthierarchie/src/Identifier.h

    r242 r243  
    2828        public:
    2929            virtual void removeObject(OrxonoxClass* object) const = 0;
     30            virtual void removeObjectIntern(OrxonoxClass* object, bool bIterateForwards) const = 0;
    3031
    3132            virtual BaseObject* fabricate() const = 0;
     
    3435            bool isDirectlyA(const Identifier* identifier) const;
    3536            bool isChildOf(const Identifier* identifier) const;
    36             bool isDirectChildOf(const Identifier* identifier) const;
    3737            bool isParentOf(const Identifier* identifier) const;
    38             bool isDirectParentOf(const Identifier* identifier) const;
    3938
    4039            const std::string& getName() const { return this->name_; }
    41             const IdentifierList& getDirectParents() const { return this->directParents_; }
    42             const IdentifierList& getAllParents() const { return this->allParents_; }
    43             IdentifierList& getDirectChildren() const { return *this->directChildren_; }
    44             IdentifierList& getAllChildren() const { return *this->allChildren_; }
     40            const IdentifierList& getParents() const { return this->parents_; }
     41            IdentifierList& getChildren() const { return *this->children_; }
    4542
    4643            static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
     
    6865            }
    6966
    70             IdentifierList directParents_;
    71             IdentifierList allParents_;
    72             IdentifierList* directChildren_;
    73             IdentifierList* allChildren_;
     67            IdentifierList parents_;
     68            IdentifierList* children_;
    7469
    7570            std::string name_;
     
    9893            static void addObject(T* object);
    9994            void removeObject(OrxonoxClass* object) const;
     95            void removeObjectIntern(OrxonoxClass* object, bool bIterateForwards) const;
    10096
    10197        private:
     
    212208        bool bIterateForwards = !Identifier::isCreatingHierarchy();
    213209
     210        this->removeObjectIntern(object, bIterateForwards);
     211
     212        IdentifierListElement* temp = this->parents_.first_;
     213        while (temp)
     214        {
     215            temp->identifier_->removeObjectIntern(object, bIterateForwards);
     216            temp = temp->next_;
     217        }
     218    }
     219
     220    template <class T>
     221    void ClassIdentifier<T>::removeObjectIntern(OrxonoxClass* object, bool bIterateForwards) const
     222    {
    214223#if HIERARCHY_VERBOSE
    215224        if (bIterateForwards)
     
    220229
    221230        this->objects_->remove(object, bIterateForwards);
    222 
    223         IdentifierListElement* temp = this->directParents_.first_;
    224         while (temp)
    225         {
    226             temp->identifier_->removeObject(object);
    227             temp = temp->next_;
    228         }
    229231    }
    230232
     
    295297            inline bool isChildOf(const Identifier* identifier) const
    296298                { return this->identifier_->isChildOf(identifier); }
    297             inline bool isDirectChildOf(const Identifier* identifier) const
    298                 { return this->identifier_->isDirectChildOf(identifier); }
    299299            inline bool isParentOf(const Identifier* identifier) const
    300300                { return this->identifier_->isParentOf(identifier); }
    301             inline bool isDirectParentOf(const Identifier* identifier) const
    302                 { return this->identifier_->isDirectParentOf(identifier); }
    303301
    304302        private:
  • code/branches/objecthierarchie/src/IdentifierList.cc

    r241 r243  
    9898        this->identifier_ = identifier;
    9999        this->next_ = 0;
    100         this->bDirect_ = true;
    101100    }
    102101
  • code/branches/objecthierarchie/src/IdentifierList.h

    r241 r243  
    1616            const Identifier* identifier_;
    1717            IdentifierListElement* next_;
    18             bool bDirect_;
    1918    };
    2019
  • code/branches/objecthierarchie/src/orxonox.cc

    r242 r243  
    147147        A3B2C1* test5_17 = new A3B2C1();
    148148        A3B2C2* test5_18 = new A3B2C2();
    149 */
    150 /*
     149
    151150        OrxonoxClass* test5;
    152151        for (int i = 0; i <= 18; i++)
    153152        {
    154           if (i == 0) test5 = test1;
     153          if (i == 0) test5 = new BaseObject;
    155154          if (i == 1) test5 = test5_01;
    156155          if (i == 2) test5 = test5_02;
     
    173172
    174173          std::cout << "\n";
    175           std::cout << test5->getIdentifier()->getName() << ": directParents:  " << test5->getIdentifier()->getDirectParents()->toString() << "\n";
    176           std::cout << test5->getIdentifier()->getName() << ": allParents:     " << test5->getIdentifier()->getAllParents()->toString() << "\n";
    177           std::cout << test5->getIdentifier()->getName() << ": directChildren: " << test5->getIdentifier()->getDirectChildren()->toString() << "\n";
    178           std::cout << test5->getIdentifier()->getName() << ": allChildren:    " << test5->getIdentifier()->getAllChildren()->toString() << "\n";
     174          std::cout << test5->getIdentifier()->getName() << ": parents:     " << test5->getIdentifier()->getParents().toString() << "\n";
     175          std::cout << test5->getIdentifier()->getName() << ": children:    " << test5->getIdentifier()->getChildren().toString() << "\n";
    179176        }
    180177*/
     
    284281
    285282        std::cout << "\n";
    286         std::cout << "isDirectChildOf(XYZ)-Test:\n";
    287         std::cout << "test5_04 = A1B1, Erwartet: 1 0 0 0 0 0 0\n";
    288         testandcout(test5_04->isDirectChildOf(Class(A1)));
    289         testandcout(test5_04->isDirectChildOf(Class(A2)));
    290         testandcout(test5_04->isDirectChildOf(Class(BaseObject)));
    291         testandcout(test5_04->isDirectChildOf(Class(Interface1)));
    292         testandcout(test5_04->isDirectChildOf(Class(Interface2)));
    293         testandcout(test5_04->isDirectChildOf(Class(A1B1C2)));
    294         testandcout(test5_04->isDirectChildOf(Class(A1B1)));
    295 
    296         std::cout << "\n";
    297         std::cout << "test5_06 = A2B1, Erwartet: 0 1 0 0 0 0 0\n";
    298         testandcout(test5_06->isDirectChildOf(Class(A1)));
    299         testandcout(test5_06->isDirectChildOf(Class(A2)));
    300         testandcout(test5_06->isDirectChildOf(Class(BaseObject)));
    301         testandcout(test5_06->isDirectChildOf(Class(Interface1)));
    302         testandcout(test5_06->isDirectChildOf(Class(Interface2)));
    303         testandcout(test5_06->isDirectChildOf(Class(A1B1C2)));
    304         testandcout(test5_06->isDirectChildOf(Class(A1B1)));
    305 
    306         std::cout << "\n";
    307         std::cout << "test5_07 = A2B2, Erwartet: 0 1 0 1 0 0\n";
    308         testandcout(test5_07->isDirectChildOf(Class(A1)));
    309         testandcout(test5_07->isDirectChildOf(Class(A2)));
    310         testandcout(test5_07->isDirectChildOf(Class(BaseObject)));
    311         testandcout(test5_07->isDirectChildOf(Class(Interface1)));
    312         testandcout(test5_07->isDirectChildOf(Class(Interface2)));
    313         testandcout(test5_07->isDirectChildOf(Class(A1B1C2)));
    314 
    315         std::cout << "\n";
    316         std::cout << "test5_08 = A3B1, Erwartet: 0 0 0 0 0 0\n";
    317         testandcout(test5_08->isDirectChildOf(Class(A1)));
    318         testandcout(test5_08->isDirectChildOf(Class(A2)));
    319         testandcout(test5_08->isDirectChildOf(Class(BaseObject)));
    320         testandcout(test5_08->isDirectChildOf(Class(Interface1)));
    321         testandcout(test5_08->isDirectChildOf(Class(Interface2)));
    322         testandcout(test5_08->isDirectChildOf(Class(A1B1C2)));
    323 
    324         std::cout << "\n";
    325         std::cout << "test5_09 = A3B2, Erwartet: 0 0 0 0 1 0\n";
    326         testandcout(test5_09->isDirectChildOf(Class(A1)));
    327         testandcout(test5_09->isDirectChildOf(Class(A2)));
    328         testandcout(test5_09->isDirectChildOf(Class(BaseObject)));
    329         testandcout(test5_09->isDirectChildOf(Class(Interface1)));
    330         testandcout(test5_09->isDirectChildOf(Class(Interface2)));
    331         testandcout(test5_09->isDirectChildOf(Class(A1B1C2)));
    332 
    333         std::cout << "\n";
    334283        std::cout << "isParentOf(XYZ)-Test:\n";
    335284        std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 1 1 1\n";
     
    361310        testandcout(Class(Interface1)->isParentOf(Class(A2B2)));
    362311        testandcout(Class(Interface1)->isParentOf(Class(A3B1C2)));
    363 
    364         std::cout << "\n";
    365         std::cout << "isDirectParentOf(XYZ)-Test:\n";
    366         std::cout << "test1 = BaseObject, Erwartet: 0 0 1 1 0 0 0\n";
    367         testandcout(test1->isDirectParentOf(Class(BaseObject)));
    368         testandcout(test1->isDirectParentOf(Class(Interface1)));
    369         testandcout(test1->isDirectParentOf(Class(A1)));
    370         testandcout(test1->isDirectParentOf(Class(A2)));
    371         testandcout(test1->isDirectParentOf(Class(A1B1)));
    372         testandcout(test1->isDirectParentOf(Class(A2B2)));
    373         testandcout(test1->isDirectParentOf(Class(A3B1C2)));
    374 
    375         std::cout << "\n";
    376         std::cout << "test5_01 = A1, Erwartet: 0 0 0 0 1 0 0\n";
    377         testandcout(test5_01->isDirectParentOf(Class(BaseObject)));
    378         testandcout(test5_01->isDirectParentOf(Class(Interface1)));
    379         testandcout(test5_01->isDirectParentOf(Class(A1)));
    380         testandcout(test5_01->isDirectParentOf(Class(A2)));
    381         testandcout(test5_01->isDirectParentOf(Class(A1B1)));
    382         testandcout(test5_01->isDirectParentOf(Class(A2B2)));
    383         testandcout(test5_01->isDirectParentOf(Class(A3B1C2)));
    384 
    385         std::cout << "\n";
    386         std::cout << "Interface1, Erwartet: 0 0 0 0 0 1 0\n";
    387         testandcout(Class(Interface1)->isDirectParentOf(Class(BaseObject)));
    388         testandcout(Class(Interface1)->isDirectParentOf(Class(Interface1)));
    389         testandcout(Class(Interface1)->isDirectParentOf(Class(A1)));
    390         testandcout(Class(Interface1)->isDirectParentOf(Class(A2)));
    391         testandcout(Class(Interface1)->isDirectParentOf(Class(A1B1)));
    392         testandcout(Class(Interface1)->isDirectParentOf(Class(A2B2)));
    393         testandcout(Class(Interface1)->isDirectParentOf(Class(A3B1C2)));
    394312*/
    395313/*
     
    407325        std::cout << "6:\n";
    408326        Identifier* test6_06 = Class(A1B1C1);
    409 */
    410 /*
    411         std::cout << "\n";
    412         std::cout << "BaseObject: directParents:  " << Class(BaseObject)->getDirectParents()->toString() << "\n";
    413         std::cout << "BaseObject: allParents:     " << Class(BaseObject)->getAllParents()->toString() << "\n";
    414         std::cout << "BaseObject: directChildren: " << Class(BaseObject)->getDirectChildren()->toString() << "\n";
    415         std::cout << "BaseObject: allChildren:    " << Class(BaseObject)->getAllChildren()->toString() << "\n";
    416 
    417         std::cout << "\n";
    418         std::cout << "A1: directParents:  " << Class(A1)->getDirectParents()->toString() << "\n";
    419         std::cout << "A1: allParents:     " << Class(A1)->getAllParents()->toString() << "\n";
    420         std::cout << "A1: directChildren: " << Class(A1)->getDirectChildren()->toString() << "\n";
    421         std::cout << "A1: allChildren:    " << Class(A1)->getAllChildren()->toString() << "\n";
    422 
    423         std::cout << "\n";
    424         std::cout << "A1B1: directParents:  " << Class(A1B1)->getDirectParents()->toString() << "\n";
    425         std::cout << "A1B1: allParents:     " << Class(A1B1)->getAllParents()->toString() << "\n";
    426         std::cout << "A1B1: directChildren: " << Class(A1B1)->getDirectChildren()->toString() << "\n";
    427         std::cout << "A1B1: allChildren:    " << Class(A1B1)->getAllChildren()->toString() << "\n";
    428 
    429         std::cout << "\n";
    430         std::cout << "A1B1C1: directParents:  " << Class(A1B1C1)->getDirectParents()->toString() << "\n";
    431         std::cout << "A1B1C1: allParents:     " << Class(A1B1C1)->getAllParents()->toString() << "\n";
    432         std::cout << "A1B1C1: directChildren: " << Class(A1B1C1)->getDirectChildren()->toString() << "\n";
    433         std::cout << "A1B1C1: allChildren:    " << Class(A1B1C1)->getAllChildren()->toString() << "\n";
     327
     328        std::cout << "\n";
     329        std::cout << "BaseObject: parents:     " << Class(BaseObject)->getParents().toString() << "\n";
     330        std::cout << "BaseObject: children:    " << Class(BaseObject)->getChildren().toString() << "\n";
     331
     332        std::cout << "\n";
     333        std::cout << "A1: parents:     " << Class(A1)->getParents().toString() << "\n";
     334        std::cout << "A1: children:    " << Class(A1)->getChildren().toString() << "\n";
     335
     336        std::cout << "\n";
     337        std::cout << "A1B1: parents:     " << Class(A1B1)->getParents().toString() << "\n";
     338        std::cout << "A1B1: children:    " << Class(A1B1)->getChildren().toString() << "\n";
     339
     340        std::cout << "\n";
     341        std::cout << "A1B1C1: parents:     " << Class(A1B1C1)->getParents().toString() << "\n";
     342        std::cout << "A1B1C1: children:    " << Class(A1B1C1)->getChildren().toString() << "\n";
    434343
    435344        std::cout << "\n";
     
    437346        std::cout << "\n";
    438347        std::cout << "A2 parent of A2B1C1: " << Class(A2)->isParentOf(Class(A2B1C1)) << "\n";
    439 */
    440 /*
     348
     349
    441350        std::cout << "Test 7\n";
    442351        std::cout << "1\n";
     
    527436        delete test9_06;
    528437*/
     438
    529439        std::cout << "Test 10\n";
    530440        Identifier* test10_01 = Class(A1B2);
     
    624534        for (Iterator<A2B1C1> it; it; --it)
    625535            std::cout << "Name: " << it->name_ << "\n";
     536
    626537
    627538      }
Note: See TracChangeset for help on using the changeset viewer.