Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchie/src/Identifier.cc @ 219

Last change on this file since 219 was 219, checked in by landauf, 16 years ago
  • removed the "ClassHierarchy" manager-class and put its sole feature (bIsCreatingClassHierarchy_) directly into the Identifier.
  • added a dynamic_cast from OrxonoxClass to BaseObject to the Factory. OrxonoxClass is needed because several classes use Interfaces, but all classes are derived at least from BaseObject, so the cast will work.
File size: 3.4 KB
Line 
1#include "Identifier.h"
2
3namespace orxonox
4{
5    // ###############################
6    // ###       Identifier        ###
7    // ###############################
8    int Identifier::hierarchyCreatingCounter_s = 0;
9
10    Identifier::Identifier()
11    {
12        this->bCreatedOneObject_ = false;
13//        this->directParents_ = new IdentifierList();
14//        this->allParents_ = new IdentifierList();
15//        this->directChildren_ = new IdentifierList();
16//        this->allChildren_ = new IdentifierList();
17//        this->objects_ = new ObjectList();
18    }
19
20    Identifier::~Identifier()
21    {
22//        delete this->directParents_;
23//        delete this->allParents_;
24//        delete this->directChildren_;
25//        delete this->allChildren_;
26//        delete this->objects_;
27        delete &this->name_;
28    }
29
30    void Identifier::initialize(IdentifierList* parents)
31    {
32        std::cout << "*** Initialize " << this->name_ << "-Singleton.\n";
33        if (parents)
34        {
35            this->bCreatedOneObject_ = true;
36
37            IdentifierListElement* temp1;
38            IdentifierListElement* temp2;
39            IdentifierListElement* temp3;
40
41            temp1 = parents->first_;
42            while (temp1)
43            {
44                temp2 = temp1->identifier_->directParents_.first_;
45                while (temp2)
46                {
47                    temp3 = parents->first_;
48                    while(temp3)
49                    {
50                        if (temp3->identifier_ == temp2->identifier_)
51                            temp3->bDirect_ = false;
52
53                        temp3 = temp3->next_;
54                    }
55
56                    temp2 = temp2->next_;
57                }
58                temp1 = temp1->next_;
59            }
60
61            temp1 = parents->first_;
62            while (temp1)
63            {
64                if (temp1->bDirect_)
65                {
66                    this->directParents_.add(temp1->identifier_);
67                    temp1->identifier_->directChildren_.add(this);
68                }
69
70                this->allParents_.add(temp1->identifier_);
71                temp1->identifier_->allChildren_.add(this);
72
73                temp1 = temp1->next_;
74            }
75        }
76    }
77
78    void Identifier::addObject(OrxonoxClass* object)
79    {
80        std::cout << "*** Added " << this->name_ << " to list.\n";
81        this->objects_.add(object);
82    }
83
84    void Identifier::removeObject(OrxonoxClass* object)
85    {
86        std::cout << "*** Removed " << this->name_ << " from list.\n";
87        this->objects_.remove(object);
88    }
89
90    bool Identifier::isA(Identifier* identifier)
91    {
92        return (identifier == this || this->allParents_.isInList(identifier));
93    }
94
95    bool Identifier::isDirectlyA(Identifier* identifier)
96    {
97        return (identifier == this);
98    }
99
100    bool Identifier::isChildOf(Identifier* identifier)
101    {
102        return this->allParents_.isInList(identifier);
103    }
104
105    bool Identifier::isDirectChildOf(Identifier* identifier)
106    {
107        return this->directParents_.isInList(identifier);
108    }
109
110    bool Identifier::isParentOf(Identifier* identifier)
111    {
112        return this->allChildren_.isInList(identifier);
113    }
114
115    bool Identifier::isDirectParentOf(Identifier* identifier)
116    {
117        return this->directChildren_.isInList(identifier);
118    }
119}
Note: See TracBrowser for help on using the repository browser.