File: MetricManagerAdvanced.cpp

package info (click to toggle)
libusermetrics 1.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,324 kB
  • sloc: cpp: 7,182; xml: 131; sh: 106; ansic: 60; makefile: 26
file content (31 lines) | stat: -rw-r--r-- 918 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <libusermetricsinput/MetricManager.h>
#include <QtCore/QCoreApplication>

using namespace UserMetricsInput;

int main(int argc, char *argv[]) {
	QCoreApplication application(argc, argv);

	// We start with a manager object
	MetricManagerPtr manager(MetricManager::getInstance());

	// You can hold onto this shared pointer for as long as you want
	MetricPtr metric(
			manager->add(
					MetricParameters("twitter").formatString(
							"<b>%1</b> tweets received today").emptyDataString(
							"No tweets today").textDomain(APP_ID)));

	// The update is sent when the update object is destroyed
	MetricUpdatePtr update(metric->update());

	// Get our data from somewhere
	TwitterService twitterService;

	// The data is ordered starting from today, going backwards in time
	for (const TwitterData &twitterData : twitterService.getTweetCounts()) {
		update->addData(twitterData.toDouble());
	}

	return 0;
}