MythTV
master
|
Superclass for making an object have a set of listeners. More...
#include <libmythbase/mythobservable.h>
Public Member Functions | |
MythObservable () | |
virtual | ~MythObservable () |
void | addListener (QObject *listener) |
Add a listener to the observable. More... | |
void | removeListener (QObject *listener) |
Remove a listener to the observable. More... | |
void | dispatch (const MythEvent &event) |
Dispatch an event to all listeners. More... | |
bool | hasListeners (void) |
Protected Attributes | |
QMutex * | m_lock {nullptr} |
QSet< QObject * > | m_listeners |
Superclass for making an object have a set of listeners.
This superclass provides the basic API for adding and removing listeners and iterating across them. It is typically used to post events to listening QObjects.
MythEvents can be dispatched to all listeners by calling dispatch
The name MythObservable is 'wrong', since all the methods refer to the observers as listeners (ie. addListener), however, MythListenable just doesn't sound right, and fixing all the calls to addListener was too big a patch.
Definition at line 11 of file mythobservable.h.
|
inline |
Definition at line 14 of file mythobservable.h.
|
virtual |
Definition at line 22 of file mythobservable.cpp.
void MythObservable::addListener | ( | QObject * | listener | ) |
Add a listener to the observable.
Adds the given QObject to the list of objects that observe this observable.
listener | the QObject that will listen to this observable |
Definition at line 38 of file mythobservable.cpp.
Referenced by MusicPlayer::addListener(), SSDP::AddListener(), MusicPlayer::addVisual(), AutoExpire::AutoExpire(), BackendConnectionManager::BackendConnectionManager(), BrowserApi::BrowserApi(), ChannelRecPriority::ChannelRecPriority(), ZMMiniPlayer::Create(), PrevRecordedList::Create(), ProgLister::Create(), CustomEdit::CustomEdit(), CustomEventRelayer::CustomEventRelayer(), CustomPriority::CustomPriority(), MusicPlayer::decoderHandlerReady(), EditAlbumartDialog::EditAlbumartDialog(), EditMetadataDialog::EditMetadataDialog(), LyricsData::findLyrics(), IdleScreen::IdleScreen(), ProgFinder::Init(), MediaServer::Init(), PrevRecordedList::Init(), GuideGrid::Init(), TV::InitFromDB(), JobQueue::JobQueue(), LCDProcClient::LCDProcClient(), LyricsView::LyricsView(), MainServer::MainServer(), MessageHandler::MessageHandler(), MusicPlayer::MusicPlayer(), MythMainWindow::MythMainWindow(), MythSystemEventHandler::MythSystemEventHandler(), MythWebSocketEvent::MythWebSocketEvent(), NetBase::NetBase(), NetworkControl::NetworkControl(), MusicPlayer::openOutputDevice(), PlaybackBox::PlaybackBox(), PlaylistEditorView::PlaylistEditorView(), PreviewGenerator::RemotePreviewRun(), MusicPlayer::setupDecoderHandler(), GalleryThumbView::Start(), GallerySlideView::Start(), UPNPScanner::Start(), HouseKeeper::Start(), ThemeChooser::ThemeChooser(), VideoSetupWizard::VideoSetupWizard(), ViewScheduled::ViewScheduled(), WebSocketMythEvent::WebSocketMythEvent(), WelcomeDialog::WelcomeDialog(), and ZMClient::ZMClient().
void MythObservable::removeListener | ( | QObject * | listener | ) |
Remove a listener to the observable.
Remove the given QObject from the list of objects that observe this observable.
listener | the QObject that already listens to this observable |
Definition at line 55 of file mythobservable.cpp.
Referenced by GallerySlideView::Close(), GalleryThumbView::Close(), LyricsData::customEvent(), CustomEventRelayer::deleteLater(), PreviewGenerator::RemotePreviewRun(), MusicPlayer::removeListener(), SSDP::RemoveListener(), MusicPlayer::removeVisual(), UPNPScanner::Stop(), MusicPlayer::stop(), MainServer::Stop(), AutoExpire::~AutoExpire(), BackendConnectionManager::~BackendConnectionManager(), BrowserApi::~BrowserApi(), ChannelRecPriority::~ChannelRecPriority(), CustomEdit::~CustomEdit(), CustomPriority::~CustomPriority(), EditAlbumartDialog::~EditAlbumartDialog(), GuideGrid::~GuideGrid(), HouseKeeper::~HouseKeeper(), IdleScreen::~IdleScreen(), JobQueue::~JobQueue(), LCDProcClient::~LCDProcClient(), LyricsView::~LyricsView(), MediaServer::~MediaServer(), MusicPlayer::~MusicPlayer(), MythMainWindow::~MythMainWindow(), MythSystemEventHandler::~MythSystemEventHandler(), MythWebSocketEvent::~MythWebSocketEvent(), NetBase::~NetBase(), NetworkControl::~NetworkControl(), PlaybackBox::~PlaybackBox(), PlaylistEditorView::~PlaylistEditorView(), PrevRecordedList::~PrevRecordedList(), ProgFinder::~ProgFinder(), ProgLister::~ProgLister(), ThemeChooser::~ThemeChooser(), TV::~TV(), VideoSetupWizard::~VideoSetupWizard(), ViewScheduled::~ViewScheduled(), WebSocketMythEvent::~WebSocketMythEvent(), WelcomeDialog::~WelcomeDialog(), ZMClient::~ZMClient(), and ZMMiniPlayer::~ZMMiniPlayer().
void MythObservable::dispatch | ( | const MythEvent & | event | ) |
Dispatch an event to all listeners.
Makes a copy of the event on the heap by calling MythEvent::clone() and dispatches is by calling QCoreApplication::postEvent().
event | MythEvent to dispatch. |
Definition at line 73 of file mythobservable.cpp.
Referenced by MusicPlayer::activePlaylistChanged(), avfDecoder::checkMetatdata(), AudioOutputJACK::CloseDevice(), DecoderHandler::customEvent(), MusicPlayer::customEvent(), MusicPlayer::decoderHandlerReady(), MythCoreContext::dispatch(), DecoderHandler::doConnectDecoder(), DecoderHandler::doFailed(), DecoderHandler::doOperationStart(), DecoderHandler::doOperationStop(), DecoderHandler::error(), Decoder::error(), OutputListeners::error(), avfDecoder::initialize(), AudioOutputJACK::JackCallback(), SSDPCache::NotifyAdd(), SSDPCache::NotifyRemove(), AudioOutputBase::OutputAudioLoop(), MusicPlayer::playlistChanged(), UPNPSubscription::ProcessRequest(), avfDecoder::run(), CdDecoder::run(), MusicPlayer::sendAlbumArtChangedEvent(), MusicPlayer::sendCDChangedEvent(), MusicPlayer::sendMetadataChangedEvent(), MusicPlayer::sendTrackStatsChangedEvent(), MusicPlayer::sendTrackUnavailableEvent(), MusicPlayer::sendVolumeChangedEvent(), AudioOutputBase::Status(), and MusicPlayer::stop().
|
inline |
Definition at line 23 of file mythobservable.h.
Referenced by MusicPlayer::addListener(), MusicPlayer::hasClient(), and MusicPlayer::removeListener().
|
protected |
Definition at line 29 of file mythobservable.h.
Referenced by addListener(), MusicPlayer::decoderHandlerReady(), dispatch(), MusicPlayer::openOutputDevice(), removeListener(), MusicPlayer::setupDecoderHandler(), MusicPlayer::stop(), and ~MythObservable().
|
protected |
Definition at line 30 of file mythobservable.h.
Referenced by addListener(), MusicPlayer::decoderHandlerReady(), dispatch(), MusicPlayer::openOutputDevice(), removeListener(), MusicPlayer::setupDecoderHandler(), MusicPlayer::stop(), and ~MythObservable().