Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'random_readwritestate' into 'master'
[simgrid.git] / src / mc / checker / Checker.hpp
1 /* Copyright (c) 2016-2020. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SIMGRID_MC_CHECKER_HPP
8 #define SIMGRID_MC_CHECKER_HPP
9
10 //#include "src/mc/Session.hpp"
11 #include "src/mc/mc_forward.hpp"
12 #include "src/mc/mc_record.hpp"
13
14 namespace simgrid {
15 namespace mc {
16
17 /** A model-checking algorithm
18  *
19  *  This is an abstract base class used to group the data, state, configuration
20  *  of a model-checking algorithm.
21  *
22  *  Implementing this interface will probably not be really mandatory,
23  *  you might be able to write your model-checking algorithm as plain
24  *  imperative code instead.
25  *
26  *  It is expected to interact with the model-checking core through the
27  * `Session` interface (but currently the `Session` interface does not
28  *  have all the necessary features). */
29 // abstract
30 class Checker {
31   Session* session_;
32
33 public:
34   explicit Checker(Session& session);
35
36   // No copy:
37   Checker(Checker const&) = delete;
38   Checker& operator=(Checker const&) = delete;
39
40   virtual ~Checker() = default;
41
42   /** Main function of this algorithm */
43   virtual void run() = 0;
44
45   /* These methods are callbacks called by the model-checking engine
46    * to get and display information about the current state of the
47    * model-checking algorithm: */
48
49   /** Show the current trace/stack
50    *
51    *  Could this be handled in the Session/ModelChecker instead? */
52   virtual RecordTrace get_record_trace() = 0;
53
54   /** Generate a textual execution trace of the simulated application */
55   virtual std::vector<std::string> get_textual_trace() = 0;
56
57   /** Log additional information about the state of the model-checker */
58   virtual void log_state() = 0;
59
60 protected:
61   Session& get_session() { return *session_; }
62 };
63
64 // External constructors so that the types (and the types of their content) remain hidden
65 XBT_PUBLIC Checker* createLivenessChecker(Session& session);
66 XBT_PUBLIC Checker* createSafetyChecker(Session& session);
67 XBT_PUBLIC Checker* createCommunicationDeterminismChecker(Session& session);
68
69 } // namespace mc
70 } // namespace simgrid
71
72 #endif