00001 #ifndef MYTHOBSERVABLE_H_
00002 #define MYTHOBSERVABLE_H_
00003
00004 #include <QSet>
00005 #include "mythevent.h"
00006 #include "mythbaseexp.h"
00007
00008 class QObject;
00009 class QMutex;
00010
00011 class MBASE_PUBLIC MythObservable
00012 {
00013 public:
00014 MythObservable();
00015 virtual ~MythObservable();
00016
00017 void addListener(QObject *listener);
00018 void removeListener(QObject *listener);
00019
00020 void dispatch(const MythEvent &event);
00021
00022 void dispatchNow(const MythEvent &event);
00023
00024 bool hasListeners(void) { return !m_listeners.isEmpty(); }
00025
00026 protected:
00027 QMutex *m_lock;
00028 QSet<QObject*> m_listeners;
00029 };
00030
00031 #endif