Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 19, 2009, 3:48:00 PM (15 years ago)
Author:
rgrieder
Message:

Merged orxonox_cast related revisions from core4 back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/OrxonoxClass.h

    r3280 r3325  
    5050    class _CoreExport OrxonoxClass
    5151    {
     52        template <class T>
     53        friend class ClassIdentifier;
     54
    5255        public:
    5356            OrxonoxClass();
     
    5962            /** @brief Returns the Identifier of the object. @return The Identifier */
    6063            inline Identifier* getIdentifier() const { return this->identifier_; }
    61 
    62             /** @brief Sets the Identifier of the object. Used by the RegisterObject-macro. */
    63             inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; }
    64 
    65             /** @brief Returns the list of all parents of the object. @return The list */
    66             inline std::set<const Identifier*>* getParents() const { return this->parents_; }
    67 
    68             /** @brief Creates the parents-list. */
    69             inline void createParents() { this->parents_ = new std::set<const Identifier*>(); }
    70 
    71             /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */
    72             inline MetaObjectList& getMetaList() { return (*this->metaList_); }
    73 
    7464
    7565            bool isA(const Identifier* identifier);
     
    10191            bool isDirectParentOf(const OrxonoxClass* object);
    10292
     93            /**
     94            @brief
     95                Returns a valid pointer of any derived type that is
     96                registered in the class hierarchy.
     97            @return
     98                Returns NULL if the no pointer was found.
     99            */
     100            template <class T>
     101            FORCEINLINE T* getDerivedPointer(unsigned int classID) const
     102            {
     103                for (int i = this->objectPointers_.size() - 1; i >= 0; --i)
     104                {
     105                    if (this->objectPointers_[i].first == classID)
     106                        return reinterpret_cast<T*>(this->objectPointers_[i].second);
     107                }
     108                return NULL;
     109            }
     110
    103111        private:
    104112            Identifier* identifier_;                   //!< The Identifier of the object
    105113            std::set<const Identifier*>* parents_;     //!< List of all parents of the object
    106114            MetaObjectList* metaList_;                 //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
     115            //! 'Fast map' that holds this-pointers of all derived types
     116            std::vector<std::pair<unsigned int, void*> > objectPointers_;
    107117    };
    108118}
Note: See TracChangeset for help on using the changeset viewer.