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

This class implements weak pointers for the IntrusivePtr class. More...

#include <Radiant/IntrusivePtr.hpp>

Public Types

typedef T element_type
 Type of the object pointed to.
 

Public Member Functions

const IntrusivePtrCounter * counter () const
 
 IntrusiveWeakPtr ()
 Null constructor.
 
template<typename Y >
 IntrusiveWeakPtr (Y *ptr)
 Construct a weak pointer from the given raw pointer. More...
 
template<typename Y >
 IntrusiveWeakPtr (const IntrusivePtr< Y > &iptr)
 Construct an intrusive weak pointer from the given intrusive pointer. More...
 
 IntrusiveWeakPtr (const IntrusiveWeakPtr< T > &wptr)
 Construct a copy of the given weak pointer. More...
 
template<typename Y >
 IntrusiveWeakPtr (const IntrusiveWeakPtr< Y > &wptr)
 Construct a copy of the given intrusive weak pointer. More...
 
 IntrusiveWeakPtr (IntrusiveWeakPtr< T > &&wptr)
 Move the given weak pointer. More...
 
template<typename Y >
 IntrusiveWeakPtr (IntrusiveWeakPtr< Y > &&wptr)
 Move the given weak pointer. More...
 
template<typename Y >
IntrusivePtr< Y > lock () const
 Convert the intrusive weak pointer to intrusive pointer. More...
 
IntrusivePtr< T > lock () const
 Convert the intrusive weak pointer to intrusive pointer. More...
 
template<typename Y >
bool operator!= (const IntrusiveWeakPtr< Y > &rhs) const
 Compare if two intrusive weak pointers are inequal. More...
 
template<typename Y >
bool operator< (const IntrusiveWeakPtr< Y > &rhs) const
 Compare two intrusive weak pointers. More...
 
IntrusiveWeakPtroperator= (const IntrusiveWeakPtr< T > &wptr)
 Assign the given intrusive weak pointer. More...
 
template<typename Y >
IntrusiveWeakPtroperator= (const IntrusiveWeakPtr< Y > &wptr)
 Assign the given intrusive weak pointer. More...
 
IntrusiveWeakPtroperator= (IntrusiveWeakPtr< T > &&wptr)
 Move the given intrusive weak pointer. More...
 
template<typename Y >
IntrusiveWeakPtroperator= (IntrusiveWeakPtr< Y > &&wptr)
 Move the given intrusive weak pointer. More...
 
template<typename Y >
bool operator== (const IntrusiveWeakPtr< Y > &rhs) const
 Compare if two intrusive weak pointers are equal. More...
 
void reset ()
 Reset the intrusive weak pointer to nullptr.
 
 ~IntrusiveWeakPtr ()
 Destructor.
 

Friends

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

Detailed Description

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

This class implements weak pointers for the IntrusivePtr class.

The weak associated to an intrusive pointer. Whenever the contents of the weak pointer are accessed, it must be converted to an intrusive pointer with the lock() method or a special constructor. If the intrusive pointer associated with this weak pointer is released, the conversion will fail and an intrusive pointer to nullptr is returned. In order to use intrusive pointers with custom objects, a single function intrusivePtrGetCounter must be defined for the wrapped object type.

Constructor & Destructor Documentation

template<typename T >
template<typename Y >
Radiant::IntrusiveWeakPtr< T >::IntrusiveWeakPtr ( Y *  ptr)
inlineexplicit

Construct a weak pointer from the given raw pointer.

Parameters
ptrraw pointer to construct from
Template Parameters
YType of the object whose pointer is stored in this pointer
template<typename T >
template<typename Y >
Radiant::IntrusiveWeakPtr< T >::IntrusiveWeakPtr ( const IntrusivePtr< Y > &  iptr)

Construct an intrusive weak pointer from the given intrusive pointer.

Parameters
iptrintrusive pointer to convert from
Template Parameters
YType of the object whose pointer is stored in this pointer
template<typename T >
Radiant::IntrusiveWeakPtr< T >::IntrusiveWeakPtr ( const IntrusiveWeakPtr< T > &  wptr)
inline

Construct a copy of the given weak pointer.

