Murl::SharedPointer< DataType > Class Template Reference

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]

template<class DataType >
template<class RawType >
Murl::SharedPointer< DataType >::SharedPointer ( RawType *  rawPointer)
inlineexplicit

Constructor taking a pointer to a specified object.

Parameters
rawPointerThe pointer to the object.

◆ SharedPointer() [2/5]

template<class DataType >
template<class RawType , class DeleterType >
Murl::SharedPointer< DataType >::SharedPointer ( RawType *  rawPointer,
DeleterType  deleter 
)
inline

Constructor taking a pointer to a specified object and a corresponding deleter functor object.

Parameters
rawPointerThe pointer to the object.
deleterThe deleter functor.

◆ SharedPointer() [3/5]

template<class DataType >
template<class RawType >
Murl::SharedPointer< DataType >::SharedPointer ( AutoPointer< RawType >  autoPointer)
inline

Constructor taking the ownership of an AutoPointer.

Parameters
autoPointerThe AutoPointer object to take over.

◆ SharedPointer() [4/5]

template<class DataType >
template<class RawType >
Murl::SharedPointer< DataType >::SharedPointer ( const WeakPointer< RawType > &  weakPointer)
inlineexplicit

Constructor taking a WeakPointer.

Parameters
weakPointerThe WeakPointer object.

◆ SharedPointer() [5/5]

template<class DataType >
template<class RawType >
Murl::SharedPointer< DataType >::SharedPointer ( const SharedPointer< RawType > &  sharedPointer)
inline

Constructor for automatic downcast.

Parameters
sharedPointerThe SharedPointer object.

Member Function Documentation

◆ operator*()

template<class DataType >
DataType& Murl::SharedPointer< DataType >::operator* ( ) const
inline

Indirection operator.

Returns
The reference to the memory.

◆ operator->()

template<class DataType >
DataType* Murl::SharedPointer< DataType >::operator-> ( ) const
inline

Dereference operator.

Returns
The pointer to the memory.

◆ operator UnspecifiedBoolType()

template<class DataType >
Murl::SharedPointer< DataType >::operator UnspecifiedBoolType ( ) const
inline

User define conversion to support statements like.

if (sharedPointer)
Returns
Pointer to the memory pointer or null.

◆ operator!()

template<class DataType >
bool Murl::SharedPointer< DataType >::operator! ( ) const
inline

User define conversion to support statements like.

if (!sharedPointer)
Returns
true if the memory pointer is null.

◆ IsNull()

template<class DataType >
Bool Murl::SharedPointer< DataType >::IsNull ( ) const
inline

Check if the memory pointer is null.

Returns
true if the memory pointer is null.

◆ GetCount()

template<class DataType >
UInt32 Murl::SharedPointer< DataType >::GetCount ( ) const
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()

template<class DataType >
Bool Murl::SharedPointer< DataType >::IsUnique ( ) const
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]

template<class DataType >
template<class RawType >
void Murl::SharedPointer< DataType >::Reset ( RawType *  rawPointer)
inline

Set the memory pointer to a new object.

Parameters
rawPointerThe pointer to the object.

References Murl::SharedPointer< DataType >::Swap().

◆ Reset() [2/2]

template<class DataType >
template<class RawType , class DeleterType >
void Murl::SharedPointer< DataType >::Reset ( RawType *  rawPointer,
DeleterType  deleter 
)
inline

Set the memory pointer to a new object and a corresponding deleter functor object.

Parameters
rawPointerThe pointer to the object.
deleterThe deleter functor.

References Murl::SharedPointer< DataType >::Swap().

◆ Swap()

template<class DataType >
void Murl::SharedPointer< DataType >::Swap ( SharedPointer< DataType > &  sharedPointer)
inline

Swap with another SharedPointer.

Parameters
sharedPointerThe SharedPointer to swap with.

References Murl::SharedPointerPrivate::SharedCounter::Swap().

Referenced by Murl::SharedPointer< DataType >::Reset().

◆ operator==() [1/2]

template<class DataType >
template<class RawType >
bool Murl::SharedPointer< DataType >::operator== ( const SharedPointer< RawType > &  rhs) const
inline

Equal to comparison operator.

Parameters
rhsThe right hand side SharedPointer to compare.
Returns
true if the memory pointers are equal.

◆ operator!=() [1/2]

template<class DataType >
template<class RawType >
bool Murl::SharedPointer< DataType >::operator!= ( const SharedPointer< RawType > &  rhs) const
inline

Not equal to comparison operator.

Parameters
rhsThe right hand side SharedPointer to compare.
Returns
true if the memory pointers are not equal.

◆ operator<()

template<class DataType >
template<class RawType >
bool Murl::SharedPointer< DataType >::operator< ( const SharedPointer< RawType > &  rhs) const
inline

Less than operator.

Parameters
rhsThe right hand side SharedPointer to compare.
Returns
true if the left hand side (this) is less than the right hand side.

◆ operator==() [2/2]

template<class DataType >
bool Murl::SharedPointer< DataType >::operator== ( void *  rhs) const
inline

Equal to comparison operator with an unspecified pointer type.

Parameters
rhsThe right hand side memory pointer to compare.
Returns
true if the memory pointers are equal.

◆ operator!=() [2/2]

template<class DataType >
bool Murl::SharedPointer< DataType >::operator!= ( void *  rhs) const
inline

Not equal to comparison operator with an unspecified pointer type.

Parameters
rhsThe right hand side memory pointer to compare.
Returns
true if the memory pointers are equal.

◆ Get()

template<class DataType >
DataType* Murl::SharedPointer< DataType >::Get ( ) const
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()

template<class DataType >
template<class RawType >
static SharedPointer<DataType> Murl::SharedPointer< DataType >::DynamicCast ( const SharedPointer< RawType > &  source)
inlinestatic

Create a SharedPointer from a SharedPointer of different type using the dynamic_cast for transfering the memory pointer.

Parameters
sourceThe SharedPointer to cast the memory from.
Returns
A SmartPointer containing the source memory pointer with own type.

◆ StaticCast()

template<class DataType >
template<class RawType >
static SharedPointer<DataType> Murl::SharedPointer< DataType >::StaticCast ( const SharedPointer< RawType > &  source)
inlinestatic

Create a SharedPointer from a SharedPointer of different type using the static_cast for transfering the memory pointer.

Parameters
sourceThe SharedPointer to cast the memory from.
Returns
A SmartPointer containing the source memory pointer with own type.

◆ ConstCast()

template<class DataType >
template<class RawType >
static SharedPointer<DataType> Murl::SharedPointer< DataType >::ConstCast ( const SharedPointer< RawType > &  source)
inlinestatic

Create a SharedPointer from a SharedPointer of different type using the const_cast for transfering the memory pointer.

Parameters
sourceThe 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


Copyright © 2011-2024 Spraylight GmbH.