Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 6, 2007, 1:40:00 AM (16 years ago)
Author:
landauf
Message:

some features work perfectly,
some features are fucked up,
some features arent yet implemented.

x3n→hair→brightness++;

theres still a lot to do, but i can see the light on the end of the tunnel.
templates, makros, operator overloading, function pointers… the beauty of the beast. i'm in love and still dying piece by piece with every line of code i'm writing.
</film noir>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchie/src/ClassHierarchy.h

    r162 r172  
    44#include <string>
    55#include <iostream>
    6 
    7 // DONE:
     6#include <assert.h>
     7
     8// DONE AND TESTED:
    89// - klassenhierarchie aufbauen
     10// - isA u.a. vergleiche
    911// - in listen einfügen
     12
     13// IN WORK:
    1014// - factory
    1115// - klassen-identifier
    12 // - isA u.ä. vergleiche
    13 
    14 // TODO:
     16
     17// TO DO:
    1518// - durch listen iterieren
    1619// - searchtree für classname-strings
     
    2023{
    2124    // ##### ClassHierarchy #####
     25    template <class T>
     26    class ClassIdentifier;
     27
    2228    class ClassHierarchy
    2329    {
     30        template <class T>
     31        friend class ClassIdentifier;
     32
    2433        public:
    2534            static ClassHierarchy* getSingleton();
    26             bool isCreatingHierarchy() { return this->bCreatingHierarchy_; }
    27             void createHierarchy(bool bCreatingHierarchy) { this->bCreatingHierarchy_ = bCreatingHierarchy; std::cout << "*** Switched Hierarchy-Creating-Mode to" << bCreatingHierarchy << "\n"; }
     35            bool isCreatingHierarchy() { return (this->hierarchyCreatingCounter_ > 0); }
    2836
    2937        private:
    3038            ClassHierarchy();
     39            ~ClassHierarchy();
     40            void startCreatingHierarchy() { this->hierarchyCreatingCounter_++; std::cout << "*** Increased Hierarchy-Creating-Counter to " << this->hierarchyCreatingCounter_ << "\n"; }
     41            void stopCreatingHierarchy() { this->hierarchyCreatingCounter_--; std::cout << "*** Decreased Hierarchy-Creating-Counter to " << this->hierarchyCreatingCounter_ << "\n"; }
    3142
    3243            static ClassHierarchy* pointer_;
    33             bool bCreatingHierarchy_;
     44            int hierarchyCreatingCounter_;
    3445    };
    3546
     
    3849    class ObjectList;
    3950    class OrxonoxClass;
    40     template <class T>
    41     class ClassIdentifier;
    4251
    4352    class Identifier
     
    4655        friend class ClassIdentifier;
    4756
    48         public:
     57        template <class T>
     58        friend class BaseIdentifier;
     59
     60        public:
     61            Identifier(Identifier* identifier) {};
     62            ~Identifier();
    4963            void addObject(OrxonoxClass* object);
    5064            void removeObject(OrxonoxClass* object);
    5165
    5266            bool isA(Identifier* identifier);
    53             bool isDirectA(Identifier* identifier);
     67            bool isDirectlyA(Identifier* identifier);
    5468            bool isChildOf(Identifier* identifier);
    5569            bool isDirectChildOf(Identifier* identifier);
     
    5771            bool isDirectParentOf(Identifier* identifier);
    5872
     73            std::string getName() { return this->name_; }
     74            IdentifierList* getDirectParents() { return this->directParents_; }
     75            IdentifierList* getAllParents() { return this->allParents_; }
     76            IdentifierList* getDirectChildren() { return this->directChildren_; }
     77            IdentifierList* getAllChildren() { return this->allChildren_; }
     78
    5979        private:
    6080            Identifier();
     
    7292    };
    7393
     94
     95    // ##### ClassIdentifier #####
     96    class A1;
     97
    7498    template <class T>
    7599    class ClassIdentifier : public Identifier
     
    82106        private:
    83107            ClassIdentifier();
     108            ~ClassIdentifier();
    84109
    85110            static ClassIdentifier<T>* pointer_;
     
    93118    ClassIdentifier<T>::ClassIdentifier()
    94119    {
     120    }
     121
     122    template <class T>
     123    ClassIdentifier<T>::~ClassIdentifier()
     124    {
     125        this->pointer_ = NULL;
    95126    }
    96127
     
    120151    ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
    121152    {
    122         std::cout << "*** Get Identifier.\n";
     153//        std::cout << "*** Get Identifier.\n";
    123154        if (!pointer_)
    124155        {
    125156            std::cout << "*** Get Identifier -> Create Class\n";
    126             ClassHierarchy::getSingleton()->createHierarchy(true);
     157            ClassHierarchy::getSingleton()->startCreatingHierarchy();
    127158            T* temp = new T();
    128             ClassHierarchy::getSingleton()->createHierarchy(false);
     159            ClassHierarchy::getSingleton()->stopCreatingHierarchy();
    129160            delete temp;
    130161        }
     
    138169        return new T();
    139170    }
     171
    140172
    141173    // ##### Identifier List #####
     
    150182            void remove(Identifier* identifier);
    151183            bool isInList(Identifier* identifier);
     184            std::string toString();
    152185
    153186            IdentifierListElement* first_;
     
    158191        public:
    159192            IdentifierListElement(Identifier* identifier);
     193            ~IdentifierListElement();
    160194
    161195            Identifier* identifier_;
     
    183217        public:
    184218            ObjectListElement(OrxonoxClass* object);
     219            ~ObjectListElement();
    185220
    186221            OrxonoxClass* object_;
Note: See TracChangeset for help on using the changeset viewer.