Remove warnings
[anna.git] / source / core / oam / Counter.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
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 //
7
8
9 #include <anna/core/tracing/Logger.hpp>
10 #include <anna/core/oam/Counter.hpp>
11 #include <anna/core/oam/CounterScope.hpp>
12 #include <anna/core/util/defines.hpp>
13
14 using namespace std;
15 using namespace anna;
16
17
18 #define TEST_COUNTER_TAG   "__CNT__"
19
20
21 oam::Counter::Counter(oam::CounterScope& scope, const int id, const char* name) :
22   a_scope(scope),
23   a_id(id),
24   a_value(0),
25   a_accValue(0) {
26   a_name = scope.getName();
27   a_name += "::";
28   a_name += name;
29 }
30
31 int oam::Counter::getReference() const
32 throw() {
33   return (a_scope.getId() * CounterScope::MaxCounter) + a_id;
34 }
35
36 void oam::Counter::debug() const
37 throw() {
38   Logger::write(Logger::Information, functions::asString("%s| Counter%08d | %u | %s", TEST_COUNTER_TAG, getReference(), a_value, a_name.c_str()), ANNA_FILE_LOCATION);
39 }
40
41 string oam::Counter::asString() const
42 throw() {
43   string result("oam::Counter { Id: ");
44   result += functions::asString("%08d", getReference());
45   result += " | Name: ";
46   result += a_name;
47   result += " | Value: ";
48   result += functions::asString(a_value);
49   result += " | Acc-Value: ";
50   result += functions::asString(a_accValue);
51   return result += " }";
52 }
53