[197] | 1 | #include "Identifier.h" |
---|
| 2 | |
---|
| 3 | namespace orxonox |
---|
| 4 | { |
---|
| 5 | // ############################### |
---|
| 6 | // ### Identifier ### |
---|
| 7 | // ############################### |
---|
[219] | 8 | int Identifier::hierarchyCreatingCounter_s = 0; |
---|
| 9 | |
---|
[197] | 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 | { |
---|
[231] | 22 | #if HIERARCHY_VERBOSE |
---|
[197] | 23 | std::cout << "*** Initialize " << this->name_ << "-Singleton.\n"; |
---|
[231] | 24 | #endif |
---|
[197] | 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 | { |
---|
[219] | 36 | temp2 = temp1->identifier_->directParents_.first_; |
---|
[197] | 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 | { |
---|
[219] | 58 | this->directParents_.add(temp1->identifier_); |
---|
| 59 | temp1->identifier_->directChildren_.add(this); |
---|
[197] | 60 | } |
---|
| 61 | |
---|
[219] | 62 | this->allParents_.add(temp1->identifier_); |
---|
| 63 | temp1->identifier_->allChildren_.add(this); |
---|
[197] | 64 | |
---|
| 65 | temp1 = temp1->next_; |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | bool Identifier::isA(Identifier* identifier) |
---|
| 71 | { |
---|
[219] | 72 | return (identifier == this || this->allParents_.isInList(identifier)); |
---|
[197] | 73 | } |
---|
| 74 | |
---|
| 75 | bool Identifier::isDirectlyA(Identifier* identifier) |
---|
| 76 | { |
---|
| 77 | return (identifier == this); |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | bool Identifier::isChildOf(Identifier* identifier) |
---|
| 81 | { |
---|
[219] | 82 | return this->allParents_.isInList(identifier); |
---|
[197] | 83 | } |
---|
| 84 | |
---|
| 85 | bool Identifier::isDirectChildOf(Identifier* identifier) |
---|
| 86 | { |
---|
[219] | 87 | return this->directParents_.isInList(identifier); |
---|
[197] | 88 | } |
---|
| 89 | |
---|
| 90 | bool Identifier::isParentOf(Identifier* identifier) |
---|
| 91 | { |
---|
[219] | 92 | return this->allChildren_.isInList(identifier); |
---|
[197] | 93 | } |
---|
| 94 | |
---|
| 95 | bool Identifier::isDirectParentOf(Identifier* identifier) |
---|
| 96 | { |
---|
[219] | 97 | return this->directChildren_.isInList(identifier); |
---|
[197] | 98 | } |
---|
| 99 | } |
---|