- Timestamp:
- Dec 1, 2007, 4:24:56 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/core/Identifier.cc
r362 r365 1 /*! 2 @file Identifier.cc 3 @brief Implementation of the Identifier class. 4 */ 5 1 6 #include "Identifier.h" 2 7 … … 6 11 // ### Identifier ### 7 12 // ############################### 8 int Identifier::hierarchyCreatingCounter_s = 0; 9 unsigned int Identifier::classIDcounter_s = 0; 13 int Identifier::hierarchyCreatingCounter_s = 0; // Set the static member variable hierarchyCreatingCounter_s to zero 14 unsigned int Identifier::classIDcounter_s = 0; // Set the static member variable classIDcounter_s to zero 10 15 16 /** 17 @brief Constructor: No factory, no object created, new ObjectList and a unique networkID. 18 */ 11 19 Identifier::Identifier() 12 20 { … … 18 26 } 19 27 28 /** 29 @brief Destructor: Deletes the name and the IdentifierList containing the children. 30 */ 20 31 Identifier::~Identifier() 21 32 { 22 33 delete &this->name_; 23 24 34 delete this->children_; 25 35 } 26 36 37 /** 38 @brief Initializes the Identifier with an IdentifierList containing all parents of the class the Identifier belongs to. 39 @param parents The IdentifierList containing all parents 40 */ 27 41 void Identifier::initialize(const IdentifierList* parents) 28 42 { … … 38 52 { 39 53 this->parents_.add(temp1->identifier_); 40 temp1->identifier_->getChildren().add(this); 54 temp1->identifier_->getChildren().add(this); // We're a child of our parents 41 55 42 56 temp1 = temp1->next_; … … 45 59 } 46 60 61 /** 62 @brief Creates an object of the type the Identifier belongs to. 63 @return The new object 64 */ 47 65 BaseObject* Identifier::fabricate() 48 66 { 49 67 if (this->factory_) 50 68 { 51 return this->factory_->fabricate(); 69 return this->factory_->fabricate(); // We have to return a BaseObject, because we don't know the exact type. 52 70 } 53 71 else 54 72 { 73 // Abstract classes don't have a factory and therefore can't create new objects 55 74 std::cout << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract.\n"; 56 75 std::cout << "Aborting..."; … … 59 78 } 60 79 80 /** 81 @brief Sets the networkID to a new value and changes the entry in the Factory. 82 @param id The new networkID 83 */ 61 84 void Identifier::setNetworkID(unsigned int id) 62 85 { … … 65 88 } 66 89 90 /** 91 @returns true, if the Identifier is at least of the given type. 92 @param identifier The identifier to compare with 93 */ 67 94 bool Identifier::isA(const Identifier* identifier) const 68 95 { … … 70 97 } 71 98 99 /** 100 @returns true, if the Identifier is exactly of the given type. 101 @param identifier The identifier to compare with 102 */ 72 103 bool Identifier::isDirectlyA(const Identifier* identifier) const 73 104 { … … 75 106 } 76 107 108 /** 109 @returns true, if the assigned identifier is a child of the given identifier. 110 @param identifier The identifier to compare with 111 */ 77 112 bool Identifier::isChildOf(const Identifier* identifier) const 78 113 { … … 80 115 } 81 116 117 /** 118 @returns true, if the assigned identifier is a parent of the given identifier. 119 @param identifier The identifier to compare with 120 */ 82 121 bool Identifier::isParentOf(const Identifier* identifier) const 83 122 {
Note: See TracChangeset
for help on using the changeset viewer.