libusermetrics

usermetricsinput.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 /*
20 * This file defines the C API of libusermetricsinput. If you can, it is strongly
21 * recommended to use the C++ API, MetricManager.h instead.
22 */
23
24 #ifndef USERMETRICSINPUT_H_
25 #define USERMETRICSINPUT_H_
26
27 #ifdef USERMETRICSINPUT_METRICUPDATE_H_
28 #error "Mixing C and C++ public header includes. You can only use one or the other."
29 #endif
30
31 #include <libusermetricsinput/UserMetricsInputExport.h>
32
33 #ifdef __cplusplus
34
37 extern "C" {
38 #endif
39
40 enum USERMETRICSINPUT_METRICTYPE {
41 METRIC_TYPE_USER, METRIC_TYPE_SYSTEM
42 };
43
47 typedef void* UserMetricsInputMetricManager;
48
52 typedef void* UserMetricsInputMetricParameters;
53
57 typedef void* UserMetricsInputMetric;
58
62 typedef void* UserMetricsInputMetricUpdate;
63
69 USERMETRICSINPUT_EXPORT
70 UserMetricsInputMetricManager usermetricsinput_metricmanager_new();
71 USERMETRICSINPUT_EXPORT
77 void usermetricsinput_metricmanager_delete(
78 UserMetricsInputMetricManager metricManager);
86 USERMETRICSINPUT_EXPORT
87 UserMetricsInputMetricParameters usermetricsinput_metricparameters_new(
88 const char *dataSourceId);
89
96 USERMETRICSINPUT_EXPORT
97 void usermetricsinput_metricparameters_set_format_string(
98 UserMetricsInputMetricParameters metricParameter,
99 const char *formatString);
100
107 USERMETRICSINPUT_EXPORT
108 void usermetricsinput_metricparameters_set_empty_data_string(
109 UserMetricsInputMetricParameters metricParameter,
110 const char *emptyDataString);
111
118 USERMETRICSINPUT_EXPORT
119 void usermetricsinput_metricparameters_set_text_domain(
120 UserMetricsInputMetricParameters metricParameter,
121 const char *textDomain);
122
129 USERMETRICSINPUT_EXPORT
130 void usermetricsinput_metricparameters_set_minimum(
131 UserMetricsInputMetricParameters metricParameter, double minimum);
132
139 USERMETRICSINPUT_EXPORT
140 void usermetricsinput_metricparameters_set_maximum(
141 UserMetricsInputMetricParameters metricParameter, double maximum);
142
149 USERMETRICSINPUT_EXPORT
150 void usermetricsinput_metricparameters_set_type(
151 UserMetricsInputMetricParameters metricParameter,
152 USERMETRICSINPUT_METRICTYPE metricType);
153
159 USERMETRICSINPUT_EXPORT
160 void usermetricsinput_metricparameters_delete(
161 UserMetricsInputMetricParameters metricParameters);
162
171 USERMETRICSINPUT_EXPORT
172 UserMetricsInputMetric usermetricsinput_metricmanager_add(
173 UserMetricsInputMetricManager metricManager,
174 UserMetricsInputMetricParameters metricParameters);
175
183 USERMETRICSINPUT_EXPORT
184 void usermetricsinput_metric_increment(UserMetricsInputMetric metric,
185 double amount, const char *username);
186
194 USERMETRICSINPUT_EXPORT
195 void usermetricsinput_metric_update_today(UserMetricsInputMetric metric,
196 double value, const char *username);
206 USERMETRICSINPUT_EXPORT
207 UserMetricsInputMetricUpdate usermetricsinput_metric_update(
208 UserMetricsInputMetric metric, const char *username);
209
217 USERMETRICSINPUT_EXPORT
218 void usermetricsinput_metricupdate_delete(
219 UserMetricsInputMetricUpdate metricUpdate);
220
231 USERMETRICSINPUT_EXPORT
232 void usermetricsinput_metricupdate_add_data(
233 UserMetricsInputMetricUpdate metricUpdate, double data);
234
242 USERMETRICSINPUT_EXPORT
243 void usermetricsinput_metricupdate_add_null(
244 UserMetricsInputMetricUpdate metricUpdate);
245
269 #ifdef __cplusplus
270 }
274 #endif
275
276 #endif
UserMetricsInputMetricUpdate
void * UserMetricsInputMetricUpdate
A update to a user metric for a particular user.
Definition: usermetricsinput.h:62
usermetricsinput_metricparameters_set_minimum
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_minimum(UserMetricsInputMetricParameters metricParameter, double minimum)
Set the minimum display value for this metric.
usermetricsinput_metric_update_today
USERMETRICSINPUT_EXPORT void usermetricsinput_metric_update_today(UserMetricsInputMetric metric, double value, const char *username)
Update the "today" value for a simple user metric.
usermetricsinput_metric_update
USERMETRICSINPUT_EXPORT UserMetricsInputMetricUpdate usermetricsinput_metric_update(UserMetricsInputMetric metric, const char *username)
Create an update to a particular metric.
usermetricsinput_metricparameters_delete
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_delete(UserMetricsInputMetricParameters metricParameters)
Free a UserMetricsInputMetricParameters.
UserMetricsInputMetricParameters
void * UserMetricsInputMetricParameters
Parameters for constructing a metric.
Definition: usermetricsinput.h:52
UserMetricsInputMetricManager
void * UserMetricsInputMetricManager
A central place for registering user metrics.
Definition: usermetricsinput.h:47
USERMETRICSINPUT_METRICTYPE
USERMETRICSINPUT_METRICTYPE
Definition: usermetricsinput.h:40
usermetricsinput_metricparameters_set_text_domain
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_text_domain(UserMetricsInputMetricParameters metricParameter, const char *textDomain)
Set the translation domain.
usermetricsinput_metricparameters_set_type
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_type(UserMetricsInputMetricParameters metricParameter, USERMETRICSINPUT_METRICTYPE metricType)
Set the type of metric this is (user owned or system owned)
UserMetricsInputMetric
void * UserMetricsInputMetric
A single user metric, e.g. "number of e-mails today" or "photos taken today".
Definition: usermetricsinput.h:57
UserMetricsInputExport.h
usermetricsinput_metricupdate_add_null
USERMETRICSINPUT_EXPORT void usermetricsinput_metricupdate_add_null(UserMetricsInputMetricUpdate metricUpdate)
Add unknown data to an update.
usermetricsinput_metricparameters_set_maximum
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_maximum(UserMetricsInputMetricParameters metricParameter, double maximum)
Set the maximum display value for this metric.
USERMETRICSINPUT_EXPORT
#define USERMETRICSINPUT_EXPORT
Definition: UserMetricsInputExport.h:15
usermetricsinput_metricmanager_delete
USERMETRICSINPUT_EXPORT void usermetricsinput_metricmanager_delete(UserMetricsInputMetricManager metricManager)
Free a UserMetricsInputMetricManager.
usermetricsinput_metricupdate_delete
USERMETRICSINPUT_EXPORT void usermetricsinput_metricupdate_delete(UserMetricsInputMetricUpdate metricUpdate)
Free a UserMetricsInputMetric.
METRIC_TYPE_SYSTEM
@ METRIC_TYPE_SYSTEM
Definition: usermetricsinput.h:41
usermetricsinput_metricparameters_new
USERMETRICSINPUT_EXPORT UserMetricsInputMetricParameters usermetricsinput_metricparameters_new(const char *dataSourceId)
Construct a new UserMetricsInputMetricParameters.
usermetricsinput_metricmanager_add
USERMETRICSINPUT_EXPORT UserMetricsInputMetric usermetricsinput_metricmanager_add(UserMetricsInputMetricManager metricManager, UserMetricsInputMetricParameters metricParameters)
Register a new UserMetricsInputMetric.
METRIC_TYPE_USER
@ METRIC_TYPE_USER
Definition: usermetricsinput.h:41
usermetricsinput_metricupdate_add_data
USERMETRICSINPUT_EXPORT void usermetricsinput_metricupdate_add_data(UserMetricsInputMetricUpdate metricUpdate, double data)
Add data to a UserMetricsInputMetricUpdate.
usermetricsinput_metricmanager_new
USERMETRICSINPUT_EXPORT UserMetricsInputMetricManager usermetricsinput_metricmanager_new()
Construct a new UserMetricsInputMetricManager.
usermetricsinput_metricparameters_set_format_string
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_format_string(UserMetricsInputMetricParameters metricParameter, const char *formatString)
Set the string to print in the output API, e.g. "<b>%1</b> messages received today".
usermetricsinput_metricparameters_set_empty_data_string
USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_empty_data_string(UserMetricsInputMetricParameters metricParameter, const char *emptyDataString)
set the string to print in the case of no data, e.g. "No messages received today"
usermetricsinput_metric_increment
USERMETRICSINPUT_EXPORT void usermetricsinput_metric_increment(UserMetricsInputMetric metric, double amount, const char *username)
Increment the "today" value for a simple user metric.