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:
//------------------------------------------------------------------------------
//---------------------------------------------------- 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);
}
//------------------------------------------------------------------------------
//---------------------------------------------------- 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
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);
}
}
-
-
-
//------------------------------------------------------------------------------
//------------------------------------------ Accumulator::getStandardDeviation()
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
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();
}