Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
stringify IO
[simgrid.git] / examples / s4u / actions-storage / s4u_actions-storage.cpp
index 0c10ded..85ffb9d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2017. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -29,9 +29,9 @@ static void log_action(const char* const* action, double date)
   }
 }
 
-static simgrid::s4u::File* get_file_descriptor(const char* file_name)
+static simgrid::s4u::File* get_file_descriptor(std::string file_name)
 {
-  std::string full_name = simgrid::s4u::this_actor::name() + ":" + file_name;
+  std::string full_name = simgrid::s4u::this_actor::getName() + ":" + file_name;
 
   return opened_files.at(full_name);
 }
@@ -60,11 +60,11 @@ public:
   /* My actions */
   static void open(const char* const* action)
   {
-    const char* file_name = action[2];
+    std::string file_name = action[2];
     double clock          = simgrid::s4u::Engine::getClock();
-    std::string full_name = simgrid::s4u::this_actor::name() + ":" + file_name;
+    std::string full_name = simgrid::s4u::this_actor::getName() + ":" + file_name;
 
-    ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name);
+    ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name.c_str());
     simgrid::s4u::File* file = new simgrid::s4u::File(file_name, NULL);
 
     opened_files.insert({full_name, file});
@@ -74,7 +74,7 @@ public:
 
   static void read(const char* const* action)
   {
-    const char* file_name = action[2];
+    std::string file_name = action[2];
     sg_size_t size        = std::stoul(action[3]);
     double clock          = simgrid::s4u::Engine::getClock();
 
@@ -88,12 +88,12 @@ public:
 
   static void close(const char* const* action)
   {
-    const char* file_name = action[2];
+    std::string file_name = action[2];
     double clock          = simgrid::s4u::Engine::getClock();
 
     simgrid::s4u::File* file = get_file_descriptor(file_name);
 
-    ACT_DEBUG("Entering Close: %s (filename: %s)", NAME, file_name);
+    ACT_DEBUG("Entering Close: %s (filename: %s)", NAME, file_name.c_str());
     delete file;
 
     log_action(action, simgrid::s4u::Engine::getClock() - clock);
@@ -120,7 +120,6 @@ int main(int argc, char* argv[])
   xbt_replay_action_register("read", Replayer::read);
   xbt_replay_action_register("close", Replayer::close);
 
-  /* Actually do the simulation using MSG_action_trace_run */
   if (argv[3]) {
     simgrid::xbt::action_fs = new std::ifstream(argv[3], std::ifstream::in);
   }
@@ -134,5 +133,6 @@ int main(int argc, char* argv[])
 
   XBT_INFO("Simulation time %g", e->getClock());
 
+  delete e;
   return 0;
 }