1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 //------------------------------------------------------------------------------
10 //--------------------------------------------------------------------- #include
11 //------------------------------------------------------------------------------
15 #include <anna/statistics/Meter.hpp>
16 #include <anna/statistics/Engine.hpp>
17 #include <anna/xml/xml.hpp>
20 using namespace anna::statistics;
23 //******************************************************************************
24 //------------------------------------------------------------------------------
25 //--------------------------------------------------------------- Meter::Meter()
26 //------------------------------------------------------------------------------
28 // Default Constructor
29 Meter::Meter(const std::string & name) : a_accumulator(name) {
30 Engine& statsEngine = Engine::instantiate();
31 a_single_accumulator_concept_id = statsEngine.addConcept(name, "ms", true);
36 // LOGMETHOD (TraceMethod tttm ("anna::statistics::Meter", "Destructor", FILE_LOCATION));
41 //------------------------------------------------------------------------------
42 //------------------------------------------------------------- Meter::operator=
43 //------------------------------------------------------------------------------
44 const Meter & Meter::operator = (const Meter & meter) {
45 // LOGMETHOD (TraceMethod tttm ("anna::statistics::Meter", "operator=", FILE_LOCATION));
46 // Avoid self copy: i.e., Meter a,b; a=&b; a=b; b=a;
47 if(this == &meter) return (*this);
49 a_meter = meter.a_meter;
50 a_accumulator = meter.a_accumulator;
51 a_single_accumulator_concept_id = meter.a_single_accumulator_concept_id;
57 //------------------------------------------------------------------------------
58 //------------------------------------------------------------ Meter::asString()
59 //------------------------------------------------------------------------------
60 std::string Meter::asString(const int & numberOfDecimals) const throw() {
64 trace += "\n=====\n\n";
65 trace += a_accumulator.asString(numberOfDecimals);
70 //------------------------------------------------------------------------------
71 //--------------------------------------------------------------- Meter::asXML()
72 //------------------------------------------------------------------------------
73 anna::xml::Node* Meter::asXML(anna::xml::Node* parent, const int & numberOfDecimals) const throw() {
74 anna::xml::Node* result = parent->createChild("anna.statistics.Meter");
75 return (a_accumulator.asXML(result, numberOfDecimals));