2
* Copyright 2015 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
19
#ifndef UBUNTUGESTURES_TIMESOURCE_H
20
#define UBUNTUGESTURES_TIMESOURCE_H
22
#include "ubuntugesturesglobal.h"
23
#include <QSharedPointer>
25
namespace UbuntuGestures {
27
Interface for a time source.
29
class UBUNTUGESTURES_EXPORT TimeSource {
31
virtual ~TimeSource() {}
32
/* Returns the current time in milliseconds since some reference time in the past. */
33
virtual qint64 msecsSinceReference() = 0;
35
typedef QSharedPointer<TimeSource> SharedTimeSource;
38
Implementation of a time source
40
class RealTimeSourcePrivate;
41
class UBUNTUGESTURES_EXPORT RealTimeSource : public TimeSource {
44
virtual ~RealTimeSource();
45
qint64 msecsSinceReference() override;
47
RealTimeSourcePrivate *d;
51
A fake time source, useful for tests
53
class FakeTimeSource : public TimeSource {
55
FakeTimeSource() { m_msecsSinceReference = 0; }
56
qint64 msecsSinceReference() override { return m_msecsSinceReference; }
57
qint64 m_msecsSinceReference;
60
} // namespace UbuntuGestures
62
#endif // UBUNTUGESTURES_TIMESOURCE_H