X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=blobdiff_plain;f=source%2Fstatistics%2FAccumulator.cpp;fp=source%2Fstatistics%2FAccumulator.cpp;h=c3e3b2c09e0ce936522229381cbbedddf0a837e4;hp=358c87ccb94181fe934fae6dc6869d47b60e828e;hb=028006fc5ee34967fcfffff24a2b1c8b410c26c3;hpb=3b71d6454d211ec50c2f3e04b04c607c382f2f29 diff --git a/source/statistics/Accumulator.cpp b/source/statistics/Accumulator.cpp index 358c87c..c3e3b2c 100644 --- a/source/statistics/Accumulator.cpp +++ b/source/statistics/Accumulator.cpp @@ -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(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(); }