Murl::WeakPointer< DataType > Class Template Reference

The WeakPointer class. More...

#include "murl_weak_pointer.h"

Public Types

using ValueType = DataType
 The template parameter value type.
 

Public Member Functions

 WeakPointer ()
 The default constructor creating a null pointer.
 
template<class RawType >
 WeakPointer (const WeakPointer< RawType > &weakPointer)
 Constructor for automatic downcast. More...
 
template<class RawType >
 WeakPointer (const SharedPointer< RawType > &sharedPointer)
 Constructor taking a SharedPointer. More...
 
SharedPointer< DataType > Lock () const
 Get the SharedPointer from the WeakPointer. More...
 
UInt32 GetCount () const
 Get the SharedPointer's usage counter. More...
 
Bool IsExpired () const
 Check if the SharedPointer is expired. More...
 
void Clear ()
 Release the reference from the WeakPointer and set the memory pointer to null.
 
void Swap (WeakPointer< DataType > &weakPointer)
 Swap with another WeakPointer. More...
 
template<class RawType >
bool operator== (const WeakPointer< RawType > &rhs) const
 Equal to comparison operator. More...
 
template<class RawType >
bool operator!= (const WeakPointer< RawType > &rhs) const
 Not equal to comparison operator. More...
 
template<class RawType >
bool operator< (const WeakPointer< RawType > &rhs) const
 Less than operator. More...
 

Detailed Description

template<class DataType>
class Murl::WeakPointer< DataType >

The WeakPointer class.

The WeakPointer holds a reference to a shared pointer for obtaining temporary Sharedpointer instances by using the Lock() method. If the SharedPointer do no longer exist, the Lock() method returns a SharedPointer object which holds a null pointer.

Constructor & Destructor Documentation

◆ WeakPointer() [1/2]

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

Constructor for automatic downcast.

Parameters
weakPointerThe WeakPointer object.

◆ WeakPointer() [2/2]

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

Constructor taking a SharedPointer.

Parameters
sharedPointerThe SharedPointer object.

Member Function Documentation

◆ Lock()

template<class DataType >
SharedPointer<DataType> Murl::WeakPointer< DataType >::Lock ( ) const
inline

Get the SharedPointer from the WeakPointer.

Returns
The SharedPointer object. The SharedPointer's pointer is null if the SharedPointer is expired.

References Murl::WeakPointer< DataType >::IsExpired().

◆ GetCount()

template<class DataType >
UInt32 Murl::WeakPointer< 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::WeakCounter::GetCount().

◆ IsExpired()

template<class DataType >
Bool Murl::WeakPointer< DataType >::IsExpired ( ) const
inline

Check if the SharedPointer is expired.

Returns
true if the SharedPointer is expired.

References Murl::SharedPointerPrivate::WeakCounter::GetCount().

Referenced by Murl::WeakPointer< DataType >::Lock().

◆ Swap()

template<class DataType >
void Murl::WeakPointer< DataType >::Swap ( WeakPointer< DataType > &  weakPointer)
inline

Swap with another WeakPointer.

Parameters
weakPointerThe WeakPointer to swap with.

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

Referenced by Murl::WeakPointer< DataType >::Clear().

◆ operator==()

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

Equal to comparison operator.

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

◆ operator!=()

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

Not equal to comparison operator.

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

◆ operator<()

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

Less than operator.

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

The documentation for this class was generated from the following files:
  • murl_shared_pointer.h
  • murl_weak_pointer.h


Copyright © 2011-2024 Spraylight GmbH.