on a142f21 help sign in
unity8/libs/UbuntuGestures/TimeSource.h
64 lines 1.9 kB history raw
1/*
2 * Copyright (C) 2013,2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, as
6 * published by the Free Software Foundation; either version 2.1 or 3.0
7 * of the License.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranties of
11 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the applicable version of the GNU Lesser General Public
13 * License for more details.
14 *
15 * You should have received a copy of both the GNU Lesser General Public
16 * License along with this program. If not, see <http://www.gnu.org/licenses/>
17 *
18 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
19 */
21#ifndef UBUNTUGESTURES_TIMESOURCE_H
22#define UBUNTUGESTURES_TIMESOURCE_H
24#include "UbuntuGesturesGlobal.h"
25#include <QSharedPointer>
27namespace UbuntuGestures {
28/*
29 Interface for a time source.
30 */
31class UBUNTUGESTURES_EXPORT TimeSource {
32public:
33 virtual ~TimeSource() {}
34 /* Returns the current time in milliseconds since some reference time in the past. */
35 virtual qint64 msecsSinceReference() = 0;
36};
37typedef QSharedPointer<TimeSource> SharedTimeSource;
39/*
40 Implementation of a time source
41 */
42class RealTimeSourcePrivate;
43class UBUNTUGESTURES_EXPORT RealTimeSource : public TimeSource {
44public:
45 RealTimeSource();
46 virtual ~RealTimeSource();
47 qint64 msecsSinceReference() override;
48private:
49 RealTimeSourcePrivate *d;
50};
52/*
53 A fake time source, useful for tests
54 */
55class FakeTimeSource : public TimeSource {
56public:
57 FakeTimeSource() { m_msecsSinceReference = 0; }
58 qint64 msecsSinceReference() override { return m_msecsSinceReference; }
59 qint64 m_msecsSinceReference;
60};
62} // namespace UbuntuGestures
64#endif // UBUNTUGESTURES_TIMESOURCE_H