Message statistics
[anna.git] / source / statistics / Accumulator.cpp
index 358c87c..c3e3b2c 100644 (file)
@@ -32,15 +32,6 @@ using namespace anna::statistics;
 using namespace anna::time;
 
 
-//******************************************************************************
-//------------------------------------------------------------------------------
-//-------------------------------------------------- Accumulator::~Accumulator()
-//------------------------------------------------------------------------------
-Accumulator::~Accumulator() {
-// LOGMETHOD (TraceMethod tttm ("anna::statistics::Accumulator", "Destructor", ANNA_FILE_LOCATION));
-  // TODO: anna::statistics::Engine::instantiate().releaseAccumulator(a_name);
-}
-
 // Private functions:
 
 
@@ -57,10 +48,8 @@ void Accumulator::initialize(const int & conceptId) throw() {
 //------------------------------------------------------------------------------
 //---------------------------------------------------- Accumulator::addConcept()
 //------------------------------------------------------------------------------
-int Accumulator::addConcept(const std::string & description, const std::string & unit, const bool & integerNatureSample) throw() {
-  std::string conceptName = description;
-  conceptName += ": ";
-  conceptName += a_name;
+int Accumulator::addConcept(const std::string & description, const std::string & unit, const bool & integerNatureSample, const char *conceptNameFormat) throw() {
+  std::string conceptName = anna::functions::asString(conceptNameFormat, description.c_str(), a_name.c_str());
   return anna::statistics::Engine::instantiate().addConcept(conceptName, unit, integerNatureSample);
 }
 
@@ -68,7 +57,7 @@ int Accumulator::addConcept(const std::string & description, const std::string &
 //------------------------------------------------------------------------------
 //---------------------------------------------------- Accumulator::getConcept()
 //------------------------------------------------------------------------------
-_concept_data_t * Accumulator::getConcept(const int & conceptId) const throw(anna::RuntimeException) {
+_concept_data_t *Accumulator::getConcept(const int & conceptId) const throw(anna::RuntimeException) {
   _concept_data_map_iter it = a_concept_data_map.find(conceptId);
 
   if(it == a_concept_data_map.end()) {  // not found
@@ -85,7 +74,6 @@ _concept_data_t * Accumulator::getConcept(const int & conceptId) const throw(ann
 
     Accumulator * nc_this = const_cast<Accumulator *>(this);
     nc_this->initialize(conceptId);
-    // (la otra posibilidad era hacer mutable el mapa e inicializar poniendo el contenido de 'initialize()')
     it = a_concept_data_map.find(conceptId);
   }
 
@@ -104,9 +92,6 @@ std::string Accumulator::floatFormat(const int & numberOfDecimals) const throw()
 }
 
 
-
-
-
 //------------------------------------------------------------------------------
 //------------------------------------------ Accumulator::getStandardDeviation()
 //------------------------------------------------------------------------------
@@ -229,8 +214,10 @@ void Accumulator::reset(void) throw() {
 //------------------------------------------------------------------------------
 void Accumulator::reset(const int & conceptId) throw(anna::RuntimeException) {
 // LOGMETHOD (TraceMethod tttm ("anna::statistics::Accumulator", "reset", ANNA_FILE_LOCATION));
-  _concept_data_t *ptr_auxConceptData = getConcept(conceptId);
-  //if (ptr_auxConceptData == NULL) return; // Not possible: getConcept initializes it if not found.
+  _concept_data_t *ptr_auxConceptData = getConcept(conceptId); // will initialize if didn't associated to this accumulator,
+                                                               // exception if engine knows nothing about such concept id.
+  //if (ptr_auxConceptData == NULL) return; // Not possible: getConcept initializes it if not found or exception was launched
+                                            //               previously if the engine don't know the concept id.
   ptr_auxConceptData->reset();
 }