All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Radiant::IntrusivePtr< T > Class Template Reference

This class implements an intrusive pointer. More...

#include <Radiant/IntrusivePtr.hpp>

Inheritance diagram for Radiant::IntrusivePtr< T >:

Public Types

typedef T element_type
 Type of the object pointed to.
 

Public Member Functions

bool boolean_test () const
 Used to implemented the safe-bool idiom for intrusive pointers. More...
 
const IntrusivePtrCounter * counter () const
 
template<typename Y >
IntrusivePtr< Y > dynamic_pointer_cast () const
 Perform a dynamic_cast to another intrusive pointer type. More...
 
 IntrusivePtr ()
 Constructor for null pointer.
 
 IntrusivePtr (T *ptr)
 Construct a new intrusive pointer to the given object. More...
 
 IntrusivePtr (const IntrusivePtr< T > &iptr)
 Construct a copy of an intrusive pointer. More...
 
template<typename Y >
 IntrusivePtr (const IntrusivePtr< Y > &iptr)
 Construct a copy of an intrusive pointer. More...
 
 IntrusivePtr (IntrusivePtr< T > &&iptr)
 A move constructor for intrusive pointers. More...
 
template<typename Y >
 IntrusivePtr (IntrusivePtr< Y > &&iptr)
 A move constructor for intrusive pointers. More...
 
template<typename Y >
 IntrusivePtr (const IntrusiveWeakPtr< Y > &wptr)
 Construct an intrusive pointer from instrusive weak pointer. More...
 
bool operator! () const
 Check if the intrusive pointer is null. More...
 
template<typename Y >
bool operator!= (const IntrusivePtr< Y > &rhs) const
 Compare if two intrusive pointers are inequal. More...
 
template<typename Y >
bool operator!= (const IntrusiveWeakPtr< Y > &rhs) const
 Compare if intrusive pointer is inequal to the given intrusive weak pointer. More...
 
bool operator!= (nullptr_t) const
 Compare if the intrusive pointer is inequal to nullptr. More...
 
template<typename Y >
bool operator!= (const Y *rhs) const
 Compare if the intrusive pointer is inequal to the given raw pointer. More...
 
T & operator* () const
 Convert the intrusive pointer to raw pointer. More...
 
T * operator-> () const
 Dereference the intrusive pointer. More...
 
template<typename Y >
bool operator< (const IntrusivePtr< Y > &rhs) const
 Compare the order of two intrusive pointers. More...
 
template<typename Y >
bool operator< (const Y *rhs) const
 Compare the intrusive pointer to a raw pointer. More...
 
template<typename Y >
IntrusivePtr< T > & operator= (const IntrusivePtr< Y > &iptr)
 Assign an intrusive pointer. More...
 
IntrusivePtr< T > & operator= (const IntrusivePtr< T > &iptr)
 Assign an intrusive pointer. More...
 
IntrusivePtr< T > & operator= (IntrusivePtr< T > &&iptr)
 Move an intrusive pointer. More...
 
template<typename Y >
IntrusivePtr< T > & operator= (IntrusivePtr< Y > &&iptr)
 Move an intrusive pointer. More...
 
IntrusivePtr< T > & operator= (T *ptr)
 Assign a raw pointer to the intrusive pointer. More...
 
template<typename Y >
bool operator== (const IntrusivePtr< Y > &rhs) const
 Compare if two intrusive pointers are equal. More...
 
template<typename Y >
bool operator== (const IntrusiveWeakPtr< Y > &rhs) const
 Compare if intrusive pointer is equal to the given intrusive weak pointer. More...
 
template<typename Y >
bool operator== (const Y *rhs) const
 Compare if the intrusive pointer is equal to the given raw pointer. More...
 
bool operator== (nullptr_t) const
 Compare if the intrusive pointer is equal to nullptr. More...
 
template<typename Y >
void reset (Y *ptr)
 Reset the intrusive pointer to given object. More...
 
void reset ()
 Reset the intrusive pointer to nullptr.
 
template<typename Y >
IntrusivePtr< Y > static_pointer_cast () const
 Perform static_cast to another intrusive pointer type. More...
 
