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:
Collaboration diagram for anonymous_namespace{EffectUI.cpp}::EffectSettingsAccessTee:

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 }
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 ( )

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

called on the main thread only

Implements EffectSettingsAccess.

Definition at line 215 of file EffectUI.cpp.

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

References mpMain, and mwSide.

◆ Get()

const EffectSettings & EffectSettingsAccessTee::Get ( )

Implements EffectSettingsAccess.

Definition at line 191 of file EffectUI.cpp.

191 {
192 return mpMain->Get();

References mpMain.

◆ IsSameAs()

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

Implements EffectSettingsAccess.

Definition at line 222 of file EffectUI.cpp.

225 return mpMain->IsSameAs(other);

References mpMain.

◆ Set() [1/2]

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

Implements EffectSettingsAccess.

◆ Set() [2/2]

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

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
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

Definition at line 179 of file EffectUI.cpp.

Referenced by Flush().

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