<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.20" xml:lang="en-US">
  <compounddef id="MetricManagerIncrementToday_8cpp-example" kind="example">
    <compoundname>MetricManagerIncrementToday.cpp</compoundname>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
<para>A simple example of a metric that doesn&apos;t worry about updating history, and just increments a single value in response to an action. This is for apps that can simply increment by a fixed amount. <programlisting filename="MetricManagerIncrementToday.cpp"><codeline><highlight class="preprocessor">#include<sp/>&lt;<ref refid="MetricManager_8h" kindref="compound">libusermetricsinput/MetricManager.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;QtCore/QCoreApplication&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"></highlight><highlight class="keyword">using<sp/>namespace<sp/></highlight><highlight class="normal"><ref refid="namespaceUserMetricsInput" kindref="compound">UserMetricsInput</ref>;</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>main(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>argc,<sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*argv[])<sp/>{</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>QCoreApplication<sp/>application(argc,<sp/>argv);</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>We<sp/>start<sp/>with<sp/>a<sp/>manager<sp/>object</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="namespaceUserMetricsInput_1a2f7898162932dad95bccf206c795b1e7" kindref="member">MetricManagerPtr</ref><sp/>manager(<ref refid="classUserMetricsInput_1_1MetricManager_1a1634db867ec49218befc231f67c3e4b3" kindref="member">MetricManager::getInstance</ref>());</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>You<sp/>can<sp/>hold<sp/>onto<sp/>this<sp/>shared<sp/>pointer<sp/>for<sp/>as<sp/>long<sp/>as<sp/>you<sp/>want</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="namespaceUserMetricsInput_1af5d8d34e6e6ea8560855d005f8b8c118" kindref="member">MetricPtr</ref><sp/>metric(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>manager-&gt;add(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classUserMetricsInput_1_1MetricParameters" kindref="compound">MetricParameters</ref>(</highlight><highlight class="stringliteral">&quot;photo-app-photos&quot;</highlight><highlight class="normal">).formatString(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;&lt;b&gt;%1&lt;/b&gt;<sp/>photos<sp/>taken<sp/>today&quot;</highlight><highlight class="normal">).emptyDataString(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;No<sp/>photos<sp/>taken<sp/>today&quot;</highlight><highlight class="normal">).textDomain(APP_ID)));</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>The<sp/>default<sp/>parameters<sp/>for<sp/>increment<sp/>cause<sp/>it<sp/>to<sp/>be<sp/>incremented<sp/>by<sp/>1.0,</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>for<sp/>the<sp/>current<sp/>user.</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>metric-&gt;increment();</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline><highlight class="normal">}</highlight></codeline>
</programlisting> </para>
    </detaileddescription>
  </compounddef>
</doxygen>
