cesium-native 0.43.0
Loading...
Searching...
No Matches
CesiumUtility::IntrusivePointer< T > Class Template Referencefinal

A smart pointer that calls addReference and releaseReference on the controlled object. More...

#include <CesiumUtility/IntrusivePointer.h>

Public Member Functions

 IntrusivePointer (T *p=nullptr) noexcept
 Default constructor.
 
 IntrusivePointer (const IntrusivePointer< T > &rhs) noexcept
 Copy constructor.
 
template<class U >
 IntrusivePointer (const IntrusivePointer< U > &rhs) noexcept
 Implicit conversion to a pointer to a base (or otherwise convertible) type.
 
 IntrusivePointer (IntrusivePointer< T > &&rhs) noexcept
 Move constructor.
 
template<class U >
 IntrusivePointer (IntrusivePointer< U > &&rhs) noexcept
 Implicit conversion of an r-value to a pointer to a base (or otherwise convertible) type.
 
 ~IntrusivePointer () noexcept
 Default destructor.
 
template<typename... ConstructorArgumentTypes>
T & emplace (ConstructorArgumentTypes &&... constructorArguments)
 Constructs a new instance and assigns it to this IntrusivePointer. If this IntrusivePointer already points to another instance, releaseReference is called on it.
 
void reset ()
 Reset this pointer to nullptr.
 
IntrusivePointeroperator= (const IntrusivePointer &rhs) noexcept
 Assignment operator.
 
template<class U >
IntrusivePointeroperator= (const IntrusivePointer< U > &rhs) noexcept
 Assigns an IntrusivePointer of another type to this IntrusivePointer.
 
IntrusivePointeroperator= (IntrusivePointer &&rhs) noexcept
 Move assignment operator.
 
IntrusivePointeroperator= (T *p) noexcept
 Assignment operator.
 
T & operator* () const noexcept
 Dereferencing operator.
 
T * operator-> () const noexcept
 Arrow operator.
 
 operator bool () const noexcept
 Implicit conversion to bool, being true iff this is not the nullptr.
 
T * get () const noexcept
 Returns the internal pointer.
 
bool operator== (const IntrusivePointer< T > &rhs) const noexcept
 Returns true if two pointers are equal.
 
template<class U >
bool operator== (const IntrusivePointer< U > &rhs) const noexcept
 Returns true if two pointers are equal.
 
bool operator!= (const IntrusivePointer< T > &rhs) const noexcept
 Returns true if two pointers are not equal.
 
bool operator== (const T *pRhs) const noexcept
 Returns true if the contents of this pointer is equal to the given pointer.
 
bool operator!= (const T *pRhs) const noexcept
 Returns true if the contents of this pointer is not equal to the given pointer.
 

Detailed Description

template<class T>
class CesiumUtility::IntrusivePointer< T >

A smart pointer that calls addReference and releaseReference on the controlled object.

Please note that the thread-safety of this type is entirely dependent on the implementation of addReference and releaseReference. If these methods are not thread safe on a particular type - which is common for objects that are not meant to be used from multiple threads simultaneously - then using an IntrusivePointer from multiple threads is also unsafe.

Template Parameters
TThe type of object controlled.

Definition at line 19 of file IntrusivePointer.h.

Constructor & Destructor Documentation

◆ IntrusivePointer() [1/5]

template<class T >
CesiumUtility::IntrusivePointer< T >::IntrusivePointer ( T * p = nullptr)
inlinenoexcept

Default constructor.

Definition at line 24 of file IntrusivePointer.h.

◆ IntrusivePointer() [2/5]

template<class T >
CesiumUtility::IntrusivePointer< T >::IntrusivePointer ( const IntrusivePointer< T > & rhs)
inlinenoexcept

Copy constructor.

Definition at line 29 of file IntrusivePointer.h.

◆ IntrusivePointer() [3/5]

template<class T >
template<class U >
CesiumUtility::IntrusivePointer< T >::IntrusivePointer ( const IntrusivePointer< U > & rhs)
inlinenoexcept

Implicit conversion to a pointer to a base (or otherwise convertible) type.

Template Parameters
UThe new type, usually a base class.
Parameters
rhsThe pointer.

Definition at line 41 of file IntrusivePointer.h.

◆ IntrusivePointer() [4/5]

template<class T >
CesiumUtility::IntrusivePointer< T >::IntrusivePointer ( IntrusivePointer< T > && rhs)
inlinenoexcept

Move constructor.

Definition at line 48 of file IntrusivePointer.h.

◆ IntrusivePointer() [5/5]

template<class T >
template<class U >
CesiumUtility::IntrusivePointer< T >::IntrusivePointer ( IntrusivePointer< U > && rhs)
inlinenoexcept

Implicit conversion of an r-value to a pointer to a base (or otherwise convertible) type.

