TrueReality  v0.1.1912
trBase::SmrtPtr< T > Class Template Reference

Smart pointer for handling referenced counted objects. More...

#include <SmrtPtr.h>

Inheritance diagram for trBase::SmrtPtr< T >:

Public Member Functions

 SmrtPtr ()
 Default constructor. More...
 
 SmrtPtr (T *t)
 Constructor. More...
 
 SmrtPtr (const SmrtPtr &smPt)
 Copy constructor. More...
 
T * Get () const
 Returns the stored internal pointer. More...
 
T * Release ()
 Release the pointer from ownership by this SmrtPtr<>, decrementing the objects refenced count to prevent the object from being deleted even if the reference count goes to zero. More...
 
void Swap (SmrtPtr &sp)
 Swaps the internal pointer of this and the passed in SmartPtr. More...
 
bool Valid () const
 Returns True if the smart pointer has a valid internal pointer set. More...
 
bool operator! () const
 Logical negation operator. More...
 
T & operator* () const
 Dereferences the internal pointer. More...
 
T * operator-> () const
 Access to the internal pointer. More...
 
 operator T* () const
 
 operator osg::ref_ptr< T > () const
 Implicit conversion operator to OSG ref_ptr. More...
 
 operator osg::ref_ptr< T > & ()
 Implicit conversion operator to OSG ref_ptr. More...
 
 operator const osg::ref_ptr< T > & () const
 Implicit conversion operator to OSG ref_ptr. More...
 
 operator osg::ref_ptr< T > * ()
 Implicit conversion operator to OSG ref_ptr. More...
 

Private Attributes

osg::ref_ptr< T > mOSGSmartPtr
 

Friends

std::ostream & operator<< (std::ostream &ios, const SmrtPtr &smPt)
 Prints out the memory address of the held pointer. More...
 

Detailed Description

template<class T>
class trBase::SmrtPtr< T >

Smart pointer for handling referenced counted objects.

Definition at line 36 of file SmrtPtr.h.

Constructor & Destructor Documentation

◆ SmrtPtr() [1/3]

template<class T>
trBase::SmrtPtr< T >::SmrtPtr ( )
inline

Default constructor.

Definition at line 45 of file SmrtPtr.h.

◆ SmrtPtr() [2/3]

template<class T>
trBase::SmrtPtr< T >::SmrtPtr ( T *  t)
inline

Constructor.

Parameters
[in,out]tIf non-null, the T to process.

Definition at line 54 of file SmrtPtr.h.

◆ SmrtPtr() [3/3]

template<class T>
trBase::SmrtPtr< T >::SmrtPtr ( const SmrtPtr< T > &  smPt)
inline

Copy constructor.

Parameters
smPtThe sm point.

Definition at line 64 of file SmrtPtr.h.

Member Function Documentation

◆ Get()

◆ operator const osg::ref_ptr< T > &()

template<class T>
trBase::SmrtPtr< T >::operator const osg::ref_ptr< T > & ( ) const
inline

Implicit conversion operator to OSG ref_ptr.

Template Parameters
TGeneric type parameter.
Returns
The OSG smart pointer

Definition at line 172 of file SmrtPtr.h.

◆ operator osg::ref_ptr< T >()

template<class T>
trBase::SmrtPtr< T >::operator osg::ref_ptr< T > ( ) const
inline

Implicit conversion operator to OSG ref_ptr.

Template Parameters
TGeneric type parameter.
Returns
The OSG smart pointer

Definition at line 150 of file SmrtPtr.h.

◆ operator osg::ref_ptr< T > &()

template<class T>
trBase::SmrtPtr< T >::operator osg::ref_ptr< T > & ( )
inline

Implicit conversion operator to OSG ref_ptr.

Template Parameters
TGeneric type parameter.
Returns
The OSG smart pointer

Definition at line 161 of file SmrtPtr.h.

◆ operator osg::ref_ptr< T > *()

template<class T>
trBase::SmrtPtr< T >::operator osg::ref_ptr< T > * ( )
inline

Implicit conversion operator to OSG ref_ptr.

Template Parameters
TGeneric type parameter.
Returns
The OSG smart pointer

Definition at line 183 of file SmrtPtr.h.

◆ operator T*()

template<class T>
trBase::SmrtPtr< T >::operator T* ( ) const
inline

Definition at line 139 of file SmrtPtr.h.

◆ operator!()

template<class T>
bool trBase::SmrtPtr< T >::operator! ( ) const
inline

Logical negation operator.

Returns
The logical inverse of this value.

Definition at line 112 of file SmrtPtr.h.

◆ operator*()

template<class T>
T & trBase::SmrtPtr< T >::operator* ( ) const
inline

Dereferences the internal pointer.

Returns
The result of the operation.

Definition at line 121 of file SmrtPtr.h.

◆ operator->()

template<class T>
T * trBase::SmrtPtr< T >::operator-> ( ) const
inline

Access to the internal pointer.

Returns
The dereferenced object.

Definition at line 130 of file SmrtPtr.h.

◆ Release()

template<class T>
T * trBase::SmrtPtr< T >::Release ( )
inline

Release the pointer from ownership by this SmrtPtr<>, decrementing the objects refenced count to prevent the object from being deleted even if the reference count goes to zero.

When using Release() you are implicitly expecting other code to take over management of the object, otherwise a memory leak will result.

Returns
Null if it fails, else a pointer to a T.

Definition at line 85 of file SmrtPtr.h.

◆ Swap()

template<class T>
void trBase::SmrtPtr< T >::Swap ( SmrtPtr< T > &  sp)
inline

Swaps the internal pointer of this and the passed in SmartPtr.

Parameters
[in,out]spThe smart ppointer.

Definition at line 94 of file SmrtPtr.h.

◆ Valid()

template<class T>
bool trBase::SmrtPtr< T >::Valid ( ) const
inline

Returns True if the smart pointer has a valid internal pointer set.

Returns
True if it succeeds, false if it fails.

Definition at line 103 of file SmrtPtr.h.

Referenced by trManager::DirectorBase::CompareComponentPriority(), trManager::EntityBase::Emancipate(), trManager::SystemManager::GetInstance(), trCore::SceneObjects::SkyBoxNode::LoadFile(), trManager::EntityBase::RemoveFromHierarchy(), and trManager::EntityBase::SetParent().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

template<class T>
std::ostream & operator<< ( std::ostream &  ios,
const SmrtPtr< T > &  smPt 
)
friend

Prints out the memory address of the held pointer.

Parameters
[in,out]iosThe ios.
smPtThe smart pointer.
Returns
A streamed output

Definition at line 195 of file SmrtPtr.h.

Member Data Documentation

◆ mOSGSmartPtr


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