CFx SDK Documentation  2023 SP0
Public Member Functions | List of all members
OdSharedPtr< T > Class Template Reference

#include <SharedPtr.h>

Inheritance diagram for OdSharedPtr< T >:
OdStaticSharedPtr< T > OdStaticDefSharedPtr< T >

Public Member Functions

 OdSharedPtr ()
 
 OdSharedPtr (T *pObject)
 
 OdSharedPtr (const OdSharedPtr &other)
 
 ~OdSharedPtr ()
 
OdSharedPtroperator= (const OdSharedPtr &other)
 
T * operator-> ()
 
T * get ()
 
const T * get () const
 
 operator T* ()
 
 operator const T * () const
 
const T * operator-> () const
 
T & operator* ()
 
const T & operator* () const
 
bool isNull () const
 
T * detach ()
 
int refCount () const
 

Detailed Description

template<class T>
class OdSharedPtr< T >

This template class implements SharedPointers for instances not derived from OdRxObject.

Remarks
SharedPointers relieve the programmer of having to determine when objects are no longer needed, or having to delete them them at that time.

Each object referenced by a SharedPointer (henceforth 'referenced object') has associated with it a reference count; i.e., how many SharedPointers are referencing it. When the reference count reaches zero, the referenced object is deleted.

Corresponding C++ library: TD_Root <group Other_Classes>

Definition at line 48 of file SharedPtr.h.

Constructor & Destructor Documentation

◆ OdSharedPtr() [1/3]

template<class T >
OdSharedPtr< T >::OdSharedPtr ( )
inline

Definition at line 52 of file SharedPtr.h.

◆ OdSharedPtr() [2/3]

template<class T >
OdSharedPtr< T >::OdSharedPtr ( T *  pObject)
inline

Definition at line 54 of file SharedPtr.h.

◆ OdSharedPtr() [3/3]

template<class T >
OdSharedPtr< T >::OdSharedPtr ( const OdSharedPtr< T > &  other)
inline
Remarks
The another OdSharedPtr object is supplied, its reference count, if present, is incremented.

Definition at line 66 of file SharedPtr.h.

◆ ~OdSharedPtr()

template<class T >
OdSharedPtr< T >::~OdSharedPtr ( )
inline
Remarks
Decrements the reference count of the object referenced by this SharedPointer object.

When the reference count reaches zero, the referenced object is deleted.

Definition at line 82 of file SharedPtr.h.

Member Function Documentation

◆ detach()

template<class T >
T* OdSharedPtr< T >::detach ( )
inline

Detaches referenced object from the pointer. Warning: this method may be used only if reference count is 1 (i.e. when this pointer is the single owner of the referenced object)

Definition at line 170 of file SharedPtr.h.

◆ get() [1/2]

template<class T >
T* OdSharedPtr< T >::get ( )
inline

Returns the object referenced by this SharedPointer.

Remarks
This SharedPointer object maintains its reference to the object, and the object's reference count is not modified.

Definition at line 134 of file SharedPtr.h.

◆ get() [2/2]

template<class T >
const T* OdSharedPtr< T >::get ( ) const
inline

Returns the object referenced by this SharedPointer.

Remarks
This SharedPointer object maintains its reference to the object, and the object's reference count is not modified.

Definition at line 143 of file SharedPtr.h.

◆ isNull()

template<class T >
bool OdSharedPtr< T >::isNull ( ) const
inline

Returns true if and only if this SharedPointer contains a null reference.

Definition at line 163 of file SharedPtr.h.

◆ operator const T *()

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

Definition at line 146 of file SharedPtr.h.

◆ operator T*()

template<class T >
OdSharedPtr< T >::operator T* ( )
inline

Definition at line 145 of file SharedPtr.h.

◆ operator*() [1/2]

template<class T >
T& OdSharedPtr< T >::operator* ( )
inline

Definition at line 156 of file SharedPtr.h.

◆ operator*() [2/2]

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

Definition at line 158 of file SharedPtr.h.

◆ operator->() [1/2]

template<class T >
T* OdSharedPtr< T >::operator-> ( )
inline

Returns the object referenced by this SharedPointer.

Remarks
The reference count of the referenced object is unchanged.

Definition at line 125 of file SharedPtr.h.

◆ operator->() [2/2]

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

Returns the object referenced by this SharedPointer.

Remarks
The reference count of the referenced object is unchanged.

Definition at line 154 of file SharedPtr.h.

◆ operator=()

template<class T >
OdSharedPtr& OdSharedPtr< T >::operator= ( const OdSharedPtr< T > &  other)
inline

Definition at line 91 of file SharedPtr.h.

◆ refCount()

template<class T >
int OdSharedPtr< T >::refCount ( ) const
inline

Returns the number of references to the object.

Definition at line 187 of file SharedPtr.h.


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