usermetricsinput.h
libusermetricsinput/UserMetricsInputExport.h
usermetricsinput.h
libusermetricsinput/UserMetricsInputExport.h
USERMETRICSINPUT_METRICTYPE
METRIC_TYPE_USER
METRIC_TYPE_SYSTEM
void * typedef void* UserMetricsInputMetricManager UserMetricsInputMetricManager

A central place for registering user metrics.

void * typedef void* UserMetricsInputMetricParameters UserMetricsInputMetricParameters

Parameters for constructing a metric.

void * typedef void* UserMetricsInputMetric UserMetricsInputMetric

A single user metric, e.g. "number of e-mails today" or "photos taken today".

void * typedef void* UserMetricsInputMetricUpdate UserMetricsInputMetricUpdate

A update to a user metric for a particular user.

USERMETRICSINPUT_EXPORT UserMetricsInputMetricManager USERMETRICSINPUT_EXPORT UserMetricsInputMetricManager usermetricsinput_metricmanager_new () usermetricsinput_metricmanager_new

Construct a new UserMetricsInputMetricManager.

Must be freed with usermetricsinput_metricmanager_delete

USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricmanager_delete (UserMetricsInputMetricManager metricManager) usermetricsinput_metricmanager_delete UserMetricsInputMetricManager metricManager

Free a UserMetricsInputMetricManager.

metricManager

The UserMetricsInputMetricManager to free

USERMETRICSINPUT_EXPORT UserMetricsInputMetricParameters USERMETRICSINPUT_EXPORT UserMetricsInputMetricParameters usermetricsinput_metricparameters_new (const char *dataSourceId) usermetricsinput_metricparameters_new const char * dataSourceId

Construct a new UserMetricsInputMetricParameters.

dataSourceId

The unique ID of the data source, e.g. "facebook"

Must be freed with usermetricsinput_metricparameters_delete
USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_format_string (UserMetricsInputMetricParameters metricParameter, const char *formatString) 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".

metricParameter

formatString

USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_empty_data_string (UserMetricsInputMetricParameters metricParameter, const char *emptyDataString) 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"

metricParameter

emptyDataString

USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_text_domain (UserMetricsInputMetricParameters metricParameter, const char *textDomain) usermetricsinput_metricparameters_set_text_domain UserMetricsInputMetricParameters metricParameter const char * textDomain

Set the translation domain.

metricParameter

textDomain

USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_minimum (UserMetricsInputMetricParameters metricParameter, double minimum) usermetricsinput_metricparameters_set_minimum UserMetricsInputMetricParameters metricParameter double minimum

Set the minimum display value for this metric.

metricParameter

minimum

USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_maximum (UserMetricsInputMetricParameters metricParameter, double maximum) usermetricsinput_metricparameters_set_maximum UserMetricsInputMetricParameters metricParameter double maximum

Set the maximum display value for this metric.

metricParameter

maximum

USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_set_type (UserMetricsInputMetricParameters metricParameter, USERMETRICSINPUT_METRICTYPE metricType) usermetricsinput_metricparameters_set_type UserMetricsInputMetricParameters metricParameter USERMETRICSINPUT_METRICTYPE metricType

Set the type of metric this is (user owned or system owned).

metricParameter

metricType

USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricparameters_delete (UserMetricsInputMetricParameters metricParameters) usermetricsinput_metricparameters_delete UserMetricsInputMetricParameters metricParameters

Free a UserMetricsInputMetricParameters.

metricParameters

The UserMetricsInputMetricManager to free

USERMETRICSINPUT_EXPORT UserMetricsInputMetric USERMETRICSINPUT_EXPORT UserMetricsInputMetric usermetricsinput_metricmanager_add (UserMetricsInputMetricManager metricManager, UserMetricsInputMetricParameters metricParameters) usermetricsinput_metricmanager_add UserMetricsInputMetricManager metricManager UserMetricsInputMetricParameters metricParameters

Register a new UserMetricsInputMetric.

metricManager

metricParameters

The parameters of the metric to create

Do not attempt to delete this object.
USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metric_increment (UserMetricsInputMetric metric, double amount, const char *username) usermetricsinput_metric_increment UserMetricsInputMetric metric double amount const char * username

Increment the "today" value for a simple user metric.

metric

amount

How much to increase the metric by - usually 1.

username

The user to update the data for. If blank ("") then the current user is used.

USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metric_update_today (UserMetricsInputMetric metric, double value, const char *username) usermetricsinput_metric_update_today UserMetricsInputMetric metric double value const char * username

Update the "today" value for a simple user metric.

metric

value

Today's value

username

The user to update the data for. If blank ("") then the current user is used.

USERMETRICSINPUT_EXPORT UserMetricsInputMetricUpdate USERMETRICSINPUT_EXPORT UserMetricsInputMetricUpdate usermetricsinput_metric_update (UserMetricsInputMetric metric, const char *username) usermetricsinput_metric_update UserMetricsInputMetric metric const char * username

Create an update to a particular metric.

metric

username

The user to update the data for. If blank ("") then the current user is used.

Must be freed with usermetricsinput_metricupdate_delete - this is when the actual update will be sent to the storage service.
USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricupdate_delete (UserMetricsInputMetricUpdate metricUpdate) usermetricsinput_metricupdate_delete UserMetricsInputMetricUpdate metricUpdate

