FastUIDraw
Public Member Functions | List of all members
fastuidraw::reference_counted_ptr< T > Class Template Reference

A wrapper over a pointer to implement reference counting. More...

#include <reference_counted.hpp>

Public Member Functions

 reference_counted_ptr (void)
 
 reference_counted_ptr (T *p)
 
 reference_counted_ptr (const reference_counted_ptr &obj)
 
template<typename U >
 reference_counted_ptr (const reference_counted_ptr< U > &obj)
 
 reference_counted_ptr (reference_counted_ptr &&obj)
 
 ~reference_counted_ptr ()
 
void clear (void)
 
template<typename U >
reference_counted_ptr< U > const_cast_ptr (void) const
 
template<typename U >
reference_counted_ptr< U > dynamic_cast_ptr (void) const
 
T * get (void) const
 
 operator unspecified_bool_type () const
 
template<typename U >
bool operator!= (U *rhs) const
 
template<typename U >
bool operator!= (const reference_counted_ptr< U > &rhs) const
 
T & operator* (void) const
 
T * operator-> (void) const
 
bool operator< (const reference_counted_ptr &rhs) const
 
reference_counted_ptroperator= (const reference_counted_ptr &rhs)
 
reference_counted_ptroperator= (T *rhs)
 
reference_counted_ptroperator= (reference_counted_ptr &&rhs)
 
template<typename U >
reference_counted_ptroperator= (const reference_counted_ptr< U > &rhs)
 
template<typename U >
bool operator== (U *rhs) const
 
template<typename U >
bool operator== (const reference_counted_ptr< U > &rhs) const
 
template<typename U >
reference_counted_ptr< U > static_cast_ptr (void) const
 
void swap (reference_counted_ptr &rhs)
 

Detailed Description

template<typename T>
class fastuidraw::reference_counted_ptr< T >

A wrapper over a pointer to implement reference counting.

The class T must implement the static methods

where T::add_reference() increment the reference count and T::remove_reference() decrements the reference count and will delete the object.

See also reference_counted_base and reference_counted.

Definition at line 54 of file reference_counted.hpp.

Constructor & Destructor Documentation

◆ reference_counted_ptr() [1/5]

template<typename T>
fastuidraw::reference_counted_ptr< T >::reference_counted_ptr ( void  )
inline

Ctor, inits the reference_counted_ptr as equivalent to nullptr.

Definition at line 68 of file reference_counted.hpp.

◆ reference_counted_ptr() [2/5]

template<typename T>
fastuidraw::reference_counted_ptr< T >::reference_counted_ptr ( T *  p)
inline

Ctor, initialize from a T*. If passed non-nullptr, then the reference counter is incremented (via T::add_reference()).

Parameters
ppointer value from which to initialize

Definition at line 78 of file reference_counted.hpp.

◆ reference_counted_ptr() [3/5]

template<typename T>
fastuidraw::reference_counted_ptr< T >::reference_counted_ptr ( const reference_counted_ptr< T > &  obj)
inline

Copy ctor.

Parameters
objvalue from which to initialize

Definition at line 91 of file reference_counted.hpp.

◆ reference_counted_ptr() [4/5]

template<typename T>
template<typename U >
fastuidraw::reference_counted_ptr< T >::reference_counted_ptr ( const reference_counted_ptr< U > &  obj)
inline

Ctor from a reference_counted_ptr<U> where U* is implicitely convertible to a T*.

Template Parameters
Utype where U* is implicitely convertible to a T*.
Parameters
objvalue from which to initialize

Definition at line 107 of file reference_counted.hpp.

◆ reference_counted_ptr() [5/5]

template<typename T>
fastuidraw::reference_counted_ptr< T >::reference_counted_ptr ( reference_counted_ptr< T > &&  obj)
inline

Move ctor.

Parameters
objobject from which to take.

Definition at line 120 of file reference_counted.hpp.

◆ ~reference_counted_ptr()

template<typename T>
fastuidraw::reference_counted_ptr< T >::~reference_counted_ptr ( )
inline

Dtor, if pointer is non-nullptr, then reference is decremented (via T::remove_reference()).

Definition at line 130 of file reference_counted.hpp.

Member Function Documentation

◆ clear()

template<typename T>
void fastuidraw::reference_counted_ptr< T >::clear ( void  )
inline

Clears the reference_counted_ptr object, equivalent to

Definition at line 326 of file reference_counted.hpp.

◆ const_cast_ptr()

template<typename T>
template<typename U >
reference_counted_ptr<U> fastuidraw::reference_counted_ptr< T >::const_cast_ptr ( void  ) const
inline

Perform const cast to cast (uses const_cast internally).

Template Parameters
Utype to which to cast

Definition at line 351 of file reference_counted.hpp.

◆ dynamic_cast_ptr()

template<typename T>
template<typename U >
reference_counted_ptr<U> fastuidraw::reference_counted_ptr< T >::dynamic_cast_ptr ( void  ) const
inline

Perform dynamic cast to down cast (uses dynamic_cast internally).

