~faenil/ubuntu-ui-toolkit/flickableBasedScrollView

« back to all changes in this revision

Viewing changes to src/Ubuntu/UbuntuGestures/timesource.h

  • Committer: Andrea Bernabei
  • Date: 2015-11-25 11:50:10 UTC
  • mfrom: (1681.2.44 staging)
  • Revision ID: andrea.bernabei@canonical.com-20151125115010-vpxkm2lze1hav9q9
mergeĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2015 Canonical Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
 
17
 */
 
18
 
 
19
#ifndef UBUNTUGESTURES_TIMESOURCE_H
 
20
#define UBUNTUGESTURES_TIMESOURCE_H
 
21
 
 
22
#include "ubuntugesturesglobal.h"
 
23
#include <QSharedPointer>
 
24
 
 
25
namespace UbuntuGestures {
 
26
/*
 
27
    Interface for a time source.
 
28
 */
 
29
class UBUNTUGESTURES_EXPORT TimeSource {
 
30
public:
 
31
    virtual ~TimeSource() {}
 
32
    /* Returns the current time in milliseconds since some reference time in the past. */
 
33
    virtual qint64 msecsSinceReference() = 0;
 
34
};
 
35
typedef QSharedPointer<TimeSource> SharedTimeSource;
 
36
 
 
37
/*
 
38
    Implementation of a time source
 
39
 */
 
40
class RealTimeSourcePrivate;
 
41
class UBUNTUGESTURES_EXPORT RealTimeSource : public TimeSource {
 
42
public:
 
43
    RealTimeSource();
 
44
    virtual ~RealTimeSource();
 
45
    qint64 msecsSinceReference() override;
 
46
private:
 
47
    RealTimeSourcePrivate *d;
 
48
};
 
49
 
 
50
/*
 
51
    A fake time source, useful for tests
 
52
 */
 
53
class FakeTimeSource : public TimeSource {
 
54
public:
 
55
    FakeTimeSource() { m_msecsSinceReference = 0; }
 
56
    qint64 msecsSinceReference() override { return m_msecsSinceReference; }
 
57
    qint64 m_msecsSinceReference;
 
58
};
 
59
 
 
60
} // namespace UbuntuGestures
 
61
 
 
62
#endif // UBUNTUGESTURES_TIMESOURCE_H