IntrusiveWeakPtr< T > weak () const
 Shortcut for creating weak pointer from this.
 
 ~IntrusivePtr ()
 Destructor.
 

Friends

template<typename Y >
class IntrusivePtr
 
template<typename Y >
class IntrusiveWeakPtr
 

Detailed Description

template<typename T>
class Radiant::IntrusivePtr< T >

This class implements an intrusive pointer.

Intrusive pointer is a light version of a shared pointer. The dynamically allocated object the pointer points to handles the reference counter. Thus the reference count is stored in a single location and the pointer size is kept to a minimum. In case of Cornerstone it also makes it possible to share objects between C++ and JavaScript.

Constructor & Destructor Documentation

template<typename T>
Radiant::IntrusivePtr< T >::IntrusivePtr ( T *  ptr)
inline

Construct a new intrusive pointer to the given object.

Parameters
ptrpointer to the object
template<typename T>
Radiant::IntrusivePtr< T >::IntrusivePtr ( const IntrusivePtr< T > &  iptr)
inline

Construct a copy of an intrusive pointer.

Parameters
iptrintrusive pointer to copy
template<typename T>
template<typename Y >
Radiant::IntrusivePtr< T >::IntrusivePtr ( const IntrusivePtr< Y > &  iptr)
inline

Construct a copy of an intrusive pointer.

Parameters
iptrintrusive pointer to copy
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
Radiant::IntrusivePtr< T >::IntrusivePtr ( IntrusivePtr< T > &&  iptr)
inline

A move constructor for intrusive pointers.

Parameters
iptrintrusive pointer to move
template<typename T>
template<typename Y >
Radiant::IntrusivePtr< T >::IntrusivePtr ( IntrusivePtr< Y > &&  iptr)
inline

A move constructor for intrusive pointers.

Parameters
iptrintrusive pointer to move
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
template<typename Y >
Radiant::IntrusivePtr< T >::IntrusivePtr ( const IntrusiveWeakPtr< Y > &  wptr)
inline

Construct an intrusive pointer from instrusive weak pointer.

Parameters
wptrweak pointer to construct from
Template Parameters
YType of the object pointed by parameter pointer

Member Function Documentation

template<typename T>
bool Radiant::IntrusivePtr< T >::boolean_test ( ) const
inline

Used to implemented the safe-bool idiom for intrusive pointers.

Returns
true if the pointer is nullptr; otherwise false
template<typename T>
const IntrusivePtrCounter* Radiant::IntrusivePtr< T >::counter ( ) const
inline
Returns
the counter object, can be null
template<typename T>
template<typename Y >
IntrusivePtr<Y> Radiant::IntrusivePtr< T >::dynamic_pointer_cast ( ) const
inline

Perform a dynamic_cast to another intrusive pointer type.

Returns
intrusive pointer to different type or to nullptr if the cast fails
Template Parameters
YType of the object pointed by pointer returned
template<typename T>
bool Radiant::IntrusivePtr< T >::operator! ( ) const
inline

Check if the intrusive pointer is null.

Returns
true if the intrusive pointer is nullptr; otherwise false
template<typename T>
template<typename Y >
bool Radiant::IntrusivePtr< T >::operator!= ( const IntrusivePtr< Y > &  rhs) const
inline

Compare if two intrusive pointers are inequal.

Parameters
rhsintrusive pointer to compare
Returns
true if the pointers are inequal; otherwise false
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
template<typename Y >
bool Radiant::IntrusivePtr< T >::operator!= ( const IntrusiveWeakPtr< Y > &  rhs) const
inline

Compare if intrusive pointer is inequal to the given intrusive weak pointer.

Parameters
rhsintrusive weak pointer to compare
Returns
true if the pointers are inequal; otherwise false
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
bool Radiant::IntrusivePtr< T >::operator!= ( nullptr_t  ) const
inline

Compare if the intrusive pointer is inequal to nullptr.

Returns
true if the intrusive pointer is nullptr
template<typename T>
template<typename Y >
bool Radiant::IntrusivePtr< T >::operator!= ( const Y *  rhs) const
inline

