Nebula
Loading...
Searching...
No Matches
Ptr< TYPE > Class Template Reference

#include <ptr.h>

Detailed Description

template<class TYPE>
class Ptr< TYPE >

Nebula's smart pointer class which manages the life time of RefCounted objects.

Can be used like a normal C++ pointer in most cases.

NOTE: the Ptr class is not part of the Core namespace for convenience reasons.

Public Member Functions

 Ptr ()
 constructor
 
 Ptr (TYPE *p)
 construct from C++ pointer
 
 Ptr (std::nullptr_t rhs)
 constructor from nullptr
 
 Ptr (const Ptr< TYPE > &p)
 construct from smart pointer
 
 Ptr (Ptr< TYPE > &&p)
 implement move constructor
 
template<class OTHERTYPE >
 Ptr (OTHERTYPE *rhs)
 construct from C++ pointer of other type
 
template<class OTHERTYPE >
 Ptr (const Ptr< OTHERTYPE > &rhs)
 construct from smart pointer of other type
 
template<class OTHERTYPE >
 Ptr (Ptr< OTHERTYPE > &&rhs)
 construct from smart pointer of other type
 
 ~Ptr ()
 destructor
 
void operator= (TYPE *rhs)
 assignment operator
 
void operator= (const Ptr< TYPE > &rhs)
 assignment operator
 
void operator= (Ptr< TYPE > &&rhs)
 move operator
 
void operator= (std::nullptr_t rhs)
 unassignment operator
 
template<class OTHERTYPE >
void operator= (OTHERTYPE *rhs)
 assign operator to pointer of other type
 
template<class OTHERTYPE >
void operator= (const Ptr< OTHERTYPE > &rhs)
 assign operator to Ptr of other type
 
template<class OTHERTYPE >
void operator= (Ptr< OTHERTYPE > &&rhs)
 move assignment to Ptr of other type
 
bool operator== (const Ptr< TYPE > &rhs) const
 equality operator
 
bool operator!= (const Ptr< TYPE > &rhs) const
 inequality operator
 
bool operator== (const TYPE *rhs) const
 shortcut equality operator
 
bool operator!= (const TYPE *rhs) const
 shortcut inequality operator
 
TYPE * operator-> () const
 safe -> operator
 
TYPE & operator* () const
 safe dereference operator
 
 operator TYPE * () const
 safe pointer cast operator
 
template<class DERIVED >
const Ptr< DERIVED > & downcast () const
 type-safe downcast operator to other smart pointer
 
template<class BASE >
const Ptr< BASE > & upcast () const
 type-safe upcast operator to other smart pointer
 
template<class OTHERTYPE >
const Ptr< OTHERTYPE > & cast () const
 unsafe(!) cast to anything, unless classes have no inheritance-relationship, call upcast/downcast instead, they are type-safe
 
bool isvalid () const
 check if pointer is valid
 
TYPE * get () const
 return direct pointer (asserts if null pointer)
 
TYPE * get_unsafe () const
 return direct pointer (returns null pointer)
 
uint32_t HashCode () const
 calculate hash code for Util::HashTable (basically just the adress)
 

Private Attributes

TYPE * ptr
 

Friends

template<class OTHERTYPE >
class Ptr
 make other type Ptr classes friend
 

Constructor & Destructor Documentation

◆ Ptr() [1/8]

template<class TYPE >
Ptr< TYPE >::Ptr ( )

constructor

◆ Ptr() [2/8]

template<class TYPE >
Ptr< TYPE >::Ptr ( TYPE * p)

construct from C++ pointer

◆ Ptr() [3/8]

template<class TYPE >
Ptr< TYPE >::Ptr ( std::nullptr_t rhs)
inline

constructor from nullptr

◆ Ptr() [4/8]

template<class TYPE >
Ptr< TYPE >::Ptr ( const Ptr< TYPE > & p)

construct from smart pointer

◆ Ptr() [5/8]

template<class TYPE >
Ptr< TYPE >::Ptr ( Ptr< TYPE > && p)

implement move constructor

◆ Ptr() [6/8]

template<class TYPE >
template<class OTHERTYPE >
Ptr< TYPE >::Ptr ( OTHERTYPE * rhs)
inline

construct from C++ pointer of other type

◆ Ptr() [7/8]

