Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchie/src/Identifier.cc @ 244

Last change on this file since 244 was 244, checked in by landauf, 16 years ago

reimplementation of the factory and parts of the class-hierarchy-generating-algorithm. interfaces with protected constructors are now allowed.

File size: 1.9 KB
RevLine 
[197]1#include "Identifier.h"
2
3namespace orxonox
4{
5    // ###############################
6    // ###       Identifier        ###
7    // ###############################
[219]8    int Identifier::hierarchyCreatingCounter_s = 0;
9
[197]10    Identifier::Identifier()
11    {
12        this->bCreatedOneObject_ = false;
[244]13        this->factory_ = 0;
[239]14
[243]15        this->children_ = new IdentifierList;
[197]16    }
17
18    Identifier::~Identifier()
19    {
20        delete &this->name_;
[239]21
[243]22        delete this->children_;
[197]23    }
24
[239]25    void Identifier::initialize(const IdentifierList* parents)
[197]26    {
[231]27#if HIERARCHY_VERBOSE
[197]28        std::cout << "*** Initialize " << this->name_ << "-Singleton.\n";
[231]29#endif
[244]30        this->bCreatedOneObject_ = true;
31
[197]32        if (parents)
33        {
[243]34            IdentifierListElement* temp1 = parents->first_;
[197]35            while (temp1)
36            {
[243]37                this->parents_.add(temp1->identifier_);
38                temp1->identifier_->getChildren().add(this);
[197]39
40                temp1 = temp1->next_;
41            }
42        }
43    }
44
[244]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
[239]59    bool Identifier::isA(const Identifier* identifier) const
[197]60    {
[243]61        return (identifier == this || this->parents_.isInList(identifier));
[197]62    }
63
[239]64    bool Identifier::isDirectlyA(const Identifier* identifier) const
[197]65    {
66        return (identifier == this);
67    }
68
[239]69    bool Identifier::isChildOf(const Identifier* identifier) const
[197]70    {
[243]71        return this->parents_.isInList(identifier);
[197]72    }
73
[239]74    bool Identifier::isParentOf(const Identifier* identifier) const
[197]75    {
[243]76        return this->children_->isInList(identifier);
[197]77    }
78}
Note: See TracBrowser for help on using the repository browser.