template<typename
Message = Message, bool NotifyAll = true>
class Observer::Publisher< Message, NotifyAll >
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.
- Template Parameters
-
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.
template<typename
Message , bool NotifyAll>
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
- Returns
- if
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.
209{
210 bool result =
m_list->Visit(&message);
211 if constexpr (!NotifyAll)
212 return result;
213}
Referenced by AColor::ApplyUpdatedImages(), PrefsListener::Broadcast(), and DeviceManager::Rescan().
template<typename
Message , bool NotifyAll>
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.
- Precondition
callback != nullptr
Definition at line 199 of file Observer.h.
201{
202 assert(callback);
204}
Referenced by AdornedRulerPanel::AdornedRulerPanel(), DeviceToolBar::DeviceToolBar(), WaveTrackControls::GainSlider(), ViewActions::Handler::Handler(), HistoryDialog::HistoryDialog(), PrefsListener::Impl::Impl(), NewDefaultPlaybackPolicy::Initialize(), EffectUIHost::InitializeRealtime(), LyricsPanel::LyricsPanel(), MenuManager::MenuManager(), MixerBoard::MixerBoard(), AudacityApp::OnInit(), WaveTrackControls::PanSlider(), PlayIndicatorOverlay::PlayIndicatorOverlay(), MixerToolBar::Populate(), ProjectManager::ProjectManager(), ProjectWindow::ProjectWindow(), ScrubbingOverlay::ScrubbingOverlay(), SqliteSampleBlockFactory::SqliteSampleBlockFactory(), ThemedButtonWrapper< ButtonBase >::ThemedButtonWrapper(), ThemedWindowWrapper< WindowBase >::ThemedWindowWrapper(), SelectHandle::TimerHandler::TimerHandler(), TimeToolBar::TimeToolBar(), TrackPanel::TrackPanel(), and anonymous_namespace{TrackView.cpp}::TrackPositioner::TrackPositioner().