Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 24, 2013, 6:34:23 PM (11 years ago)
Author:
landauf
Message:

moved functions and attributes needed to identify the class from OrxonoxClass to Identifiable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core6/src/libraries/core/class/OrxonoxClass.h

    r9563 r9565  
    3636    @ingroup Class OrxonoxClass
    3737    @brief Declaration of OrxonoxClass, the base class of all objects and interfaces in Orxonox.
    38 
    39     All objects and interfaces of the game-logic (not the engine) are derived from OrxonoxClass.
    40     It stores the Identifier and the MetaObjectList and has all needed functions to create and use the class-hierarchy.
    4138*/
    4239
     
    4744
    4845#include <set>
    49 #include <vector>
    50 #include "Super.h"
     46//#include "Super.h"
     47#include "Identifiable.h"
    5148
    5249namespace orxonox
     
    5653
    5754        The BaseObject and Interfaces are derived with @c virtual @c public @c OrxonoxClass from OrxonoxClass.
    58         OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the
    59         MetaObjectList, as well as to provide an interface for SmartPtr and WeakPtr.
    6055    */
    61     class _CoreExport OrxonoxClass
     56    class _CoreExport OrxonoxClass : public Identifiable
    6257    {
    63         template <class T>
    64         friend class ClassIdentifier;
    65 
    6658        template <class T>
    6759        friend class SmartPtr;
     
    7466
    7567            void destroy();
    76             void unregisterObject();
    7768
    7869            /// Function to collect the SetConfigValue-macro calls.
    7970            void setConfigValues() {};
    8071
    81             /// Returns the Identifier of the object.
    82             inline Identifier* getIdentifier() const { return this->identifier_; }
    83 
    84             bool isA(const Identifier* identifier);
    85             bool isExactlyA(const Identifier* identifier);
    86             bool isChildOf(const Identifier* identifier);
    87             bool isDirectChildOf(const Identifier* identifier);
    88             bool isParentOf(const Identifier* identifier);
    89             bool isDirectParentOf(const Identifier* identifier);
    90 
    91             /// Returns true if the object's class is of the given type or a derivative.
    92             template <class B> inline bool isA(const SubclassIdentifier<B>* identifier)
    93                 { return this->isA(*identifier); }
    94             /// Returns true if the object's class is exactly of the given type.
    95             template <class B> inline bool isExactlyA(const SubclassIdentifier<B>* identifier)
    96                 { return this->isExactlyA(*identifier); }
    97             /// Returns true if the object's class is a child of the given type.
    98             template <class B> inline bool isChildOf(const SubclassIdentifier<B>* identifier)
    99                 { return this->isChildOf(*identifier); }
    100             /// Returns true if the object's class is a direct child of the given type.
    101             template <class B> inline bool isDirectChildOf(const SubclassIdentifier<B>* identifier)
    102                 { return this->isDirectChildOf(*identifier); }
    103             /// Returns true if the object's class is a parent of the given type.
    104             template <class B> inline bool isParentOf(const SubclassIdentifier<B>* identifier)
    105                 { return this->isParentOf(*identifier); }
    106             /// Returns true if the object's class is a direct parent of the given type.
    107             template <class B> inline bool isDirectParentOf(const SubclassIdentifier<B>* identifier)
    108                 { return this->isDirectParentOf(*identifier); }
    109 
    110             bool isA(const OrxonoxClass* object);
    111             bool isExactlyA(const OrxonoxClass* object);
    112             bool isChildOf(const OrxonoxClass* object);
    113             bool isDirectChildOf(const OrxonoxClass* object);
    114             bool isParentOf(const OrxonoxClass* object);
    115             bool isDirectParentOf(const OrxonoxClass* object);
    116 
    11772            /// Returns the number of @ref orxonox::SmartPtr "smart pointers" that point to this object.
    11873            inline unsigned int getReferenceCount() const
    11974                { return this->referenceCount_; }
    120 
    121             /**
    122             @brief
    123                 Returns a valid pointer of any derived type that is
    124                 registered in the class hierarchy.
    125             @return
    126                 Returns NULL if the no pointer was found.
    127             */
    128             ORX_FORCEINLINE void* getDerivedPointer(unsigned int classID)
    129             {
    130                 for (int i = this->objectPointers_.size() - 1; i >= 0; --i)
    131                 {
    132                     if (this->objectPointers_[i].first == classID)
    133                         return this->objectPointers_[i].second;
    134                 }
    135                 return NULL;
    136             }
    137 
    138             /// Version of getDerivedPointer with template
    139             template <class T> ORX_FORCEINLINE T* getDerivedPointer(unsigned int classID)
    140             {   return static_cast<T*>(this->getDerivedPointer(classID));   }
    141             /// Const version of getDerivedPointer with template
    142             template <class T> ORX_FORCEINLINE const T* getDerivedPointer(unsigned int classID) const
    143             {   return const_cast<OrxonoxClass*>(this)->getDerivedPointer<T>(classID);   }
    14475
    14576        protected:
     
    16697                { this->destructionListeners_.erase(pointer); }
    16798
    168             Identifier* identifier_;                                //!< The Identifier of the object
    169             std::set<const Identifier*>* parents_;                  //!< List of all parents of the object
    170             MetaObjectList* metaList_;                              //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
    17199            int referenceCount_;                                    //!< Counts the references from smart pointers to this object
    172100            bool requestedDestruction_;                             //!< Becomes true after someone called delete on this object
    173101            std::set<DestructionListener*> destructionListeners_;   //!< All destruction listeners (for example weak pointers which point to this object and like to get notified if it dies)
    174 
    175             /// 'Fast map' that holds this-pointers of all derived types
    176             std::vector<std::pair<unsigned int, void*> > objectPointers_;
    177102    };
    178103
Note: See TracChangeset for help on using the changeset viewer.