template<class TYPE >
template<class OTHERTYPE >
Ptr< TYPE >::Ptr ( const Ptr< OTHERTYPE > & rhs)
inline

construct from smart pointer of other type

◆ Ptr() [8/8]

template<class TYPE >
template<class OTHERTYPE >
Ptr< TYPE >::Ptr ( Ptr< OTHERTYPE > && rhs)
inline

construct from smart pointer of other type

◆ ~Ptr()

template<class TYPE >
Ptr< TYPE >::~Ptr ( )

destructor

Member Function Documentation

◆ cast()

template<class TYPE >
template<class OTHERTYPE >
const Ptr< OTHERTYPE > & Ptr< TYPE >::cast ( ) const

unsafe(!) cast to anything, unless classes have no inheritance-relationship, call upcast/downcast instead, they are type-safe

◆ downcast()

template<class TYPE >
template<class DERIVED >
const Ptr< DERIVED > & Ptr< TYPE >::downcast ( ) const

type-safe downcast operator to other smart pointer

◆ get()

template<class TYPE >
TYPE * Ptr< TYPE >::get ( ) const

return direct pointer (asserts if null pointer)

◆ get_unsafe()

template<class TYPE >
TYPE * Ptr< TYPE >::get_unsafe ( ) const

return direct pointer (returns null pointer)

◆ HashCode()

template<class TYPE >
uint32_t Ptr< TYPE >::HashCode ( ) const

calculate hash code for Util::HashTable (basically just the adress)

◆ isvalid()

template<class TYPE >
bool Ptr< TYPE >::isvalid ( ) const

check if pointer is valid

◆ operator TYPE *()

template<class TYPE >
Ptr< TYPE >::operator TYPE * ( ) const

safe pointer cast operator

◆ operator!=() [1/2]

template<class TYPE >
bool Ptr< TYPE >::operator!= ( const Ptr< TYPE > & rhs) const

inequality operator

◆ operator!=() [2/2]

template<class TYPE >
bool Ptr< TYPE >::operator!= ( const TYPE * rhs) const

shortcut inequality operator

◆ operator*()

template<class TYPE >
TYPE & Ptr< TYPE >::operator* ( ) const

safe dereference operator

◆ operator->()

template<class TYPE >
TYPE * Ptr< TYPE >::operator-> ( ) const

safe -> operator

◆ operator=() [1/7]

template<class TYPE >
template<class OTHERTYPE >
void Ptr< TYPE >::operator= ( const Ptr< OTHERTYPE > & rhs)
inline

assign operator to Ptr of other type

◆ operator=() [2/7]

template<class TYPE >
void Ptr< TYPE >::operator= ( const Ptr< TYPE > & rhs)

assignment operator

◆ operator=() [3/7]

template<class TYPE >
template<class OTHERTYPE >
void Ptr< TYPE >::operator= ( OTHERTYPE * rhs)
inline

assign operator to pointer of other type

◆ operator=() [4/7]

template<class TYPE >
template<class OTHERTYPE >
void Ptr< TYPE >::operator= ( Ptr< OTHERTYPE > && rhs)
inline

move assignment to Ptr of other type

◆ operator=() [5/7]

template<class TYPE >
void Ptr< TYPE >::operator= ( Ptr< TYPE > && rhs)

move operator

◆ operator=() [6/7]

template<class TYPE >
void Ptr< TYPE >::operator= ( std::nullptr_t rhs)
inline

unassignment operator

◆ operator=() [7/7]

template<class TYPE >
void Ptr< TYPE >::operator= ( TYPE * rhs)

assignment operator

◆ operator==() [1/2]

template<class TYPE >
bool Ptr< TYPE >::operator== ( const Ptr< TYPE > & rhs) const

equality operator

◆ operator==() [2/2]

template<class TYPE >
bool Ptr< TYPE >::operator== ( const TYPE * rhs) const

shortcut equality operator

◆ upcast()

template<class TYPE >
template<class BASE >
const Ptr< BASE > & Ptr< TYPE >::upcast ( ) const

type-safe upcast operator to other smart pointer

Friends And Related Symbol Documentation

◆ Ptr

template<class TYPE >
template<class OTHERTYPE >
friend class Ptr
friend

make other type Ptr classes friend

Member Data Documentation

◆ ptr

template<class TYPE >
TYPE* Ptr< TYPE >::ptr
private

The documentation for this class was generated from the following file: