Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference parameters in src/s4u/.
[simgrid.git] / src / kernel / resource / profile / Profile.cpp
index a73c4c0..6b88203 100644 (file)
@@ -5,12 +5,16 @@
 
 #include "src/kernel/resource/profile/Profile.hpp"
 #include "simgrid/forward.h"
-#include "src/kernel/resource/profile/DatedValue.cpp"
-#include "src/kernel/resource/profile/FutureEvtSet.cpp"
-#include "xbt/log.h"
-#include "xbt/sysdep.h"
+#include "src/kernel/resource/profile/DatedValue.hpp"
+#include "src/kernel/resource/profile/Event.hpp"
+#include "src/kernel/resource/profile/FutureEvtSet.hpp"
+#include "src/surf/surf_interface.hpp"
+
 #include <boost/algorithm/string.hpp>
+#include <fstream>
 #include <ostream>
+#include <sstream>
+#include <unordered_map>
 #include <vector>
 
 static std::unordered_map<std::string, simgrid::kernel::profile::Profile*> trace_list;
@@ -113,7 +117,7 @@ Profile* Profile::from_file(const std::string& path)
   xbt_assert(not path.empty(), "Cannot parse a trace from an empty filename");
   xbt_assert(trace_list.find(path) == trace_list.end(), "Refusing to define trace %s twice", path.c_str());
 
-  std::ifstream* f = surf_ifsopen(path);
+  const std::ifstream* f = surf_ifsopen(path);
   xbt_assert(not f->fail(), "Cannot open file '%s' (path=%s)", path.c_str(), (boost::join(surf_path, ":")).c_str());
 
   std::stringstream buffer;
@@ -126,3 +130,18 @@ Profile* Profile::from_file(const std::string& path)
 } // namespace profile
 } // namespace kernel
 } // namespace simgrid
+
+void tmgr_finalize()
+{
+  for (auto const& kv : trace_list)
+    delete kv.second;
+  trace_list.clear();
+}
+
+void tmgr_trace_event_unref(simgrid::kernel::profile::Event** event)
+{
+  if ((*event)->free_me) {
+    delete *event;
+    *event = nullptr;
+  }
+}