From: Arnaud Giersch Date: Fri, 16 Oct 2020 19:49:06 +0000 (+0200) Subject: Make static stuff member of class Replayer. X-Git-Tag: v3.26~290 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/aca33bee4e799cd7b0a70897a1e84c998466dd6d Make static stuff member of class Replayer. --- diff --git a/examples/s4u/replay-io/s4u-replay-io.cpp b/examples/s4u/replay-io/s4u-replay-io.cpp index 2e02f0839f..c5fb26b016 100644 --- a/examples/s4u/replay-io/s4u-replay-io.cpp +++ b/examples/s4u/replay-io/s4u-replay-io.cpp @@ -12,8 +12,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(replay_io, "Messages specific for this example"); -static std::unordered_map opened_files; - #define ACT_DEBUG(...) \ if (XBT_LOG_ISENABLED(replay_io, xbt_log_priority_verbose)) { \ std::string NAME = boost::algorithm::join(action, " "); \ @@ -21,22 +19,23 @@ static std::unordered_map opened_files; } else \ ((void)0) -static void log_action(const simgrid::xbt::ReplayAction& action, double date) -{ - if (XBT_LOG_ISENABLED(replay_io, xbt_log_priority_verbose)) { - std::string s = boost::algorithm::join(action, " "); - XBT_VERB("%s %f", s.c_str(), date); - } -} +class Replayer { + static std::unordered_map opened_files; -static simgrid::s4u::File* get_file_descriptor(const std::string& file_name) -{ - std::string full_name = simgrid::s4u::this_actor::get_name() + ":" + file_name; + static void log_action(const simgrid::xbt::ReplayAction& action, double date) + { + if (XBT_LOG_ISENABLED(replay_io, xbt_log_priority_verbose)) { + std::string s = boost::algorithm::join(action, " "); + XBT_VERB("%s %f", s.c_str(), date); + } + } - return opened_files.at(full_name); -} + static simgrid::s4u::File* get_file_descriptor(const std::string& file_name) + { + std::string full_name = simgrid::s4u::this_actor::get_name() + ":" + file_name; + return opened_files.at(full_name); + } -class Replayer { public: explicit Replayer(std::vector args) { @@ -92,6 +91,8 @@ public: } }; +std::unordered_map Replayer::opened_files; + int main(int argc, char* argv[]) { simgrid::s4u::Engine e(&argc, argv);