The SharedPointer class. More...
#include "murl_shared_pointer.h"
Public Types | |
using | ValueType = DataType |
The template parameter value type. | |
Public Member Functions | |
SharedPointer () | |
The default constructor creating a null pointer. | |
template<class RawType > | |
SharedPointer (RawType *rawPointer) | |
Constructor taking a pointer to a specified object. More... | |
template<class RawType , class DeleterType > | |
SharedPointer (RawType *rawPointer, DeleterType deleter) | |
Constructor taking a pointer to a specified object and a corresponding deleter functor object. More... | |
template<class RawType > | |
SharedPointer (AutoPointer< RawType > autoPointer) | |
Constructor taking the ownership of an AutoPointer. More... | |
template<class RawType > | |
SharedPointer (const WeakPointer< RawType > &weakPointer) | |
Constructor taking a WeakPointer. More... | |
template<class RawType > | |
SharedPointer (const SharedPointer< RawType > &sharedPointer) | |
Constructor for automatic downcast. More... | |
DataType & | operator* () const |
Indirection operator. More... | |
DataType * | operator-> () const |
Dereference operator. More... | |
operator UnspecifiedBoolType () const | |
User define conversion to support statements like. More... | |
bool | operator! () const |
User define conversion to support statements like. More... | |
Bool | IsNull () const |
Check if the memory pointer is null. More... | |
UInt32 | GetCount () const |
Get the SharedPointer's usage counter. More... | |
Bool | IsUnique () const |
Check if the SharedPointer is the only one instance which is referencing the memory pointer. More... | |
void | Reset () |
Release the reference from the SharedPointer and set the memory pointer to null. | |
template<class RawType > | |
void | Reset (RawType *rawPointer) |
Set the memory pointer to a new object. More... | |
template<class RawType , class DeleterType > | |
void | Reset (RawType *rawPointer, DeleterType deleter) |
Set the memory pointer to a new object and a corresponding deleter functor object. More... | |
void | Swap (SharedPointer< DataType > &sharedPointer) |
Swap with another SharedPointer. More... | |
template<class RawType > | |
bool | operator== (const SharedPointer< RawType > &rhs) const |
Equal to comparison operator. More... | |
template<class RawType > | |
bool | operator!= (const SharedPointer< RawType > &rhs) const |
Not equal to comparison operator. More... | |
template<class RawType > | |
bool | operator< (const SharedPointer< RawType > &rhs) const |
Less than operator. More... | |
bool | operator== (void *rhs) const |
Equal to comparison operator with an unspecified pointer type. More... | |
bool | operator!= (void *rhs) const |
Not equal to comparison operator with an unspecified pointer type. More... | |
DataType * | Get () const |
Get the pointer to the memory. More... | |
Static Public Member Functions | |
template<class RawType > | |
static SharedPointer< DataType > | DynamicCast (const SharedPointer< RawType > &source) |
Create a SharedPointer from a SharedPointer of different type using the dynamic_cast for transfering the memory pointer. More... | |
template<class RawType > | |
static SharedPointer< DataType > | StaticCast (const SharedPointer< RawType > &source) |
Create a SharedPointer from a SharedPointer of different type using the static_cast for transfering the memory pointer. More... | |
template<class RawType > | |
static SharedPointer< DataType > | ConstCast (const SharedPointer< RawType > &source) |
Create a SharedPointer from a SharedPointer of different type using the const_cast for transfering the memory pointer. More... | |
Detailed Description
template<class DataType>
class Murl::SharedPointer< DataType >
The SharedPointer class.
The SharedPointer holds a reference counted memory pointer, which is deleted when the last reference is removed. To avoid cross-references a WeakPointer can be used.
Constructor & Destructor Documentation
◆ SharedPointer() [1/5]
|
inlineexplicit |
Constructor taking a pointer to a specified object.
- Parameters
-
rawPointer The pointer to the object.
◆ SharedPointer() [2/5]
|
inline |
Constructor taking a pointer to a specified object and a corresponding deleter functor object.
- Parameters
-
rawPointer The pointer to the object. deleter The deleter functor.
◆ SharedPointer() [3/5]
|
inline |
Constructor taking the ownership of an AutoPointer.
- Parameters
-
autoPointer The AutoPointer object to take over.
◆ SharedPointer() [4/5]
|
inlineexplicit |
Constructor taking a WeakPointer.
- Parameters
-
weakPointer The WeakPointer object.
◆ SharedPointer() [5/5]
|
inline |
Constructor for automatic downcast.
- Parameters
-
sharedPointer The SharedPointer object.
Member Function Documentation
◆ operator*()
|
inline |
Indirection operator.
- Returns
- The reference to the memory.
◆ operator->()
|
inline |
Dereference operator.
- Returns
- The pointer to the memory.
◆ operator UnspecifiedBoolType()
|
inline |
User define conversion to support statements like.
- Returns
- Pointer to the memory pointer or null.
◆ operator!()
|
inline |
User define conversion to support statements like.
- Returns
- true if the memory pointer is null.
◆ IsNull()
|
inline |
Check if the memory pointer is null.
- Returns
- true if the memory pointer is null.
◆ GetCount()
|
inline |
Get the SharedPointer's usage counter.
- Returns
- The number of SharePointer instances referencing to the same memory pointer.
References Murl::SharedPointerPrivate::SharedCounter::GetCount().
◆ IsUnique()
|
inline |
Check if the SharedPointer is the only one instance which is referencing the memory pointer.
- Returns
- true if the SharedPointer's usage counter is 1.
References Murl::SharedPointerPrivate::SharedCounter::GetCount().
◆ Reset() [1/2]
|
inline |
Set the memory pointer to a new object.
- Parameters
-
rawPointer The pointer to the object.
References Murl::SharedPointer< DataType >::Swap().
◆ Reset() [2/2]
|
inline |
Set the memory pointer to a new object and a corresponding deleter functor object.
- Parameters
-
rawPointer The pointer to the object. deleter The deleter functor.
References Murl::SharedPointer< DataType >::Swap().
◆ Swap()
|
inline |
Swap with another SharedPointer.
- Parameters
-
sharedPointer The SharedPointer to swap with.
References Murl::SharedPointerPrivate::SharedCounter::Swap().
Referenced by Murl::SharedPointer< DataType >::Reset().
◆ operator==() [1/2]
|
inline |
Equal to comparison operator.
- Parameters
-
rhs The right hand side SharedPointer to compare.
- Returns
- true if the memory pointers are equal.
◆ operator!=() [1/2]
|
inline |
Not equal to comparison operator.
- Parameters
-
rhs The right hand side SharedPointer to compare.
- Returns
- true if the memory pointers are not equal.
◆ operator<()
|
inline |
Less than operator.
- Parameters
-
rhs The right hand side SharedPointer to compare.
- Returns
- true if the left hand side (this) is less than the right hand side.
◆ operator==() [2/2]
|
inline |
Equal to comparison operator with an unspecified pointer type.
- Parameters
-
rhs The right hand side memory pointer to compare.
- Returns
- true if the memory pointers are equal.
◆ operator!=() [2/2]
|
inline |
Not equal to comparison operator with an unspecified pointer type.
- Parameters
-
rhs The right hand side memory pointer to compare.
- Returns
- true if the memory pointers are equal.
◆ Get()
|
inline |
Get the pointer to the memory.
The memory pointer should be used within local scope only! If the SharedPointer object goes out-of-scope, the validity of the memory location it is no longer guaranteed.
- Returns
- The pointer to the memory.
Referenced by Murl::Util::Hash::GetHashValue(), Murl::Logic::BaseProcessor::GetNodeObserver(), Murl::Logic::GraphInstanceObjects< InstanceObjectType >::Init(), and Murl::Logic::BaseNodeObserver::operator INodeObserver *().
◆ DynamicCast()
|
inlinestatic |
Create a SharedPointer from a SharedPointer of different type using the dynamic_cast for transfering the memory pointer.
- Parameters
-
source The SharedPointer to cast the memory from.
- Returns
- A SmartPointer containing the source memory pointer with own type.
◆ StaticCast()
|
inlinestatic |
Create a SharedPointer from a SharedPointer of different type using the static_cast for transfering the memory pointer.
- Parameters
-
source The SharedPointer to cast the memory from.
- Returns
- A SmartPointer containing the source memory pointer with own type.
◆ ConstCast()
|
inlinestatic |
Create a SharedPointer from a SharedPointer of different type using the const_cast for transfering the memory pointer.
- Parameters
-
source The SharedPointer to cast the memory from.
- Returns
- A SmartPointer containing the source memory pointer with own type.
The documentation for this class was generated from the following file:
- murl_shared_pointer.h