libusermetrics: libusermetricsinput/Metric.h Source File

libusermetrics

Metric.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of version 3 of the GNU Lesser General Public License as published
6 * by the Free Software Foundation.
7 *
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 * 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 * Author: Pete Woods <pete.woods@canonical.com>
17 */
18
19 #ifndef USERMETRICSINPUT_METRIC_H_
20 #define USERMETRICSINPUT_METRIC_H_
21
22 #include <libusermetricsinput/MetricUpdate.h>
23 #include <QtCore/QSharedPointer>
24
29 namespace UserMetricsInput {
30
31 class Metric;
32
36 typedef QSharedPointer<Metric> MetricPtr;
37
38 enum MetricType {
39 USER, SYSTEM,
40 };
41
50 class Q_DECL_EXPORT Metric: public QObject {
51 public:
55 explicit Metric(QObject *parent = 0);
56
60 virtual ~Metric();
61
71 virtual MetricUpdate * update(const QString &username = "") = 0;
72
80 virtual void update(double value, const QString &username = "") = 0;
81
89 virtual void increment(double amount = 1.0f,
90 const QString &username = "") = 0;
91 };
92
93 }
94
99 #endif // USERMETRICSINPUT_METRIC_H_
UserMetricsInput
The user metrics input library namespace.
Definition: Metric.h:29
UserMetricsInput::Metric::Metric
Metric(QObject *parent=0)
This constructor cannot be used - the class is pure-virtual.
UserMetricsInput::Metric::update
virtual void update(double value, const QString &username="")=0
Update the "today" value for a simple user metric.
UserMetricsInput::MetricType
MetricType
Definition: Metric.h:38
UserMetricsInput::Metric::~Metric
virtual ~Metric()
Destructor.
UserMetricsInput::Metric::update
virtual MetricUpdate * update(const QString &username="")=0
Create an MetricUpdate to a particular Metric.
UserMetricsInput::USER
@ USER
Definition: Metric.h:39
MetricUpdate.h
UserMetricsInput::MetricUpdate
An update to a Metric.
Definition: MetricUpdate.h:44
UserMetricsInput::MetricPtr
QSharedPointer< Metric > MetricPtr
Definition: Metric.h:31
UserMetricsInput::Metric
This class represents a single user metric.
Definition: Metric.h:50
UserMetricsInput::Metric::increment
virtual void increment(double amount=1.0f, const QString &username="")=0
Increment the "today" value for a simple user metric.
UserMetricsInput::SYSTEM
@ SYSTEM
Definition: Metric.h:39