[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 | { |
---|
| 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 | { |
---|
[219] | 34 | temp2 = temp1->identifier_->directParents_.first_; |
---|
[197] | 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 | { |
---|
[219] | 56 | this->directParents_.add(temp1->identifier_); |
---|
| 57 | temp1->identifier_->directChildren_.add(this); |
---|
[197] | 58 | } |
---|
| 59 | |
---|
[219] | 60 | this->allParents_.add(temp1->identifier_); |
---|
| 61 | temp1->identifier_->allChildren_.add(this); |
---|
[197] | 62 | |
---|
| 63 | temp1 = temp1->next_; |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | bool Identifier::isA(Identifier* identifier) |
---|
| 69 | { |
---|
[219] | 70 | return (identifier == this || this->allParents_.isInList(identifier)); |
---|
[197] | 71 | } |
---|
| 72 | |
---|
| 73 | bool Identifier::isDirectlyA(Identifier* identifier) |
---|
| 74 | { |
---|
| 75 | return (identifier == this); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | bool Identifier::isChildOf(Identifier* identifier) |
---|
| 79 | { |
---|
[219] | 80 | return this->allParents_.isInList(identifier); |
---|
[197] | 81 | } |
---|
| 82 | |
---|
| 83 | bool Identifier::isDirectChildOf(Identifier* identifier) |
---|
| 84 | { |
---|
[219] | 85 | return this->directParents_.isInList(identifier); |
---|
[197] | 86 | } |
---|
| 87 | |
---|
| 88 | bool Identifier::isParentOf(Identifier* identifier) |
---|
| 89 | { |
---|
[219] | 90 | return this->allChildren_.isInList(identifier); |
---|
[197] | 91 | } |
---|
| 92 | |
---|
| 93 | bool Identifier::isDirectParentOf(Identifier* identifier) |
---|
| 94 | { |
---|
[219] | 95 | return this->directChildren_.isInList(identifier); |
---|
[197] | 96 | } |
---|
| 97 | } |
---|