Audacity 3.2.0
|
An object that sends messages to an open-ended list of subscribed callbacks. More...
#include <Observer.h>
Inherited by CompressorInstance, CompressorInstance, and DeviceManager.
Classes | |
struct | Record |
Public Types | |
using | message_type = Message |
using | CallbackReturn = std::conditional_t< NotifyAll, void, bool > |
using | Callback = std::function< CallbackReturn(const Message &) > |
Type of functions that can be connected to the Publisher. More... | |
Public Member Functions | |
template<typename Alloc = std::allocator<Record>> | |
Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={}) | |
Constructor supporting type-erased custom allocation/deletion. More... | |
Publisher (Publisher &&)=default | |
Publisher & | operator= (Publisher &&)=default |
Subscription | Subscribe (Callback callback) |
Connect a callback to the Publisher; later-connected are called earlier. More... | |
template<typename Object , typename Return , typename... Args> | |
Subscription | Subscribe (Object &obj, Return(Object::*callback)(Args...)) |
Overload of Subscribe takes an object and pointer-to-member-function. More... | |
Static Public Attributes | |
static constexpr bool | notifies_all = NotifyAll |
Protected Member Functions | |
CallbackReturn | Publish (const Message &message) |
Send a message to connected callbacks. More... | |
Private Attributes | |
std::shared_ptr< detail::RecordList > | m_list |
std::function< std::shared_ptr< detail::RecordBase >(Callback)> | m_factory |
An object that sends messages to an open-ended list of subscribed callbacks.
Intended for single-threaded use only. Move-only; allows type-erased custom allocation.
Message | the type of message |
NotifyAll | if true, callback return values are ignored; else, a callback returning true causes earlier subscribed callbacks to be skipped |
Definition at line 108 of file Observer.h.
using Observer::Publisher< Message, NotifyAll >::Callback = std::function< CallbackReturn(const Message&) > |
Type of functions that can be connected to the Publisher.
Definition at line 130 of file Observer.h.
using Observer::Publisher< Message, NotifyAll >::CallbackReturn = std::conditional_t<NotifyAll, void, bool> |
Definition at line 127 of file Observer.h.
using Observer::Publisher< Message, NotifyAll >::message_type = Message |
Definition at line 114 of file Observer.h.
|
inlineexplicit |
Constructor supporting type-erased custom allocation/deletion.
pPolicy | if null, exceptions from callbacks are caught and ignored; else, *pPolicy must have a lifetime encompassing the Publisher's |
Definition at line 176 of file Observer.h.
|
default |
|
default |
|
inlineprotected |
Send a message to connected callbacks.
Later-connected are called earlier; if !NotifyAll, any callback may return true, to stop the notification; see also class ExceptionPolicy
NotifyAll
, then void; else, whether the visit was stopped (either because a callback returned true, or the exception policy consumed an exception, and ordered a stop) Definition at line 207 of file Observer.h.
Referenced by AColor::ApplyUpdatedImages(), PrefsListener::Broadcast(), AppEvents::ProviderBase::HandleAppIdle(), WaveClip::OnProjectTempoChange(), CompressorInstance::RealtimeFinalize(), CompressorInstance::RealtimeInitialize(), CompressorInstance::RealtimeResume(), DeviceManager::Rescan(), WaveClip::SetCentShift(), WaveClip::SetPitchAndSpeedPreset(), WaveClip::StretchBy(), WaveClip::StretchLeftTo(), and WaveClip::~WaveClip().
auto Observer::Publisher< Message, NotifyAll >::Subscribe | ( | Callback | callback | ) |
Connect a callback to the Publisher; later-connected are called earlier.
During Publish(), the callback may have the side-effect of adding or removing other Subscriptions. Added subscriptions will not be called, and removed ones, if not called already, will not be called after.
callback != nullptr
Definition at line 199 of file Observer.h.
Referenced by AdornedRulerPanel::AdornedRulerPanel(), AudioSetupToolBar::AudioSetupToolBar(), LabelTrackView::BindTo(), ToolManager::CreateWindows(), DeviceToolBar::DeviceToolBar(), anonymous_namespace{DropoutDetector.cpp}::DropoutSubscription::DropoutSubscription(), anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::EffectsMenuHelper(), HistoryDialog::HistoryDialog(), PrefsListener::Impl::Impl(), DefaultPlaybackPolicy::Initialize(), EffectUIHost::InitializeInstance(), LoginDialog::LoginDialog(), MixerBoard::MixerBoard(), AppEvents::OnAppIdle(), AudacityApp::OnInit(), WaveTrackControls::PanSlider(), PlayIndicatorOverlay::PlayIndicatorOverlay(), TimeToolBar::Populate(), ProjectAudioManager::ProjectAudioManager(), ProjectManager::ProjectManager(), ProjectWindow::ProjectWindow(), RealtimeEffectPanel::RealtimeEffectPanel(), ScrubbingOverlay::ScrubbingOverlay(), SpectralSelectionBar::SpectralSelectionBar(), SqliteSampleBlockFactory::SqliteSampleBlockFactory(), TimeDisplayModeSetting::Subscribe(), anonymous_namespace{ProjectStatus.cpp}::Dispatcher::Subscribe(), FrameStatistics::Subscribe(), ThemedAButtonWrapper< AButtonBase >::ThemedAButtonWrapper(), ThemedButtonWrapper< ButtonBase >::ThemedButtonWrapper(), ThemedWindowWrapper< WindowBase >::ThemedWindowWrapper(), SelectHandle::TimerHandler::TimerHandler(), TimeToolBar::TimeToolBar(), ToolsToolBar::ToolsToolBar(), TrackPanel::TrackPanel(), anonymous_namespace{ChannelView.cpp}::TrackPositioner::TrackPositioner(), NoteTrackControls::VelocitySlider(), WaveTrackControls::VolumeSlider(), and WaveTrackAffordanceControls::WaveTrackAffordanceControls().
|
inline |
Overload of Subscribe takes an object and pointer-to-member-function.
Definition at line 144 of file Observer.h.
|
private |
Definition at line 171 of file Observer.h.
|
private |
Definition at line 170 of file Observer.h.
|
staticconstexpr |
Definition at line 113 of file Observer.h.