Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 231 was 231, checked in by landauf, 17 years ago

added preprocessor-flag to change verbose mode of class-hierarchy and set it to false:

Identifier.h:
#define HIERARCHY_VERBOSE false

File size: 2.6 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    }
14
15    Identifier::~Identifier()
16    {
17        delete &this->name_;
18    }
19
20    void Identifier::initialize(IdentifierList* parents)
21    {
22#if HIERARCHY_VERBOSE
23        std::cout << "*** Initialize " << this->name_ << "-Singleton.\n";
24#endif
25        if (parents)
26        {
27            this->bCreatedOneObject_ = true;
28
29            IdentifierListElement* temp1;
30            IdentifierListElement* temp2;
31            IdentifierListElement* temp3;
32
33            temp1 = parents->first_;
34            while (temp1)
35            {
36                temp2 = temp1->identifier_->directParents_.first_;
37                while (temp2)
38                {
39                    temp3 = parents->first_;
40                    while(temp3)
41                    {
42                        if (temp3->identifier_ == temp2->identifier_)
43                            temp3->bDirect_ = false;
44
45                        temp3 = temp3->next_;
46                    }
47
48                    temp2 = temp2->next_;
49                }
50                temp1 = temp1->next_;
51            }
52
53            temp1 = parents->first_;
54            while (temp1)
55            {
56                if (temp1->bDirect_)
57                {
58                    this->directParents_.add(temp1->identifier_);
59                    temp1->identifier_->directChildren_.add(this);
60                }
61
62                this->allParents_.add(temp1->identifier_);
63                temp1->identifier_->allChildren_.add(this);
64
65                temp1 = temp1->next_;
66            }
67        }
68    }
69
70    bool Identifier::isA(Identifier* identifier)
71    {
72        return (identifier == this || this->allParents_.isInList(identifier));
73    }
74
75    bool Identifier::isDirectlyA(Identifier* identifier)
76    {
77        return (identifier == this);
78    }
79
80    bool Identifier::isChildOf(Identifier* identifier)
81    {
82        return this->allParents_.isInList(identifier);
83    }
84
85    bool Identifier::isDirectChildOf(Identifier* identifier)
86    {
87        return this->directParents_.isInList(identifier);
88    }
89
90    bool Identifier::isParentOf(Identifier* identifier)
91    {
92        return this->allChildren_.isInList(identifier);
93    }
94
95    bool Identifier::isDirectParentOf(Identifier* identifier)
96    {
97        return this->directChildren_.isInList(identifier);
98    }
99}
Note: See TracBrowser for help on using the repository browser.