Free a UserMetricsInputMetric.

metricUpdate

The UserMetricsInputMetric to free and dispatch

This will cause the update to be dispatched.
USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricupdate_add_data (UserMetricsInputMetricUpdate metricUpdate, double data) usermetricsinput_metricupdate_add_data UserMetricsInputMetricUpdate metricUpdate double data

Add data to a UserMetricsInputMetricUpdate.

metricUpdate

The UserMetricsInputMetricUpdate to add data to

data

The double-valued data to add

Each call to this method appends a new day's data to the update. So the first call adds data for today, the second call adds data for yesterday, and so on.
USERMETRICSINPUT_EXPORT void USERMETRICSINPUT_EXPORT void usermetricsinput_metricupdate_add_null (UserMetricsInputMetricUpdate metricUpdate) usermetricsinput_metricupdate_add_null UserMetricsInputMetricUpdate metricUpdate

Add unknown data to an update.

metricUpdate

The UserMetricsInputMetricUpdate to add data to

If data is not known for a particular day, then null can be added.

    /*
    *Copyright(C)2013Canonical,Ltd.
    *
    *Thislibraryisfreesoftware;youcanredistributeitand/ormodifyitunder
    *thetermsofversion3oftheGNULesserGeneralPublicLicenseaspublished
    *bytheFreeSoftwareFoundation.
    *
    *Thislibraryisdistributedinthehopethatitwillbeuseful,butWITHOUT
    *ANYWARRANTY;withouteventheimpliedwarrantyofMERCHANTABILITYorFITNESS
    *FORAPARTICULARPURPOSE.SeetheGNULesserGeneralPublicLicenseformore
    *details.
    *
    *YoushouldhavereceivedacopyoftheGNULesserGeneralPublicLicense
    *alongwiththisprogram.Ifnot,see<http://www.gnu.org/licenses/>.
    *
    *Author:PeteWoods<pete.woods@canonical.com>
    */

    /*
    *ThisfiledefinestheCAPIoflibusermetricsinput.Ifyoucan,itisstrongly
    *recommendedtousetheC++API,MetricManager.hinstead.
    */

    #ifndefUSERMETRICSINPUT_H_
    #defineUSERMETRICSINPUT_H_

    #ifdefUSERMETRICSINPUT_METRICUPDATE_H_
    #error"MixingCandC++publicheaderincludes.Youcanonlyuseoneortheother."
    #endif

    #include<libusermetricsinput/UserMetricsInputExport.h>

    #ifdef__cplusplus
    extern"C"{
    #endif

    enumUSERMETRICSINPUT_METRICTYPE{
    METRIC_TYPE_USER,METRIC_TYPE_SYSTEM
    };

    typedefvoid*UserMetricsInputMetricManager;

    typedefvoid*UserMetricsInputMetricParameters;

    typedefvoid*UserMetricsInputMetric;

    typedefvoid*UserMetricsInputMetricUpdate;

    USERMETRICSINPUT_EXPORT
    UserMetricsInputMetricManagerusermetricsinput_metricmanager_new();
    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricmanager_delete(
    UserMetricsInputMetricManagermetricManager);
    USERMETRICSINPUT_EXPORT
    UserMetricsInputMetricParametersusermetricsinput_metricparameters_new(
    constchar*dataSourceId);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricparameters_set_format_string(
    UserMetricsInputMetricParametersmetricParameter,
    constchar*formatString);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricparameters_set_empty_data_string(
    UserMetricsInputMetricParametersmetricParameter,
    constchar*emptyDataString);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricparameters_set_text_domain(
    UserMetricsInputMetricParametersmetricParameter,
    constchar*textDomain);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricparameters_set_minimum(
    UserMetricsInputMetricParametersmetricParameter,doubleminimum);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricparameters_set_maximum(
    UserMetricsInputMetricParametersmetricParameter,doublemaximum);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricparameters_set_type(
    UserMetricsInputMetricParametersmetricParameter,
    USERMETRICSINPUT_METRICTYPEmetricType);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricparameters_delete(
    UserMetricsInputMetricParametersmetricParameters);

    USERMETRICSINPUT_EXPORT
    UserMetricsInputMetricusermetricsinput_metricmanager_add(
    UserMetricsInputMetricManagermetricManager,
    UserMetricsInputMetricParametersmetricParameters);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metric_increment(UserMetricsInputMetricmetric,
    doubleamount,constchar*username);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metric_update_today(UserMetricsInputMetricmetric,
    doublevalue,constchar*username);
    USERMETRICSINPUT_EXPORT
    UserMetricsInputMetricUpdateusermetricsinput_metric_update(
    UserMetricsInputMetricmetric,constchar*username);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricupdate_delete(
    UserMetricsInputMetricUpdatemetricUpdate);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricupdate_add_data(
    UserMetricsInputMetricUpdatemetricUpdate,doubledata);

    USERMETRICSINPUT_EXPORT
    voidusermetricsinput_metricupdate_add_null(
    UserMetricsInputMetricUpdatemetricUpdate);

    #ifdef__cplusplus
    }
    #endif

    #endif