Template Parameters
Utype to which to cast

Definition at line 362 of file reference_counted.hpp.

◆ get()

template<typename T>
T* fastuidraw::reference_counted_ptr< T >::get ( void  ) const
inline

Returns the underlying pointer

Definition at line 197 of file reference_counted.hpp.

◆ operator unspecified_bool_type()

template<typename T>
fastuidraw::reference_counted_ptr< T >::operator unspecified_bool_type ( ) const
inline

Allows one to legally write:

reference_counted_ptr<T> p;
if (p)
{
// i.e. p.get() is not nullptr
}
if (!p)
{
// i.e. p.get() is nullptr
}

Definition at line 254 of file reference_counted.hpp.

◆ operator!=() [1/2]

template<typename T>
template<typename U >
bool fastuidraw::reference_counted_ptr< T >::operator!= ( U *  rhs) const
inline

Inequality comparison operator to a pointer value.

Template Parameters
Utype where U* is implicitely comparable to a T*.
Parameters
rhsvalue with which to compare against

Definition at line 290 of file reference_counted.hpp.

◆ operator!=() [2/2]

template<typename T>
template<typename U >
bool fastuidraw::reference_counted_ptr< T >::operator!= ( const reference_counted_ptr< U > &  rhs) const
inline

Inequality comparison operator to a reference_counted_ptr value.

Template Parameters
Utype where U* is implicitely comparable to a T*.
Parameters
rhsvalue with which to compare against

Definition at line 303 of file reference_counted.hpp.

◆ operator*()

template<typename T>
T& fastuidraw::reference_counted_ptr< T >::operator* ( void  ) const
inline

Overload of dererefence operator. Under debug build, assers if pointer is nullptr.

Definition at line 207 of file reference_counted.hpp.

◆ operator->()

template<typename T>
T* fastuidraw::reference_counted_ptr< T >::operator-> ( void  ) const
inline

Overload of operator. Under debug build, assers if pointer is nullptr.

Definition at line 218 of file reference_counted.hpp.

◆ operator<()

template<typename T>
bool fastuidraw::reference_counted_ptr< T >::operator< ( const reference_counted_ptr< T > &  rhs) const
inline

Comparison operator for sorting.

Parameters
rhsvalue with which to compare against

Definition at line 313 of file reference_counted.hpp.

◆ operator=() [1/4]

template<typename T>
reference_counted_ptr& fastuidraw::reference_counted_ptr< T >::operator= ( const reference_counted_ptr< T > &  rhs)
inline

Assignment operator

Parameters
rhsvalue from which to assign

Definition at line 143 of file reference_counted.hpp.

◆ operator=() [2/4]

template<typename T>
reference_counted_ptr& fastuidraw::reference_counted_ptr< T >::operator= ( T *  rhs)
inline

Assignment operator from a T*.

Parameters
rhsvalue from which to assign

Definition at line 155 of file reference_counted.hpp.

◆ operator=() [3/4]

template<typename T>
reference_counted_ptr& fastuidraw::reference_counted_ptr< T >::operator= ( reference_counted_ptr< T > &&  rhs)
inline

Move assignment operator

Parameters
rhsvalue from which to assign

Definition at line 167 of file reference_counted.hpp.

◆ operator=() [4/4]

template<typename T>
template<typename U >
reference_counted_ptr& fastuidraw::reference_counted_ptr< T >::operator= ( const reference_counted_ptr< U > &  rhs)
inline

Assignment operator from a reference_counted_ptr<U> where U* is implicitely convertible to a T*.

Template Parameters
Utype where U* is implicitely convertible to a T*.
Parameters
rhsvalue from which to assign

Definition at line 186 of file reference_counted.hpp.

◆ operator==() [1/2]

template<typename T>
template<typename U >
bool fastuidraw::reference_counted_ptr< T >::operator== ( U *  rhs) const
inline

Equality comparison operator to a pointer value.

Parameters
rhsvalue with which to compare against

Definition at line 265 of file reference_counted.hpp.

◆ operator==() [2/2]

template<typename T>
template<typename U >
bool fastuidraw::reference_counted_ptr< T >::operator== ( const reference_counted_ptr< U > &  rhs) const
inline

Equality comparison operator to a reference_counted_ptr value.

Template Parameters
Utype where U* is implicitely comparable to a T*.
Parameters
rhsvalue with which to compare against

Definition at line 278 of file reference_counted.hpp.

◆ static_cast_ptr()

template<typename T>
template<typename U >
reference_counted_ptr<U> fastuidraw::reference_counted_ptr< T >::static_cast_ptr ( void  ) const
inline

Perform static cast to down cast (uses static_cast internally).

Template Parameters
Utype to which to cast

Definition at line 340 of file reference_counted.hpp.

◆ swap()

template<typename T>
void fastuidraw::reference_counted_ptr< T >::swap ( reference_counted_ptr< T > &  rhs)
inline

Performs swap without needing to increment or decrement the reference counter.

Parameters
rhsobject with which to swap

Definition at line 230 of file reference_counted.hpp.


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