TracktionEngine
Public Member Functions | List of all members
tracktion::engine::SafeSelectable< SelectableType > Class Template Reference

Holds a pointer to some type of Selectable, which automatically becomes null if the selectable is deleted. More...

Public Member Functions

 SafeSelectable ()=default
 Creates a null SafeSelectable. More...
 
 SafeSelectable (SelectableType &selectable)
 Creates a SafeSelectable that points at the given selectable. More...
 
 SafeSelectable (const SafeSelectable &other) noexcept
 Creates a copy of another SafeSelectable. More...
 
SafeSelectableoperator= (const SafeSelectable &other)
 Copies another pointer to this one. More...
 
SafeSelectableoperator= (SelectableType *newSelectable)
 Copies another pointer to this one. More...
 
SelectableType * get () const noexcept
 Returns the selectable that this pointer refers to, or null if the selectable no longer exists. More...
 
 operator SelectableType * () const noexcept
 Returns the selectable that this pointer refers to, or null if the selectable no longer exists. More...
 
SelectableType * operator-> () const noexcept
 Returns the selectable that this pointer refers to, or null if the selectable no longer exists. More...
 
bool operator== (SelectableType *selectable) const noexcept
 
bool operator!= (SelectableType *selectable) const noexcept
 

Detailed Description

template<typename SelectableType>
class tracktion::engine::SafeSelectable< SelectableType >

Holds a pointer to some type of Selectable, which automatically becomes null if the selectable is deleted.

The SelectableType template parameter must be Selectable, or some subclass of Selectable.

You may also want to use a juce::WeakReference<Selectable> object for the same purpose.

See also
SelectablegetWeakRef()

Constructor & Destructor Documentation

◆ SafeSelectable() [1/3]

template<typename SelectableType >
tracktion::engine::SafeSelectable< SelectableType >::SafeSelectable ( )
default

Creates a null SafeSelectable.

◆ SafeSelectable() [2/3]

template<typename SelectableType >
tracktion::engine::SafeSelectable< SelectableType >::SafeSelectable ( SelectableType &  selectable)

Creates a SafeSelectable that points at the given selectable.

◆ SafeSelectable() [3/3]

template<typename SelectableType >
tracktion::engine::SafeSelectable< SelectableType >::SafeSelectable ( const SafeSelectable< SelectableType > &  other)
noexcept

Creates a copy of another SafeSelectable.

Member Function Documentation

◆ operator=() [1/2]

template<typename SelectableType >
SafeSelectable& tracktion::engine::SafeSelectable< SelectableType >::operator= ( const SafeSelectable< SelectableType > &  other)

Copies another pointer to this one.

◆ operator=() [2/2]

template<typename SelectableType >
SafeSelectable& tracktion::engine::SafeSelectable< SelectableType >::operator= ( SelectableType *  newSelectable)

Copies another pointer to this one.

◆ get()

template<typename SelectableType >
SelectableType* tracktion::engine::SafeSelectable< SelectableType >::get ( ) const
noexcept

Returns the selectable that this pointer refers to, or null if the selectable no longer exists.

Referenced by tracktion::engine::SafeSelectable< SelectableType >::operator SelectableType *(), and tracktion::engine::SafeSelectable< SelectableType >::operator->().

◆ operator SelectableType *()

template<typename SelectableType >
tracktion::engine::SafeSelectable< SelectableType >::operator SelectableType * ( ) const
noexcept

Returns the selectable that this pointer refers to, or null if the selectable no longer exists.

References tracktion::engine::SafeSelectable< SelectableType >::get().

◆ operator->()

template<typename SelectableType >
SelectableType* tracktion::engine::SafeSelectable< SelectableType >::operator-> ( ) const
noexcept

Returns the selectable that this pointer refers to, or null if the selectable no longer exists.

References tracktion::engine::SafeSelectable< SelectableType >::get().

◆ operator==()

template<typename SelectableType >
bool tracktion::engine::SafeSelectable< SelectableType >::operator== ( SelectableType *  selectable) const
noexcept

◆ operator!=()

template<typename SelectableType >
bool tracktion::engine::SafeSelectable< SelectableType >::operator!= ( SelectableType *  selectable) const
noexcept

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