Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Observer::Subscription Class Reference

A move-only handle representing a connection to a Publisher. More...

#include <Observer.h>

Collaboration diagram for Observer::Subscription:
[legend]

Public Member Functions

 Subscription ()
 
 Subscription (Subscription &&)
 
Subscriptionoperator= (Subscription &&)
 
 ~Subscription () noexcept
 Calls Reset. More...
 
void Reset () noexcept
 Breaks the connection (constant time) More...
 
bool Expired () const
 
 operator bool () const
 

Private Member Functions

 Subscription (std::weak_ptr< detail::RecordBase > pRecord)
 

Private Attributes

std::weak_ptr< detail::RecordBasem_wRecord
 

Detailed Description

A move-only handle representing a connection to a Publisher.

Definition at line 70 of file Observer.h.

Constructor & Destructor Documentation

◆ Subscription() [1/3]

Observer::Subscription::Subscription ( )
default

◆ Subscription() [2/3]

Observer::Subscription::Subscription ( Subscription &&  )
default

◆ ~Subscription()

Observer::Subscription::~Subscription ( )
inlinenoexcept

Calls Reset.

Definition at line 77 of file Observer.h.

77{ Reset(); }
void Reset() noexcept
Breaks the connection (constant time)
Definition: Observer.cpp:101

◆ Subscription() [3/3]

Observer::Subscription::Subscription ( std::weak_ptr< detail::RecordBase pRecord)
explicitprivate

Definition at line 86 of file Observer.cpp.

87 : m_wRecord{ move(pRecord) } {}
std::weak_ptr< detail::RecordBase > m_wRecord
Definition: Observer.h:95

Member Function Documentation

◆ Expired()

bool Observer::Subscription::Expired ( ) const
inline
Returns
true iff there is no connection (Publisher was destroyed, or this was not reassigned since it was last Reset(), default-constructed, or moved from)

Definition at line 87 of file Observer.h.

87{ return m_wRecord.expired(); }

◆ operator bool()

Observer::Subscription::operator bool ( ) const
inlineexplicit
Returns
not expired

Definition at line 90 of file Observer.h.

90{ return !Expired(); }
bool Expired() const
Definition: Observer.h:87

◆ operator=()

Subscription & Observer::Subscription::operator= ( Subscription &&  other)

Definition at line 89 of file Observer.cpp.

90{
91 const bool inequivalent =
92 m_wRecord.owner_before(other.m_wRecord) ||
93 other.m_wRecord.owner_before(m_wRecord);
94 if (inequivalent) {
95 Reset();
96 m_wRecord = move(other.m_wRecord);
97 }
98 return *this;
99}

References m_wRecord, and Reset().

Here is the call graph for this function:

◆ Reset()

void Observer::Subscription::Reset ( )
noexcept

Breaks the connection (constant time)

Definition at line 101 of file Observer.cpp.

102{
103 if (auto pRecord = m_wRecord.lock())
104 pRecord->Unlink();
105 m_wRecord.reset();
106}

References m_wRecord.

Referenced by ExportFilePanel::ChangeFormat(), EffectUIHost::CleanupRealtime(), operator=(), RealtimeEffectListWindow::ResetDelegate(), RealtimeEffectListWindow::SetDelegate(), WaveformAppearance::Subscribe(), and ClipSegment::~ClipSegment().

Here is the caller graph for this function:

Member Data Documentation

◆ m_wRecord

std::weak_ptr<detail::RecordBase> Observer::Subscription::m_wRecord
private

Definition at line 95 of file Observer.h.

Referenced by operator=(), and Reset().


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