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