Parameters
wptrweak pointer to copy
template<typename T >
template<typename Y >
Radiant::IntrusiveWeakPtr< T >::IntrusiveWeakPtr ( const IntrusiveWeakPtr< Y > &  wptr)
inline

Construct a copy of the given intrusive weak pointer.

Parameters
wptrweak pointer to copy
Template Parameters
YType of the object whose pointer is stored in this pointer
template<typename T >
Radiant::IntrusiveWeakPtr< T >::IntrusiveWeakPtr ( IntrusiveWeakPtr< T > &&  wptr)
inline

Move the given weak pointer.

Parameters
wptrweak pointer to move
template<typename T >
template<typename Y >
Radiant::IntrusiveWeakPtr< T >::IntrusiveWeakPtr ( IntrusiveWeakPtr< Y > &&  wptr)
inline

Move the given weak pointer.

Parameters
wptrweak pointer to move
Template Parameters
YType of the object whose pointer is stored in this pointer

Member Function Documentation

template<typename T >
const IntrusivePtrCounter* Radiant::IntrusiveWeakPtr< T >::counter ( ) const
inline
Returns
the counter object, can be null
template<typename T >
template<typename Y >
IntrusivePtr< Y > Radiant::IntrusiveWeakPtr< T >::lock ( ) const

Convert the intrusive weak pointer to intrusive pointer.

This function will return an intrusive pointer to the object pointed by this intrusive weak pointer. If the object has been released an intrusive pointer to nullptr is returned.

Returns
intrusive pointer to the object or to nullptr
Template Parameters
YType of the object that is pointed to by return value
template<typename T >
IntrusivePtr< T > Radiant::IntrusiveWeakPtr< T >::lock ( ) const

Convert the intrusive weak pointer to intrusive pointer.

This function will return an intrusive pointer to the object pointed by this intrusive weak pointer. If the object has been released an intrusive pointer to nullptr is returned.

Returns
intrusive pointer to the object or to nullptr
template<typename T >
template<typename Y >
bool Radiant::IntrusiveWeakPtr< T >::operator!= ( const IntrusiveWeakPtr< Y > &  rhs) const
inline

Compare if two intrusive weak pointers are inequal.

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

Compare two intrusive weak pointers.

Parameters
rhsintrusive weak pointer to compare
Returns
true if this pointer is less than the given pointer; otherwise false
Template Parameters
Typeof the object pointed by parameter pointer
template<typename T >
IntrusiveWeakPtr& Radiant::IntrusiveWeakPtr< T >::operator= ( const IntrusiveWeakPtr< T > &  wptr)
inline

Assign the given intrusive weak pointer.

Parameters
wptrintrusive weak pointer to assign
Returns
reference to this
template<typename T >
template<typename Y >
IntrusiveWeakPtr& Radiant::IntrusiveWeakPtr< T >::operator= ( const IntrusiveWeakPtr< Y > &  wptr)
inline

Assign the given intrusive weak pointer.

Parameters
wptrintrusive weak pointer to assign
Returns
reference to this
Template Parameters
YType of the object whose pointer is stored in this pointer
template<typename T >
IntrusiveWeakPtr& Radiant::IntrusiveWeakPtr< T >::operator= ( IntrusiveWeakPtr< T > &&  wptr)
inline

Move the given intrusive weak pointer.

Parameters
wptrintrusive weak pointer to move
Returns
reference to this
template<typename T >
template<typename Y >
IntrusiveWeakPtr& Radiant::IntrusiveWeakPtr< T >::operator= ( IntrusiveWeakPtr< Y > &&  wptr)
inline

Move the given intrusive weak pointer.

Parameters
wptrintrusive weak pointer to move
Returns
reference to this
Template Parameters
YType of the object whose pointer is stored in this pointer
template<typename T >
template<typename Y >
bool Radiant::IntrusiveWeakPtr< T >::operator== ( const IntrusiveWeakPtr< Y > &  rhs) const
inline

Compare if two intrusive weak pointers are equal.

Parameters
rhsintrusive weak pointer to compare
Returns
true if the pointers are equal; otherwise false
Template Parameters
Typeof the object pointed by parameter pointer