Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
anonymous_namespace{EffectUI.cpp}::EffectSettingsAccessTee Class Reference
Inheritance diagram for anonymous_namespace{EffectUI.cpp}::EffectSettingsAccessTee:
[legend]
Collaboration diagram for anonymous_namespace{EffectUI.cpp}::EffectSettingsAccessTee:
[legend]

Public Member Functions

 EffectSettingsAccessTee (EffectSettingsAccess &main, const std::shared_ptr< EffectSettingsAccess > &pSide={})
 
const EffectSettingsGet () override
 
void Set (EffectSettings &&settings, std::unique_ptr< Message > pMessage) override
 
void Set (std::unique_ptr< Message > pMessage) override
 Message-only overload of Set(). In future, this should be the only one. More...
 
void Flush () override
 Make the last Set changes "persistent" in underlying storage. More...
 
bool IsSameAs (const EffectSettingsAccess &other) const override
 
- Public Member Functions inherited from EffectSettingsAccess
virtual ~EffectSettingsAccess ()
 
virtual const EffectSettingsGet ()=0
 
virtual void Set (EffectSettings &&settings, std::unique_ptr< Message > pMessage=nullptr)=0
 
virtual void Set (std::unique_ptr< Message > pMessage=nullptr)=0
 Message-only overload of Set(). In future, this should be the only one. More...
 
virtual void Flush ()=0
 Make the last Set changes "persistent" in underlying storage. More...
 
virtual bool IsSameAs (const EffectSettingsAccess &other) const =0
 
template<typename Function >
void ModifySettings (Function &&function)
 Do a correct read-modify-write of settings. More...
 

Private Attributes

const std::shared_ptr< EffectSettingsAccessmpMain
 
const std::weak_ptr< EffectSettingsAccessmwSide
 

Detailed Description

Decorate an EffectSettingsAccess with a Set that replicates changes into a second EffectSettingsAccess, while that one still exists

Name inspired by man 1 tee

Definition at line 166 of file EffectUI.cpp.

Constructor & Destructor Documentation

◆ EffectSettingsAccessTee()

EffectSettingsAccessTee::EffectSettingsAccessTee ( EffectSettingsAccess main,
const std::shared_ptr< EffectSettingsAccess > &  pSide = {} 
)

Definition at line 183 of file EffectUI.cpp.

186 : mpMain{ main.shared_from_this() }
187 , mwSide{ pSide }
188{
189}
int main(int argc, char *argv[])
const std::weak_ptr< EffectSettingsAccess > mwSide
Definition: EffectUI.cpp:179
const std::shared_ptr< EffectSettingsAccess > mpMain
Definition: EffectUI.cpp:178

Member Function Documentation

◆ Flush()

void EffectSettingsAccessTee::Flush ( )
overridevirtual

Make the last Set changes "persistent" in underlying storage.

Precondition
called on the main thread only

Implements EffectSettingsAccess.

Definition at line 215 of file EffectUI.cpp.

216{
217 mpMain->Flush();
218 if (auto pSide = mwSide.lock())
219 pSide->Flush();
220}

References mpMain, and mwSide.

◆ Get()

const EffectSettings & EffectSettingsAccessTee::Get ( )
overridevirtual

Implements EffectSettingsAccess.

Definition at line 191 of file EffectUI.cpp.

191 {
192 return mpMain->Get();
193}

References mpMain.

◆ IsSameAs()

bool EffectSettingsAccessTee::IsSameAs ( const EffectSettingsAccess other) const
overridevirtual
Returns
whether this and the other give access to the same settings

Implements EffectSettingsAccess.

Definition at line 222 of file EffectUI.cpp.

224{
225 return mpMain->IsSameAs(other);
226}

References mpMain.

◆ Set() [1/2]

void anonymous_namespace{EffectUI.cpp}::EffectSettingsAccessTee::Set ( EffectSettings &&  settings,
std::unique_ptr< Message pMessage 
)
overridevirtual

Implements EffectSettingsAccess.

◆ Set() [2/2]

void anonymous_namespace{EffectUI.cpp}::EffectSettingsAccessTee::Set ( std::unique_ptr< Message pMessage)
overridevirtual

Message-only overload of Set(). In future, this should be the only one.

Implements EffectSettingsAccess.

Member Data Documentation

◆ mpMain

const std::shared_ptr<EffectSettingsAccess> anonymous_namespace{EffectUI.cpp}::EffectSettingsAccessTee::mpMain
private
Invariant
not null

Definition at line 178 of file EffectUI.cpp.

Referenced by Flush(), Get(), and IsSameAs().

◆ mwSide

const std::weak_ptr<EffectSettingsAccess> anonymous_namespace{EffectUI.cpp}::EffectSettingsAccessTee::mwSide
private

Definition at line 179 of file EffectUI.cpp.

Referenced by Flush().


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