Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 366


Ignore:
Timestamp:
Dec 2, 2007, 2:07:01 AM (16 years ago)
Author:
landauf
Message:

moved common object-functions and -variables (like isA() and name_) from BaseObject to OrxonoxClass, so they can still be used while iterating through a list of objects inheriting from an interface.

Location:
code/branches/objecthierarchy/src/orxonox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/core/OrxonoxClass.cc

    r365 r366  
    88namespace orxonox
    99{
    10     /** @brief Constructor: Sets identifier_ and parents_ to zero. */
     10    /** @brief Constructor: Sets the default values. */
    1111    OrxonoxClass::OrxonoxClass()
    1212    {
    1313        this->identifier_ = 0;
    1414        this->parents_ = 0;
     15
     16        this->bActive_ = true;
     17        this->bVisible_ = true;
    1518    }
    1619
  • code/branches/objecthierarchy/src/orxonox/core/OrxonoxClass.h

    r365 r366  
    4343            inline MetaObjectList& getMetaList() { return this->metaList_; }
    4444
     45            inline bool isA(const Identifier* identifier)
     46                { return this->getIdentifier()->isA(identifier); }
     47            inline bool isDirectlyA(const Identifier* identifier)
     48                { return this->getIdentifier()->isDirectlyA(identifier); }
     49            inline bool isChildOf(const Identifier* identifier)
     50                { return this->getIdentifier()->isChildOf(identifier); }
     51            inline bool isParentOf(const Identifier* identifier)
     52                { return this->getIdentifier()->isParentOf(identifier); }
     53
     54            inline bool isA(const SubclassIdentifier<class B>* identifier)
     55                { return this->getIdentifier()->isA(identifier->getIdentifier()); }
     56            inline bool isDirectlyA(const SubclassIdentifier<class B>* identifier)
     57                { return this->getIdentifier()->isDirectlyA(identifier->getIdentifier()); }
     58            inline bool isChildOf(const SubclassIdentifier<class B>* identifier)
     59                { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
     60            inline bool isParentOf(const SubclassIdentifier<class B>* identifier)
     61                { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
     62
     63            inline bool isA(const SubclassIdentifier<class B> identifier)
     64                { return this->getIdentifier()->isA(identifier.getIdentifier()); }
     65            inline bool isDirectlyA(const SubclassIdentifier<class B> identifier)
     66                { return this->getIdentifier()->isDirectlyA(identifier.getIdentifier()); }
     67            inline bool isChildOf(const SubclassIdentifier<class B> identifier)
     68                { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
     69            inline bool isParentOf(const SubclassIdentifier<class B> identifier)
     70                { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
     71
     72            inline bool isA(const OrxonoxClass* object)
     73                { return this->getIdentifier()->isA(object->getIdentifier()); }
     74            inline bool isDirectlyA(const OrxonoxClass* object)
     75                { return this->getIdentifier()->isDirectlyA(object->getIdentifier()); }
     76            inline bool isChildOf(const OrxonoxClass* object)
     77                { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
     78            inline bool isParentOf(const OrxonoxClass* object)
     79                { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
     80
     81
     82            inline void setName(const std::string& name) { this->name_ = name; }
     83            inline const std::string& getName() const { return this->name_; }
     84
     85            inline void setActive(bool bActive) { this->bActive_ = bActive; }
     86            inline const bool isActive() const { return this->bActive_; }
     87
     88            inline void setVisible(bool bVisible) { this->bVisible_ = bVisible; }
     89            inline const bool isVisible() const { return this->bVisible_; }
     90
    4591        private:
    4692            Identifier* identifier_;        //!< The Identifier of the object
    4793            IdentifierList* parents_;       //!< List of all parents of the object
    4894            MetaObjectList metaList_;       //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
     95
     96            std::string name_;
     97            bool bActive_;
     98            bool bVisible_;
    4999    };
    50100}
  • code/branches/objecthierarchy/src/orxonox/objects/BaseObject.h

    r258 r366  
    1111            BaseObject();
    1212            virtual ~BaseObject();
    13 
    14             inline bool isA(const Identifier* identifier)
    15                 { this->getIdentifier()->isA(identifier); }
    16             inline bool isDirectlyA(const Identifier* identifier)
    17                 { this->getIdentifier()->isDirectlyA(identifier); }
    18             inline bool isChildOf(const Identifier* identifier)
    19                 { this->getIdentifier()->isChildOf(identifier); }
    20             inline bool isParentOf(const Identifier* identifier)
    21                 { this->getIdentifier()->isParentOf(identifier); }
    22 
    23             inline bool isA(const SubclassIdentifier<class B>* identifier)
    24                 { this->getIdentifier()->isA(identifier->getIdentifier()); }
    25             inline bool isDirectlyA(const SubclassIdentifier<class B>* identifier)
    26                 { this->getIdentifier()->isDirectlyA(identifier->getIdentifier()); }
    27             inline bool isChildOf(const SubclassIdentifier<class B>* identifier)
    28                 { this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
    29             inline bool isParentOf(const SubclassIdentifier<class B>* identifier)
    30                 { this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
    31 
    32             inline bool isA(const SubclassIdentifier<class B> identifier)
    33                 { this->getIdentifier()->isA(identifier.getIdentifier()); }
    34             inline bool isDirectlyA(const SubclassIdentifier<class B> identifier)
    35                 { this->getIdentifier()->isDirectlyA(identifier.getIdentifier()); }
    36             inline bool isChildOf(const SubclassIdentifier<class B> identifier)
    37                 { this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
    38             inline bool isParentOf(const SubclassIdentifier<class B> identifier)
    39                 { this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
    40 
    41             inline bool isA(const OrxonoxClass* object)
    42                 { this->getIdentifier()->isA(object->getIdentifier()); }
    43             inline bool isDirectlyA(const OrxonoxClass* object)
    44                 { this->getIdentifier()->isDirectlyA(object->getIdentifier()); }
    45             inline bool isChildOf(const OrxonoxClass* object)
    46                 { this->getIdentifier()->isChildOf(object->getIdentifier()); }
    47             inline bool isParentOf(const OrxonoxClass* object)
    48                 { this->getIdentifier()->isParentOf(object->getIdentifier()); }
    49 
    50             std::string name_; // test
    51 
    5213    };
    5314}
  • code/branches/objecthierarchy/src/orxonox/orxonox.cc

    r362 r366  
    474474        delete test9_06;
    475475*/
    476 /*
     476
    477477        std::cout << "Test 10\n";
    478478        Identifier* test10_01 = Class(A1B2);
     
    509509        {
    510510            test10_08 = ID("A2B1C1")->fabricate();
    511             test10_08->name_ = "A2B1C1#";
    512             test10_08->name_ += ('0' + i);
     511            std::string objName = "A2B1C1#";
     512            objName += '0' + i;
     513            test10_08->setName(objName);
    513514
    514515            if (i == 0)
     
    531532
    532533        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
    533             std::cout << "Name: " << it->name_ << "\n";
     534            std::cout << "Name: " << it->getName() << "\n";
    534535
    535536        std::cout << "3\n";
    536537        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
    537             std::cout << "Name: " << it->name_ << "\n";
     538            std::cout << "Name: " << it->getName() << "\n";
    538539
    539540        std::cout << "4\n";
     
    553554        std::cout << "5\n";
    554555        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
    555             std::cout << "Name: " << it->name_ << "\n";
     556            std::cout << "Name: " << it->getName() << "\n";
    556557
    557558        std::cout << "6\n";
    558559        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
    559             std::cout << "Name: " << it->name_ << "\n";
     560            std::cout << "Name: " << it->getName() << "\n";
    560561
    561562        std::cout << "7\n";
     
    575576        std::cout << "8\n";
    576577        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
    577             std::cout << "Name: " << it->name_ << "\n";
     578            std::cout << "Name: " << it->getName() << "\n";
    578579
    579580        std::cout << "9\n";
    580581        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
    581             std::cout << "Name: " << it->name_ << "\n";
     582            std::cout << "Name: " << it->getName() << "\n";
    582583
    583584        std::cout << "10\n";
     
    597598        std::cout << "11\n";
    598599        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::start(); it; ++it)
    599             std::cout << "Name: " << it->name_ << "\n";
     600            std::cout << "Name: " << it->getName() << "\n";
    600601
    601602        std::cout << "12\n";
    602603        for (Iterator<A2B1C1> it = ObjectList<A2B1C1>::end(); it; --it)
    603             std::cout << "Name: " << it->name_ << "\n";
     604            std::cout << "Name: " << it->getName() << "\n";
    604605
    605606        std::cout << "13\n";
    606 */
     607
    607608      }
    608609
Note: See TracChangeset for help on using the changeset viewer.