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 167 of file EffectUI.cpp.

Constructor & Destructor Documentation

◆ EffectSettingsAccessTee()

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

Definition at line 184 of file EffectUI.cpp.

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

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 216 of file EffectUI.cpp.

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

References mpMain, and mwSide.

◆ Get()

const EffectSettings & EffectSettingsAccessTee::Get ( )

Implements EffectSettingsAccess.

Definition at line 192 of file EffectUI.cpp.

192 {
193 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 223 of file EffectUI.cpp.

226 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 179 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 180 of file EffectUI.cpp.

Referenced by Flush().

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