Last change
on this file since 257 was
255,
checked in by landauf, 17 years ago
|
moved files into the new folders
|
File size:
1.9 KB
|
Line | |
---|
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 | this->factory_ = 0; |
---|
14 | |
---|
15 | this->children_ = new IdentifierList; |
---|
16 | } |
---|
17 | |
---|
18 | Identifier::~Identifier() |
---|
19 | { |
---|
20 | delete &this->name_; |
---|
21 | |
---|
22 | delete this->children_; |
---|
23 | } |
---|
24 | |
---|
25 | void Identifier::initialize(const IdentifierList* parents) |
---|
26 | { |
---|
27 | #if HIERARCHY_VERBOSE |
---|
28 | std::cout << "*** Initialize " << this->name_ << "-Singleton.\n"; |
---|
29 | #endif |
---|
30 | this->bCreatedOneObject_ = true; |
---|
31 | |
---|
32 | if (parents) |
---|
33 | { |
---|
34 | IdentifierListElement* temp1 = parents->first_; |
---|
35 | while (temp1) |
---|
36 | { |
---|
37 | this->parents_.add(temp1->identifier_); |
---|
38 | temp1->identifier_->getChildren().add(this); |
---|
39 | |
---|
40 | temp1 = temp1->next_; |
---|
41 | } |
---|
42 | } |
---|
43 | } |
---|
44 | |
---|
45 | BaseObject* Identifier::fabricate() |
---|
46 | { |
---|
47 | if (this->factory_) |
---|
48 | { |
---|
49 | return this->factory_->fabricate(); |
---|
50 | } |
---|
51 | else |
---|
52 | { |
---|
53 | std::cout << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract.\n"; |
---|
54 | std::cout << "Aborting..."; |
---|
55 | abort(); |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | bool Identifier::isA(const Identifier* identifier) const |
---|
60 | { |
---|
61 | return (identifier == this || this->parents_.isInList(identifier)); |
---|
62 | } |
---|
63 | |
---|
64 | bool Identifier::isDirectlyA(const Identifier* identifier) const |
---|
65 | { |
---|
66 | return (identifier == this); |
---|
67 | } |
---|
68 | |
---|
69 | bool Identifier::isChildOf(const Identifier* identifier) const |
---|
70 | { |
---|
71 | return this->parents_.isInList(identifier); |
---|
72 | } |
---|
73 | |
---|
74 | bool Identifier::isParentOf(const Identifier* identifier) const |
---|
75 | { |
---|
76 | return this->children_->isInList(identifier); |
---|
77 | } |
---|
78 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.