X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0ffc4789aa9f3b4e65a1fb9916a420697ac5a4c5..4bd1f48f0bf1ad1703be680ec2a38d626c6a2668:/src/xbt/xbt_replay.cpp diff --git a/src/xbt/xbt_replay.cpp b/src/xbt/xbt_replay.cpp index 86f8c7c9d8..beee5cdbbe 100644 --- a/src/xbt/xbt_replay.cpp +++ b/src/xbt/xbt_replay.cpp @@ -23,7 +23,7 @@ static void read_and_trim_line(std::ifstream* fs, std::string* line) do { std::getline(*fs, *line); boost::trim(*line); - } while (!fs->eof() && (line->length() == 0 || line->front() == '#')); + } while (not fs->eof() && (line->length() == 0 || line->front() == '#')); XBT_DEBUG("got from trace: %s", line->c_str()); } @@ -34,10 +34,11 @@ class ReplayReader { public: explicit ReplayReader(const char* filename) { - XBT_VERB("Prepare to replay file '%s'", filename); - fs = new std::ifstream(filename, std::ifstream::in); - xbt_assert(fs->is_open(), "Cannot read file %s", filename); + XBT_VERB("Prepare to replay file '%s'", filename); + fs = new std::ifstream(filename, std::ifstream::in); + xbt_assert(fs->is_open(), "Cannot read replay file '%s'", filename); } + ReplayReader(const ReplayReader&) = delete; ~ReplayReader() { delete fs; @@ -50,7 +51,7 @@ bool ReplayReader::get(ReplayAction* action) read_and_trim_line(fs, &line); boost::split(*action, line, boost::is_any_of(" \t"), boost::token_compress_on); - return !fs->eof(); + return not fs->eof(); } static ReplayAction* get_action(char* name) @@ -78,9 +79,10 @@ static ReplayAction* get_action(char* name) } else { // Else, I have to store it for the relevant colleague std::queue* otherqueue = nullptr; - if (action_queues.find(evtname) != action_queues.end()) - otherqueue = action_queues.at(evtname); - else { // Damn. Create the queue of that guy + auto act = action_queues.find(evtname); + if (act != action_queues.end()) { + otherqueue = act->second; + } else { // Damn. Create the queue of that guy otherqueue = new std::queue(); action_queues.insert({evtname, otherqueue}); } @@ -103,7 +105,7 @@ static void handle_action(ReplayAction* action) char** c_action = new char*[action->size() + 1]; action_fun function = action_funs.at(action->at(1)); int i = 0; - for (auto arg : *action) { + for (auto const& arg : *action) { c_action[i] = xbt_strdup(arg.c_str()); i++; } @@ -125,9 +127,6 @@ static void handle_action(ReplayAction* action) /** * \ingroup XBT_replay * \brief function used internally to actually run the replay - - * \param argc argc . - * \param argv argv */ int replay_runner(int argc, char* argv[]) { @@ -180,7 +179,7 @@ int replay_runner(int argc, char* argv[]) */ void xbt_replay_action_register(const char* action_name, action_fun function) { - simgrid::xbt::action_funs.insert({std::string(action_name), function}); + simgrid::xbt::action_funs[std::string(action_name)] = function; } /**