libusermetrics

Public Member Functions | Static Public Member Functions | List of all members
UserMetricsInput::MetricManager Class Referenceabstract

Central place for registering and updating user metrics. More...

`#include <libusermetricsinput/MetricManager.h>`

Inheritance diagram for UserMetricsInput::MetricManager:
[legend]
Collaboration diagram for UserMetricsInput::MetricManager:
[legend]

## Public Member Functions
| MetricManager (QObject *parent=0)
| You cannot use this constructor. This is a pure-virtual class. More...
virtual | ~MetricManager ()
| Destructs the metric manager and associated Metric instances. More...
virtual MetricPtr | add (const QString &dataSourceId, const QString &formatString, const QString &emptyDataString="", const QString &textDomain="")=0
| Register a new Metric. More...
virtual MetricPtr | add (const MetricParameters &parameters)=0
| Register a new Metric. More...

## Static Public Member Functions
static MetricManager * | getInstance ()
| Gets a new instance of the MetricManager. More...

## Detailed Description

Central place for registering and updating user metrics.

This is a long-lived class that can exist for the whole application lifecycle.

## Constructor & Destructor Documentation

## ◆ MetricManager()

UserMetricsInput::MetricManager::MetricManager | ( | QObject * | parent = `0` | ) |
| explicit

You cannot use this constructor. This is a pure-virtual class.

## ◆ ~MetricManager()

virtual UserMetricsInput::MetricManager::~MetricManager | ( |  | ) |
| virtual

Destructs the metric manager and associated Metric instances.

## Member Function Documentation

## ◆ add() [1/2]

virtual MetricPtr UserMetricsInput::MetricManager::add | ( | const MetricParameters & | parameters | ) |
| pure virtual

Register a new Metric.

Parameters

  parameters | The parameters of the Metric to register

This will register a new user Metric with the above parameters. It is acceptable to call this method more than once. The same Metric instance will be returned.

## ◆ add() [2/2]

virtual MetricPtr UserMetricsInput::MetricManager::add | ( | const QString & | dataSourceId,
|  | const QString & | formatString,
|  | const QString & | emptyDataString = `""`,
|  | const QString & | textDomain = `""`
| ) |  |
| pure virtual

Register a new Metric.

Parameters

  dataSourceId | The unique ID of the data source, e.g. "facebook"
  formatString | The string to print in the output API, e.g. "<b>%1</b> messages received today"
  emptyDataString | The string to print in the case of no data, e.g. "No messages received today"
  textDomain | The translation domain

This will register a new user Metric with the above parameters. It is acceptable to call this method more than once. The same Metric instance will be returned.

## ◆ getInstance()

static MetricManager* UserMetricsInput::MetricManager::getInstance | ( |  | ) |
| static

Gets a new instance of the MetricManager.

If you want a singleton instance then hold onto this.

Examples
  MetricManagerAdvanced.cpp, MetricManagerIncrementToday.cpp, and MetricManagerUpdateToday.cpp.

The documentation for this class was generated from the following file:

- libusermetricsinput/MetricManager.h