nux-0.9.48

nux::ObjectPtr< T > Class Template Reference

A smart pointer class. Implemented as an intrusive smart pointer. More...

#include <NuxCore/ObjectPtr.h>

Public Member Functions

 ObjectPtr ()
 Constructor.
 ObjectPtr (const ObjectPtr< T > &other)
 Copy constructor.
template<typename O >
 ObjectPtr (const ObjectPtr< O > &other)
 Copy constructor.
 ObjectPtr (T *ptr, bool WarnMissuse=false)
 Construction with a base pointer of type T.
template<typename O >
 ObjectPtr (O *ptr, bool WarnMissuse=false)
 Construction with a base pointer of type O that inherits from type T.
ObjectPtroperator= (const ObjectPtr< T > &other)
 Assignment of a smart pointer of type T.
template<typename O >
ObjectPtroperator= (const ObjectPtr< O > &other)
 Assignment of a smart pointer of type O that inherits from type T.
T * GetSPPointer () const
 ~ObjectPtr ()
T & operator* () const
T * operator-> () const
bool operator() () const
 Test validity of the smart pointer.
bool IsNull () const
 Test validity of the smart pointer.
bool IsValid () const
 Test validity of the smart pointer.
bool operator< (T *ptr) const
bool operator> (T *ptr) const
bool operator< (ObjectPtr< T > other) const
bool operator> (ObjectPtr< T > other) const
bool operator!= (T *ptr) const
bool operator== (T *ptr) const
template<typename U >
bool operator!= (U *ptr) const
template<typename U >
bool operator== (U *ptr) const
template<typename U >
bool operator!= (const ObjectPtr< U > &other) const
template<typename U >
bool operator== (const ObjectPtr< U > &other) const
template<typename U >
bool operator!= (const ObjectWeakPtr< U > &other) const
template<typename U >
bool operator== (const ObjectWeakPtr< U > &other) const
bool Release ()
 Release the hosted pointer from this object.

Friends

