00001 #ifndef CLOCK_H
00002 #define CLOCK_H
00003
00004 #include <tools/global.h>
00005
00006 #include <QDateTime>
00007 #include <QMultiMap>
00008 #include <QTimer>
00009
00010 namespace domain
00011 {
00012
00013 class StorableData;
00014
00022 class DOMAIN_EXPORT Clock : public QObject
00023 {
00024 Q_OBJECT
00025
00026 public:
00027
00032 Clock();
00033
00037 const QDateTime& time() const;
00038
00046 void setTime(const QDateTime& time);
00047
00053 void addEvent(const QDateTime& time, StorableData* data);
00054
00058 void removeEvents(StorableData* data);
00059
00066 void setTicking(bool enable);
00067
00073 bool isTicking() const;
00074
00080 static QDateTime currentTime();
00081
00087 static void newEvent(const QDateTime& time, StorableData* data);
00088
00094 static void deleteEvents(StorableData* data);
00095
00096 Q_SIGNALS:
00097
00103 void timeChanged(const QDateTime& newTime);
00104
00105 private Q_SLOTS:
00106
00110 void tick();
00111
00112 private:
00113
00114 QDateTime m_time;
00115 QMultiMap<QDateTime, StorableData*> m_events;
00116 QTimer m_timer;
00117 };
00118
00119 }
00120
00121 #endif