X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d807ae338c20b6dae20c353a3bfa489aff3f755b..985e0a5509e230076d22095da54dd0123d2afe5e:/src/mc/mc_record.hpp diff --git a/src/mc/mc_record.hpp b/src/mc/mc_record.hpp index 9d4fe90bc2..a2f7310628 100644 --- a/src/mc/mc_record.hpp +++ b/src/mc/mc_record.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2014-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. */ @@ -19,25 +19,38 @@ #include "src/mc/mc_forward.hpp" #include "xbt/base.h" +#include #include -#include -namespace simgrid { -namespace mc { +namespace simgrid::mc { -using RecordTrace = std::vector; +class RecordTrace { + std::deque transitions_; -/** Convert a string representation of the path into an array of `simgrid::mc::Transition` - */ -XBT_PRIVATE RecordTrace parseRecordTrace(const char* data); -XBT_PRIVATE std::string traceToString(simgrid::mc::RecordTrace const& trace); -XBT_PRIVATE void dumpRecordPath(); +public: + // Use rule-of-three, and implicitely disable the move constructor which cannot be 'noexcept' (as required by C++ Core + // Guidelines), due to the std::deque member. + RecordTrace() = default; + RecordTrace(const RecordTrace&) = default; + ~RecordTrace() = default; + + /** Build a trace that can be replayed from a string representation */ + explicit RecordTrace(const char* data); + /** Make a string representation that can later be used to create a new trace */ + std::string to_string() const; + + void push_front(Transition* t) { transitions_.push_front(t); } + void push_back(Transition* t) { transitions_.push_back(t); } + std::deque::const_iterator begin() const { return transitions_.begin(); } + std::deque::const_iterator end() const { return transitions_.end(); } + + /** Replay all transitions of a trace */ + void replay() const; -XBT_PRIVATE void replay(RecordTrace const& trace); -XBT_PRIVATE void replay(const std::string& trace); -} -} + /** Parse and replay a string representation */ + static void replay(const std::string& trace); +}; -// **** Data conversion +} // namespace simgrid::mc #endif