Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / include / xbt / replay.hpp
index a969fbc..e6da188 100644 (file)
@@ -1,7 +1,6 @@
-/* xbt/replay_reader.h -- Tools to parse a replay file                */
+/* xbt/replay.hpp -- Tools to parse a replay file                           */
 
-/* Copyright (c) 2010, 2012-2015, 2017. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-2023. 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. */
@@ -9,30 +8,28 @@
 #ifndef XBT_REPLAY_HPP
 #define XBT_REPLAY_HPP
 
-#include "xbt/misc.h" /* SG_BEGIN_DECL */
-#ifdef __cplusplus
+#include <xbt/misc.h> /* SG_BEGIN_DECL */
+
 #include <fstream>
+#include <functional>
 #include <queue>
 #include <unordered_map>
 
-namespace simgrid {
-namespace xbt {
+namespace simgrid::xbt {
 /* To split the file if a unique one is given (specific variable for the other case live in runner()) */
-typedef std::vector<std::string> ReplayAction;
-static std::unordered_map<std::string, std::queue<ReplayAction*>*> action_queues;
-
-XBT_PUBLIC_DATA(std::ifstream*) action_fs;
-XBT_PUBLIC(int) replay_runner(int argc, char* argv[]);
-}
-}
-#endif
-
-SG_BEGIN_DECL()
-
-typedef void (*action_fun)(const char* const* args);
-XBT_PUBLIC(void) xbt_replay_action_register(const char* action_name, action_fun function);
-XBT_PUBLIC(action_fun) xbt_replay_action_get(const char* action_name);
-
-SG_END_DECL()
+using ReplayAction = std::vector<std::string>;
+
+/** Launch a replaying actor of the given name.
+ *
+ * If trace_filename is nullptr, then the tracefile is shared between all instances, and was passed using
+ * xbt_replay_set_tracefile(). If trace_filename is not nullptr, then it's not shared and this trace file is for this
+ * actor only */
+XBT_PUBLIC int replay_runner(const char* actor_name, const char* trace_filename = nullptr);
+} // namespace simgrid::xbt
+
+using action_fun = std::function<void(simgrid::xbt::ReplayAction&)>;
+XBT_PUBLIC void xbt_replay_action_register(const char* action_name, const action_fun& function);
+XBT_PUBLIC action_fun xbt_replay_action_get(const char* action_name);
+XBT_PUBLIC void xbt_replay_set_tracefile(const std::string& filename);
 
 #endif