Compare if the intrusive pointer is inequal to the given raw pointer.

Parameters
rhsraw pointer to compare to
Returns
true if the pointers are inequal; otherwise false
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
T& Radiant::IntrusivePtr< T >::operator* ( ) const
inline

Convert the intrusive pointer to raw pointer.

Returns
raw pointer to the object
template<typename T>
T* Radiant::IntrusivePtr< T >::operator-> ( ) const
inline

Dereference the intrusive pointer.

Returns
raw pointer to the object
template<typename T>
template<typename Y >
bool Radiant::IntrusivePtr< T >::operator< ( const IntrusivePtr< Y > &  rhs) const
inline

Compare the order of two intrusive pointers.

Parameters
rhsintrusive pointer to compare
Returns
true if this intrusive pointer is less than the given intrusive pointer; otherwise false
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
template<typename Y >
bool Radiant::IntrusivePtr< T >::operator< ( const Y *  rhs) const
inline

Compare the intrusive pointer to a raw pointer.

Parameters
rhsraw pointer to compare
Returns
true if this intrusive pointer is less than the given raw pointer; otherwise false
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
template<typename Y >
IntrusivePtr<T>& Radiant::IntrusivePtr< T >::operator= ( const IntrusivePtr< Y > &  iptr)
inline

Assign an intrusive pointer.

Parameters
iptrintrusive pointer to assign
Returns
reference to this
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
IntrusivePtr<T>& Radiant::IntrusivePtr< T >::operator= ( const IntrusivePtr< T > &  iptr)
inline

Assign an intrusive pointer.

Parameters
iptrintrusive pointer to assign
Returns
reference to this
template<typename T>
IntrusivePtr<T>& Radiant::IntrusivePtr< T >::operator= ( IntrusivePtr< T > &&  iptr)
inline

Move an intrusive pointer.

Parameters
iptrintrusive pointer to move
Returns
reference to this
template<typename T>
template<typename Y >
IntrusivePtr<T>& Radiant::IntrusivePtr< T >::operator= ( IntrusivePtr< Y > &&  iptr)
inline

Move an intrusive pointer.

Parameters
iptrintrusive pointer to move
Returns
reference to this
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
IntrusivePtr<T>& Radiant::IntrusivePtr< T >::operator= ( T *  ptr)
inline

Assign a raw pointer to the intrusive pointer.

Parameters
ptrraw pointer to assign
Returns
reference to this
template<typename T>
template<typename Y >
bool Radiant::IntrusivePtr< T >::operator== ( const IntrusivePtr< Y > &  rhs) const
inline

Compare if two intrusive pointers are equal.

Parameters
rhsintrusive pointer to compare
Returns
true if the pointers are equal; otherwise false
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
template<typename Y >
bool Radiant::IntrusivePtr< T >::operator== ( const IntrusiveWeakPtr< Y > &  rhs) const
inline

Compare if intrusive pointer is equal to the given intrusive weak pointer.

Parameters
rhsintrusive weak pointer to compare
Returns
true if the pointers are equal; otherwise false
template<typename T>
template<typename Y >
bool Radiant::IntrusivePtr< T >::operator== ( const Y *  rhs) const
inline

Compare if the intrusive pointer is equal to the given raw pointer.

Parameters
rhsraw pointer to compare to
Returns
true if the pointers are equal; otherwise false
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
bool Radiant::IntrusivePtr< T >::operator== ( nullptr_t  ) const
inline

Compare if the intrusive pointer is equal to nullptr.

Returns
true if the intrusive pointer is nullptr
template<typename T>
template<typename Y >
void Radiant::IntrusivePtr< T >::reset ( Y *  ptr)
inline

Reset the intrusive pointer to given object.

Parameters
ptrobject to reset the pointer to
Template Parameters
YType of the object pointed by parameter pointer
template<typename T>
template<typename Y >
IntrusivePtr<Y> Radiant::IntrusivePtr< T >::static_pointer_cast ( ) const
inline

Perform static_cast to another intrusive pointer type.

Returns
intrusive pointer to another type
Template Parameters
YType of the object pointed by pointer returned