Logo AND Algorithmique Numérique Distribuée

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