Allow to log statistics samples as a event operation
[anna.git] / source / statistics / Engine.cpp
index e804599..79a23ce 100644 (file)
@@ -99,12 +99,9 @@ bool Engine::enableSampleLog(const int & id, const char *sampleFileName) throw()
   // For all concepts:
   _concept_identification_map_nc_iter it_min(a_concept_identification_map.begin());
   _concept_identification_map_nc_iter it_max(a_concept_identification_map.end());
-
   for(it = it_min; it != it_max; it++) {
     realName = "";
-
     if(providedName != "") realName = anna::functions::asString("%s.%d.csv", providedName.c_str(), (*it).first);
-
     SampleFile_ptr = &((*it).second.SampleFile);
     *SampleFile_ptr = realName;
   }
@@ -117,14 +114,20 @@ bool Engine::enableSampleLog(const int & id, const char *sampleFileName) throw()
 //--------------------------------------------------- Engine::disableSampleLog()
 //------------------------------------------------------------------------------
 bool Engine::disableSampleLog(const int & id) throw() {
-  _concept_identification_map_nc_iter it = a_concept_identification_map.find(id);
 
-  if(it == a_concept_identification_map.end()) return false;
+  if(id != -1) {
+    _concept_identification_map_nc_iter it = a_concept_identification_map.find(id);
 
-  // Access to map
-  std::string *SampleFile_ptr = &((*it).second.SampleFile);
-  *SampleFile_ptr = "";
-  return true;
+    if(it == a_concept_identification_map.end()) return false;
+
+    // Access to map
+    std::string *SampleFile_ptr = &((*it).second.SampleFile);
+    *SampleFile_ptr = "";
+    return true;
+  }
+
+  // For all concepts:
+  return enableSampleLog(id /* -1 */, "");
 }