MythTV  master
mythobservable.h
Go to the documentation of this file.
1 #ifndef MYTHOBSERVABLE_H_
2 #define MYTHOBSERVABLE_H_
3 
4 #include <QSet>
5 #include "mythevent.h"
6 #include "mythbaseexp.h"
7 
8 class QObject;
9 class QMutex;
10 
12 {
13  public:
15  : m_lock(new QMutex()) {}
16  virtual ~MythObservable();
17 
18  void addListener(QObject *listener);
19  void removeListener(QObject *listener);
20 
21  void dispatch(const MythEvent &event);
22 
23  bool hasListeners(void) { return !m_listeners.isEmpty(); }
24 
25  private:
26  Q_DISABLE_COPY(MythObservable)
27 
28  protected:
29  QMutex *m_lock {nullptr};
30  QSet<QObject*> m_listeners;
31 };
32 
33 #endif /* MYTHOBSERVABLE_H */
Superclass for making an object have a set of listeners.
#define MBASE_PUBLIC
Definition: mythbaseexp.h:15
This class is used as a container for messages.
Definition: mythevent.h:16
bool hasListeners(void)
QSet< QObject * > m_listeners