Template Parameters
UThe new type, usually a base class.
Parameters
rhsThe pointer.

Definition at line 61 of file IntrusivePointer.h.

◆ ~IntrusivePointer()

template<class T >
CesiumUtility::IntrusivePointer< T >::~IntrusivePointer ( )
inlinenoexcept

Default destructor.

Definition at line 69 of file IntrusivePointer.h.

Member Function Documentation

◆ emplace()

template<class T >
template<typename... ConstructorArgumentTypes>
T & CesiumUtility::IntrusivePointer< T >::emplace ( ConstructorArgumentTypes &&... constructorArguments)
inline

Constructs a new instance and assigns it to this IntrusivePointer. If this IntrusivePointer already points to another instance, releaseReference is called on it.

Parameters
constructorArgumentsThe arguments to the constructor to create the new instance.
Returns
A reference to the newly-created instance.

Definition at line 81 of file IntrusivePointer.h.

◆ get()

template<class T >
T * CesiumUtility::IntrusivePointer< T >::get ( ) const
inlinenoexcept

Returns the internal pointer.

Definition at line 178 of file IntrusivePointer.h.

◆ operator bool()

template<class T >
CesiumUtility::IntrusivePointer< T >::operator bool ( ) const
inlineexplicitnoexcept

Implicit conversion to bool, being true iff this is not the nullptr.

Definition at line 173 of file IntrusivePointer.h.

◆ operator!=() [1/2]

template<class T >
bool CesiumUtility::IntrusivePointer< T >::operator!= ( const IntrusivePointer< T > & rhs) const
inlinenoexcept

Returns true if two pointers are not equal.

Definition at line 196 of file IntrusivePointer.h.

◆ operator!=() [2/2]

template<class T >
bool CesiumUtility::IntrusivePointer< T >::operator!= ( const T * pRhs) const
inlinenoexcept

Returns true if the contents of this pointer is not equal to the given pointer.

Definition at line 210 of file IntrusivePointer.h.

◆ operator*()

template<class T >
T & CesiumUtility::IntrusivePointer< T >::operator* ( ) const
inlinenoexcept

Dereferencing operator.

Definition at line 162 of file IntrusivePointer.h.

◆ operator->()

template<class T >
T * CesiumUtility::IntrusivePointer< T >::operator-> ( ) const
inlinenoexcept

Arrow operator.

Definition at line 167 of file IntrusivePointer.h.

◆ operator=() [1/4]

template<class T >
IntrusivePointer & CesiumUtility::IntrusivePointer< T >::operator= ( const IntrusivePointer< T > & rhs)
inlinenoexcept

Assignment operator.

Definition at line 95 of file IntrusivePointer.h.

◆ operator=() [2/4]

template<class T >
template<class U >
IntrusivePointer & CesiumUtility::IntrusivePointer< T >::operator= ( const IntrusivePointer< U > & rhs)
inlinenoexcept

Assigns an IntrusivePointer of another type to this IntrusivePointer.

Definition at line 115 of file IntrusivePointer.h.

◆ operator=() [3/4]

template<class T >
IntrusivePointer & CesiumUtility::IntrusivePointer< T >::operator= ( IntrusivePointer< T > && rhs)
inlinenoexcept

Move assignment operator.

Definition at line 133 of file IntrusivePointer.h.

◆ operator=() [4/4]

template<class T >
IntrusivePointer & CesiumUtility::IntrusivePointer< T >::operator= ( T * p)
inlinenoexcept

Assignment operator.

Definition at line 144 of file IntrusivePointer.h.

◆ operator==() [1/3]

template<class T >
bool CesiumUtility::IntrusivePointer< T >::operator== ( const IntrusivePointer< T > & rhs) const
inlinenoexcept

Returns true if two pointers are equal.

Definition at line 183 of file IntrusivePointer.h.

◆ operator==() [2/3]

template<class T >
template<class U >
bool CesiumUtility::IntrusivePointer< T >::operator== ( const IntrusivePointer< U > & rhs) const
inlinenoexcept

Returns true if two pointers are equal.

Definition at line 189 of file IntrusivePointer.h.

◆ operator==() [3/3]

template<class T >
bool CesiumUtility::IntrusivePointer< T >::operator== ( const T * pRhs) const
inlinenoexcept

Returns true if the contents of this pointer is equal to the given pointer.

Definition at line 204 of file IntrusivePointer.h.

◆ reset()

template<class T >
void CesiumUtility::IntrusivePointer< T >::reset ( )
inline

Reset this pointer to nullptr.

Definition at line 90 of file IntrusivePointer.h.

Friends And Related Symbol Documentation

◆ IntrusivePointer

template<class T >
template<typename U >
friend class IntrusivePointer
friend

Definition at line 226 of file IntrusivePointer.h.


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