1 | #include "Identifier.h" |
---|
2 | |
---|
3 | namespace 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 | std::cout << "*** Initialize " << this->name_ << "-Singleton.\n"; |
---|
23 | if (parents) |
---|
24 | { |
---|
25 | this->bCreatedOneObject_ = true; |
---|
26 | |
---|
27 | IdentifierListElement* temp1; |
---|
28 | IdentifierListElement* temp2; |
---|
29 | IdentifierListElement* temp3; |
---|
30 | |
---|
31 | temp1 = parents->first_; |
---|
32 | while (temp1) |
---|
33 | { |
---|
34 | temp2 = temp1->identifier_->directParents_.first_; |
---|
35 | while (temp2) |
---|
36 | { |
---|
37 | temp3 = parents->first_; |
---|
38 | while(temp3) |
---|
39 | { |
---|
40 | if (temp3->identifier_ == temp2->identifier_) |
---|
41 | temp3->bDirect_ = false; |
---|
42 | |
---|
43 | temp3 = temp3->next_; |
---|
44 | } |
---|
45 | |
---|
46 | temp2 = temp2->next_; |
---|
47 | } |
---|
48 | temp1 = temp1->next_; |
---|
49 | } |
---|
50 | |
---|
51 | temp1 = parents->first_; |
---|
52 | while (temp1) |
---|
53 | { |
---|
54 | if (temp1->bDirect_) |
---|
55 | { |
---|
56 | this->directParents_.add(temp1->identifier_); |
---|
57 | temp1->identifier_->directChildren_.add(this); |
---|
58 | } |
---|
59 | |
---|
60 | this->allParents_.add(temp1->identifier_); |
---|
61 | temp1->identifier_->allChildren_.add(this); |
---|
62 | |
---|
63 | temp1 = temp1->next_; |
---|
64 | } |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | bool Identifier::isA(Identifier* identifier) |
---|
69 | { |
---|
70 | return (identifier == this || this->allParents_.isInList(identifier)); |
---|
71 | } |
---|
72 | |
---|
73 | bool Identifier::isDirectlyA(Identifier* identifier) |
---|
74 | { |
---|
75 | return (identifier == this); |
---|
76 | } |
---|
77 | |
---|
78 | bool Identifier::isChildOf(Identifier* identifier) |
---|
79 | { |
---|
80 | return this->allParents_.isInList(identifier); |
---|
81 | } |
---|
82 | |
---|
83 | bool Identifier::isDirectChildOf(Identifier* identifier) |
---|
84 | { |
---|
85 | return this->directParents_.isInList(identifier); |
---|
86 | } |
---|
87 | |
---|
88 | bool Identifier::isParentOf(Identifier* identifier) |
---|
89 | { |
---|
90 | return this->allChildren_.isInList(identifier); |
---|
91 | } |
---|
92 | |
---|
93 | bool Identifier::isDirectParentOf(Identifier* identifier) |
---|
94 | { |
---|
95 | return this->directChildren_.isInList(identifier); |
---|
96 | } |
---|
97 | } |
---|