Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / mc / checker / Checker.hpp
1 /* Copyright (c) 2016-2021. 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/mc_api.hpp"
11
12 namespace simgrid {
13 namespace mc {
14
15 /** A model-checking algorithm
16  *
17  *  This is an abstract base class used to group the data, state, configuration
18  *  of a model-checking algorithm.
19  *
20  *  Implementing this interface will probably not be really mandatory,
21  *  you might be able to write your model-checking algorithm as plain
22  *  imperative code instead.
23  *
24  *  It is expected to interact with the model-checking core through the
25  * `Session` interface (but currently the `Session` interface does not
26  *  have all the necessary features). */
27 // abstract
28 class Checker {
29 public:
30   inline explicit Checker() { mc_api::get().set_checker(this); }
31
32   // No copy:
33   Checker(Checker const&) = delete;
34   Checker& operator=(Checker const&) = delete;
35
36   virtual ~Checker() = default;
37
38   /** Main function of this algorithm */
39   virtual void run() = 0;
40
41   /* These methods are callbacks called by the model-checking engine
42    * to get and display information about the current state of the
43    * model-checking algorithm: */
44
45   /** Show the current trace/stack
46    *
47    *  Could this be handled in the Session/ModelChecker instead? */
48   virtual RecordTrace get_record_trace() = 0;
49
50   /** Generate a textual execution trace of the simulated application */
51   virtual std::vector<std::string> get_textual_trace() = 0;
52
53   /** Log additional information about the state of the model-checker */
54   virtual void log_state() = 0;
55 };
56
57 // External constructors so that the types (and the types of their content) remain hidden
58 XBT_PUBLIC Checker* createLivenessChecker();
59 XBT_PUBLIC Checker* createSafetyChecker();
60 XBT_PUBLIC Checker* createCommunicationDeterminismChecker();
61 XBT_PUBLIC Checker* createUdporChecker();
62
63 } // namespace mc
64 } // namespace simgrid
65
66 #endif