The Sparta Modeling Framework
Loading...
Searching...
No Matches
sparta::SpartaWeakPointer< PointerT > Class Template Reference

Like in STL, create a weak pointer to a SpartaSharedPointer. More...

#include <SpartaSharedPointer.hpp>

Public Member Functions

constexpr SpartaWeakPointer () noexcept=default
 Create an empty, expired weakpointer.
 
 SpartaWeakPointer (const sparta::SpartaSharedPointer< PointerT > &sp) noexcept
 Construct a SpartaWeakPointer with the given SpartaSharedPointer.
 
 ~SpartaWeakPointer ()
 Destroy (and detach) from a SpartaSharedPointer.
 
 SpartaWeakPointer (const SpartaWeakPointer &orig)
 Create a copy of the SpartaWeakPointer.
 
 SpartaWeakPointer (SpartaWeakPointer &&orig)
 Move a SpartaWeakPointer.
 
SpartaWeakPointeroperator= (const SpartaWeakPointer &orig)
 Assign a SpartaWeakPointer from another.
 
SpartaWeakPointeroperator= (SpartaWeakPointer &&orig)
 Move assign a SpartaWeakPointer from another.
 
long use_count () const noexcept
 The use count of the SpartaSharedPointer. Will be 0 if none left.
 
bool expired () const noexcept
 Has the SpartaSharedPointer that this weak pointer points to expired?
 
SpartaSharedPointer< PointerT > lock () const noexcept
 Lock and return a SpartaSharedPointer this SpartaWeakPointer points to.
 

Detailed Description

template<class PointerT>
class sparta::SpartaWeakPointer< PointerT >

Like in STL, create a weak pointer to a SpartaSharedPointer.

Works like the original, just tons faster

Definition at line 407 of file SpartaSharedPointer.hpp.

Constructor & Destructor Documentation

◆ SpartaWeakPointer() [1/3]

template<class PointerT >
sparta::SpartaWeakPointer< PointerT >::SpartaWeakPointer ( const sparta::SpartaSharedPointer< PointerT > &  sp)
inlinenoexcept

Construct a SpartaWeakPointer with the given SpartaSharedPointer.

Parameters
spPointer to the SpartaSharedPointer to "watch"

Definition at line 417 of file SpartaSharedPointer.hpp.

◆ ~SpartaWeakPointer()

template<class PointerT >
sparta::SpartaWeakPointer< PointerT >::~SpartaWeakPointer ( )
inline

Destroy (and detach) from a SpartaSharedPointer.

Definition at line 426 of file SpartaSharedPointer.hpp.

◆ SpartaWeakPointer() [2/3]

template<class PointerT >
sparta::SpartaWeakPointer< PointerT >::SpartaWeakPointer ( const SpartaWeakPointer< PointerT > &  orig)
inline

Create a copy of the SpartaWeakPointer.

Parameters
origThe original to copy. Both are valid

Definition at line 438 of file SpartaSharedPointer.hpp.

◆ SpartaWeakPointer() [3/3]

template<class PointerT >
sparta::SpartaWeakPointer< PointerT >::SpartaWeakPointer ( SpartaWeakPointer< PointerT > &&  orig)
inline

Move a SpartaWeakPointer.

Parameters
origThe original to move. The original is invalidated

Definition at line 450 of file SpartaSharedPointer.hpp.

Member Function Documentation

◆ expired()

template<class PointerT >
bool sparta::SpartaWeakPointer< PointerT >::expired ( ) const
inlinenoexcept

Has the SpartaSharedPointer that this weak pointer points to expired?

Returns
true if no SpartaSharedPointers are still alive

Definition at line 505 of file SpartaSharedPointer.hpp.

◆ lock()

template<class PointerT >
SpartaSharedPointer< PointerT > sparta::SpartaWeakPointer< PointerT >::lock ( ) const
inlinenoexcept

Lock and return a SpartaSharedPointer this SpartaWeakPointer points to.

Returns
nullptr if the SpartaSharedPointer has expired; otherwise a locked version

Definition at line 516 of file SpartaSharedPointer.hpp.

◆ operator=() [1/2]

template<class PointerT >
SpartaWeakPointer & sparta::SpartaWeakPointer< PointerT >::operator= ( const SpartaWeakPointer< PointerT > &  orig)
inline

Assign a SpartaWeakPointer from another.

Parameters
origThe original to copy. The original is valid

Definition at line 460 of file SpartaSharedPointer.hpp.

◆ operator=() [2/2]

template<class PointerT >
SpartaWeakPointer & sparta::SpartaWeakPointer< PointerT >::operator= ( SpartaWeakPointer< PointerT > &&  orig)
inline

Move assign a SpartaWeakPointer from another.

Parameters
origThe original to move. The original is invalidated

Definition at line 478 of file SpartaSharedPointer.hpp.

◆ use_count()

template<class PointerT >
long sparta::SpartaWeakPointer< PointerT >::use_count ( ) const
inlinenoexcept

The use count of the SpartaSharedPointer. Will be 0 if none left.

Returns
The use count (the number of remaining SpartaSharedPointer)

Definition at line 494 of file SpartaSharedPointer.hpp.


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