MyGUI_RTTI.h File Reference

#include "MyGUI_Prerequest.h"
#include "MyGUI_Common.h"
#include <typeinfo>

Go to the source code of this file.

Namespaces

namespace  MyGUI

Defines

#define MYGUI_DECLARE_TYPE_NAME(Type)
#define MYGUI_RTTI_BASE(BaseType)
#define MYGUI_RTTI_DERIVED(DerivedType)
#define MYGUI_RTTI_CHILD_HEADER(DerivedType, BaseType)
#define MYGUI_RTTI_BASE_HEADER(BaseType)   MYGUI_RTTI_BASE( BaseType )

Detailed Description

Author:
Alexander Buryak - Rageous
Albert Semenov
Date:
09/2008

Definition in file MyGUI_RTTI.h.


Define Documentation

#define MYGUI_DECLARE_TYPE_NAME ( Type   ) 
Value:
public: \
            static const std::string& getClassTypeName() { static std::string type = #Type; return type; } \
             \
            virtual const std::string& getTypeName() const { return Type::getClassTypeName(); }

Definition at line 44 of file MyGUI_RTTI.h.

#define MYGUI_RTTI_BASE ( BaseType   ) 
Value:
public: \
            typedef BaseType RTTIBase; \
            MYGUI_DECLARE_TYPE_NAME( BaseType ) \
             \
            virtual bool isType( const std::type_info& _type) const { return typeid( BaseType ) == _type; } \
             \
            template<typename Type> bool isType() const { return isType( typeid( Type )); } \
             \
            template<typename Type> Type* castType(bool _throw = true) \
            { \
                if (this->isType<Type>()) return static_cast<Type*>( this ); \
                MYGUI_ASSERT(!_throw, "Error cast type '" << this->getTypeName() << "' to type '" << Type::getClassTypeName() << "' .") \
                return nullptr; \
            } \
             \
            template<typename Type> const Type* castType(bool _throw = true) const \
            { \
                if (this->isType<Type>()) return static_cast<Type*>( this ); \
                MYGUI_ASSERT(!_throw, "Error cast type '" << this->getTypeName() << "' to type '" << Type::getClassTypeName() << "' .") \
                return nullptr; \
            }

Get type name as string

Definition at line 51 of file MyGUI_RTTI.h.

#define MYGUI_RTTI_BASE_HEADER ( BaseType   )     MYGUI_RTTI_BASE( BaseType )

Compare with selected type

Definition at line 99 of file MyGUI_RTTI.h.

#define MYGUI_RTTI_CHILD_HEADER ( DerivedType,
BaseType   ) 
Value:
public: \
            MYGUI_DECLARE_TYPE_NAME( DerivedType ) \
            typedef BaseType Base; \
            typedef DerivedType RTTIBase; \
             \
            virtual bool isType( const std::type_info& _type ) const { return typeid( DerivedType ) == _type || BaseType::isType( _type ); }

Compare with selected type Compare with selected type

Definition at line 89 of file MyGUI_RTTI.h.

#define MYGUI_RTTI_DERIVED ( DerivedType   ) 
Value:
public: \
            MYGUI_DECLARE_TYPE_NAME( DerivedType ) \
            typedef RTTIBase Base; \
            typedef DerivedType RTTIBase; \
             \
            virtual bool isType( const std::type_info& _type ) const { return typeid( DerivedType ) == _type || Base::isType( _type ); } \
             \
            template<typename Type> bool isType() const { return isType( typeid( DerivedType )); }

Compare with selected type Compare with selected type Try to cast pointer to selected type. \

Parameters:
_throw If true throw exception when casting in wrong type, else return nullptr \ Try to cast pointer to selected type. \
_throw If true throw exception when casting in wrong type, else return nullptr \

Definition at line 78 of file MyGUI_RTTI.h.


Generated on 3 Dec 2009 for MyGUI by  doxygen 1.6.1