Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / src / mc / mc_record.hpp
1 /* Copyright (c) 2014-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 /** \file mc_record.hpp
7  *
8  *  This file contains the MC replay/record functionality.
9  *  The recorded path is written in the log output and can be replayed with MC disabled
10  *  (even with a non-MC build) using `--cfg=model-check/replay:$replayPath`.
11  *
12  *  The same version of SimGrid should be used and the same arguments should be
13  *  passed to the application (without the MC specific arguments).
14  */
15
16 #ifndef SIMGRID_MC_RECORD_HPP
17 #define SIMGRID_MC_RECORD_HPP
18
19 #include "src/mc/mc_forward.hpp"
20 #include "xbt/base.h"
21
22 #include <deque>
23 #include <string>
24
25 namespace simgrid::mc {
26
27 class RecordTrace {
28   std::deque<Transition*> transitions_;
29
30 public:
31   // Use rule-of-three, and implicitely disable the move constructor which cannot be 'noexcept' (as required by C++ Core
32   // Guidelines), due to the std::deque member.
33   RecordTrace()                   = default;
34   RecordTrace(const RecordTrace&) = default;
35   ~RecordTrace()                  = default;
36
37   /** Build a trace that can be replayed from a string representation */
38   explicit RecordTrace(const char* data);
39   /** Make a string representation that can later be used to create a new trace */
40   std::string to_string() const;
41
42   void push_front(Transition* t) { transitions_.push_front(t); }
43   void push_back(Transition* t) { transitions_.push_back(t); }
44   std::deque<Transition*>::const_iterator begin() const { return transitions_.begin(); }
45   std::deque<Transition*>::const_iterator end() const { return transitions_.end(); }
46
47   /** Replay all transitions of a trace */
48   void replay() const;
49
50   /** Parse and replay a string representation */
51   static void replay(const std::string& trace);
52 };
53
54 } // namespace simgrid::mc
55
56 #endif