class ObjectPtr
class ObjectWeakPtr
template<typename U >
ObjectPtr< U > Create ()
template<typename U , typename P1 >
ObjectPtr< U > Create (P1 p1)
template<typename U , typename P1 , typename P2 >
ObjectPtr< U > Create (P1 p1, P2 p2)
template<typename U , typename P1 , typename P2 , typename P3 >
ObjectPtr< U > Create (P1 p1, P2 p2, P3 p3)
template<typename U , typename P1 , typename P2 , typename P3 , typename P4 >
ObjectPtr< U > Create (P1 p1, P2 p2, P3 p3, P4 p4)
template<typename U , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
ObjectPtr< U > Create (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
template<typename U , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 >
ObjectPtr< U > Create (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
template<typename U , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 >
ObjectPtr< U > Create (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7)
template<typename U >
ObjectPtr< U > WrapWSPtr (U *u)
template<typename U >
bool operator== (U *, const ObjectPtr< U > &a)
template<typename U >
bool operator!= (U *, const ObjectPtr< U > &a)
template<typename U , typename F >
ObjectPtr< U > staticCast (const ObjectPtr< F > &from)
template<typename U , typename F >
ObjectPtr< U > constCast (const ObjectPtr< F > &from)
template<typename U , typename F >
ObjectPtr< U > dynamicCast (const ObjectPtr< F > &from)
template<typename U , typename F >
ObjectPtr< U > checkedCast (const ObjectPtr< F > &from)
template<typename U , typename F >
ObjectPtr< U > queryCast (const ObjectPtr< F > &from)

Detailed Description

template<typename T>
class nux::ObjectPtr< T >

A smart pointer class. Implemented as an intrusive smart pointer.


Constructor & Destructor Documentation

template<typename T>
nux::ObjectPtr< T >::ObjectPtr ( ) [inline]

Constructor.

template<typename T>
nux::ObjectPtr< T >::ObjectPtr ( const ObjectPtr< T > &  other) [inline]

Copy constructor.

template<typename T>
template<typename O >
nux::ObjectPtr< T >::ObjectPtr ( const ObjectPtr< O > &  other) [inline]

Copy constructor.

Parameters:
otherParameter with a type derived from T.
template<typename T>
nux::ObjectPtr< T >::ObjectPtr ( T *  ptr,
bool  WarnMissuse = false 
) [inline, explicit]

Construction with a base pointer of type T.

Parameters:
ptrStart maintaining a reference count of the passed pointer.
WarnMissuseIf True, then ObjectPtr test is ptr is owned or not. If ptr is not owned and WarnMissuse is True, then Print a warning message. This is a debug feature to detect cases such as "ObjectPtr(ObjectA) myobject(ptr);", because the calling code will no longer have a reference on ptr.
template<typename T>
template<typename O >
nux::ObjectPtr< T >::ObjectPtr ( O *  ptr,
bool  WarnMissuse = false 
) [inline, explicit]

Construction with a base pointer of type O that inherits from type T.

Parameters:
ptrStart maintaining a reference count of the passed pointer.
WarnMissuseIf True, then ObjectPtr test is ptr is owned or not. If ptr is not owned and WarnMissuse is True, then Print a warning message. This is a debug feature to detect cases such as "ObjectPtr(ObjectA) myobject(ptr);", because the calling code will no longer have a reference on ptr.
template<typename T>
nux::ObjectPtr< T >::~ObjectPtr ( ) [inline]

Member Function Documentation

template<typename T>
T* nux::ObjectPtr< T >::GetSPPointer ( ) const [inline]
template<typename T>
bool nux::ObjectPtr< T >::IsNull ( ) const [inline]

Test validity of the smart pointer.

Return True if the internal pointer is null.

template<typename T>
bool nux::ObjectPtr< T >::IsValid ( ) const [inline]

Test validity of the smart pointer.

Return True if the internal pointer is not null.

Referenced by nux::TResourceCache< int, CachedResourceData >::FlushResourceId().

template<typename T>
template<typename U >
bool nux::ObjectPtr< T >::operator!= ( const ObjectPtr< U > &  other) const [inline]
template<typename T>
template<typename U >
bool nux::ObjectPtr< T >::operator!= ( const ObjectWeakPtr< U > &  other) const [inline]
template<typename T>
bool nux::ObjectPtr< T >::operator!= ( T *  ptr) const [inline]
template<typename T>
template<typename U >
bool nux::ObjectPtr< T >::operator!= ( U *  ptr) const [inline]
template<typename T>
bool nux::ObjectPtr< T >::operator() ( ) const [inline]

Test validity of the smart pointer.

Parameters:
otherSmart pointer to swap with.

Return True if the internal pointer is not null.

template<typename T>
T& nux::ObjectPtr< T >::operator* ( void  ) const [inline]
template<typename T>
T* nux::ObjectPtr< T >::operator-> ( ) const [inline]
template<typename T>
bool nux::ObjectPtr< T >::operator< ( T *  ptr) const [inline]
template<typename T>
bool nux::ObjectPtr< T >::operator< ( ObjectPtr< T >  other) const [inline]
template<typename T>
template<typename O >
ObjectPtr& nux::ObjectPtr< T >::operator= ( const ObjectPtr< O > &  other) [inline]

Assignment of a smart pointer of type O that inherits from type T.

Parameters:
otherSmart pointer of type O.
template<typename T>
ObjectPtr& nux::ObjectPtr< T >::operator= ( const ObjectPtr< T > &  other) [inline]

Assignment of a smart pointer of type T.

Parameters:
otherSmart pointer of type T.
template<typename T>
bool nux::ObjectPtr< T >::operator== ( T *  ptr) const [inline]
template<typename T>
template<typename U >
bool nux::ObjectPtr< T >::operator== ( const ObjectPtr< U > &  other) const [inline]
template<typename T>
template<typename U >
bool nux::ObjectPtr< T >::operator== ( const ObjectWeakPtr< U > &  other) const [inline]
template<typename T>
template<typename U >
bool nux::ObjectPtr< T >::operator== ( U *  ptr) const [inline]
template<typename T>
bool nux::ObjectPtr< T >::operator> ( T *  ptr) const [inline]
template<typename T>
bool nux::ObjectPtr< T >::operator> ( ObjectPtr< T >  other) const [inline]
template<typename T>
bool nux::ObjectPtr< T >::Release ( ) [inline]

Release the hosted pointer from this object.

Release the hosted pointer from this object. After this call, the following members are null: _reference_count _weak_reference_count ptr_ This call decreases the count of strong and weak references reference before setting _reference_count and _weak_reference_count to null.

Returns:
True if the hosted object was destroyed.

Friends And Related Function Documentation

template<typename T>
template<typename U , typename F >
ObjectPtr<U> checkedCast ( const ObjectPtr< F > &  from) [friend]
template<typename T>
template<typename U , typename F >
ObjectPtr<U> constCast ( const ObjectPtr< F > &  from) [friend]
template<typename T>
template<typename U , typename P1 >
ObjectPtr<U> Create ( P1  p1) [friend]
template<typename T>
template<typename U , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 >
ObjectPtr<U> Create ( P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5 
) [friend]
template<typename T>
template<typename U , typename P1 , typename P2 , typename P3 , typename P4 >
ObjectPtr<U> Create ( P1  p1,
P2  p2,
P3  p3,
P4  p4 
) [friend]
template<typename T>
template<typename U , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 >
ObjectPtr<U> Create ( P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5,
P6  p6 
) [friend]
template<typename T>
template<typename U , typename P1 , typename P2 >
ObjectPtr<U> Create ( P1  p1,
P2  p2 
) [friend]
template<typename T>
template<typename U , typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 >
ObjectPtr<U> Create ( P1  p1,
P2  p2,
P3  p3,
P4  p4,
P5  p5,
P6  p6,
P7  p7 
) [friend]
template<typename T>
template<typename U >
ObjectPtr<U> Create ( ) [friend]
template<typename T>
template<typename U , typename P1 , typename P2 , typename P3 >
ObjectPtr<U> Create ( P1  p1,
P2  p2,
P3  p3 
) [friend]
template<typename T>
template<typename U , typename F >
ObjectPtr<U> dynamicCast ( const ObjectPtr< F > &  from) [friend]
template<typename T>
friend class ObjectPtr [friend]
template<typename T>
friend class ObjectWeakPtr [friend]
template<typename T>
template<typename U >
bool operator!= ( U *  ,
const ObjectPtr< U > &  a 
) [friend]
template<typename T>
template<typename U >
bool operator== ( U *  ,
const ObjectPtr< U > &  a 
) [friend]
template<typename T>
template<typename U , typename F >
ObjectPtr<U> queryCast ( const ObjectPtr< F > &  from) [friend]
template<typename T>
template<typename U , typename F >
ObjectPtr<U> staticCast ( const ObjectPtr< F > &  from) [friend]
template<typename T>
template<typename U >
ObjectPtr<U> WrapWSPtr ( U *  u) [friend]

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