The Vish Visualization Shell 0.3
Vish
MemCore::DynPtr< Object, ObjectBase > Class Template Reference

Encapsuled pointer class for pointers pointing to derived classes. More...

#include <elementary/memcore/DynPtr.hpp>

Inheritance diagram for MemCore::DynPtr< Object, ObjectBase >:
MemCore::WeakPtr< Seagrass, Seagrass > MemCore::WeakPtr< MemCore::Creature > MemCore::WeakPtr< AnemoneCreatorBase > MemCore::WeakPtr< VRenderObject, VManagedObject > MemCore::WeakPtr< VGLRenderObject, VManagedObject > MemCore::WeakPtr< ValueNotifierList, ValueNotifierList > MemCore::WeakPtr< ValuePool, ValuePool > MemCore::WeakPtr< ValueNotifierList > MemCore::WeakPtr< VConnectable > MemCore::WeakPtr< VManagedObject, VManagedObjectBase > MemCore::WeakPtr< VObject > MemCore::WeakPtr< VCreatorBase, VManagedObjectBase > MemCore::WeakPtr< VSlotContainer, VManagedObjectBase > MemCore::WeakPtr< VManagedObjectBase, VManagedObjectBase > MemCore::WeakPtr< VValueBase, VValueBase > MemCore::WeakPtr< Cache, CacheBase > MemCore::WeakPtr< Cacheable, Cacheable > MemCore::WeakPtr< LoaderBase, LoaderBase > MemCore::ObjectBase_t< Object, ObjectBase > MemCore::object_t< Object, ObjectBase > MemCore::WeakPtr< Object, Object > MemCore::WeakPtr< Object > MemCore::WeakPtr< Object, ObjectBase >

Public Types

typedef Object object_t
 Type of the associated object.

Public Member Functions

const DynPtr & getDynPtr () const noexcept
 Convenience type cast to dynamic pointer class.
const type_info & getType () const noexcept
 Return type info of associated object, typeid(NullPtr) or typeid(void) if none.
bool isAssignable (const DynPtr< ObjectBase, ObjectBase > &Other) const noexcept
 Check whether a given pointer to a base class may be assigned to a pointer of the derived class.

Static Public Member Functions

static const DynPtr & getNullPtr () noexcept
 Associated static NullPtr - avoids creation of a temporary object when a reference is needed.

Protected Member Functions

template<class AnyObject>
 DynPtr (const DynPtr< AnyObject, ObjectBase > &Other) noexcept
 Implicit type conversion within the same class hierarchy Any pointer.
 DynPtr (const std::nullptr_t &) noexcept
 Assign from nullptr.

Validity Operators

 operator void * () const noexcept
 Check if the pointer is valid.
bool operator! () const noexcept
 Check if the pointer is invalid.
void speak (const char *s, const char *prefix="") const noexcept
 Print some debug messages to the console.
void Speak (const char *s, const char *prefix="") const
 Verbose information printing for this pointer.

Detailed Description

template<class Object, class ObjectBase>
class MemCore::DynPtr< Object, ObjectBase >

Encapsuled pointer class for pointers pointing to derived classes.

It performs a native dynamic_cast<> on assignment and construction and caches the result.

Member Function Documentation

◆ isAssignable()

template<class Object, class ObjectBase>
bool MemCore::DynPtr< Object, ObjectBase >::isAssignable ( const DynPtr< ObjectBase, ObjectBase > & Other) const
inlinenoexcept

Check whether a given pointer to a base class may be assigned to a pointer of the derived class.

This function doesn't need to create a new pointer and is thus little lighter than pointer assignment, it basically just involves a dynamic_cast.

◆ operator void *()

template<class Object, class ObjectBase>
MemCore::DynPtr< Object, ObjectBase >::operator void * ( ) const
inlinenoexcept

Check if the pointer is valid.

Note that the referred object might still exist, but not be of the appropriate type.

◆ operator!()

template<class Object, class ObjectBase>
bool MemCore::DynPtr< Object, ObjectBase >::operator! ( ) const
inlinenoexcept

Check if the pointer is invalid.

Note that the referred object might still exist, but not be of the appropriate type.