Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
bd99e258f5c082d083e693e6c19eb8917a778c54
[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 #include <memory>
12
13 namespace simgrid::mc {
14
15 /** A model-checking exploration 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-checked application through the
25  * `RemoteApp` interface (that is currently not perfectly sufficient to that extend). */
26 // abstract
27 class Exploration : public xbt::Extendable<Exploration> {
28   std::unique_ptr<RemoteApp> remote_app_;
29
30 public:
31   explicit Exploration(const std::vector<char*>& args);
32
33   // No copy:
34   Exploration(Exploration const&) = delete;
35   Exploration& operator=(Exploration const&) = delete;
36
37   virtual ~Exploration() = default;
38
39   /** Main function of this algorithm */
40   virtual void run() = 0;
41
42   /* These methods are callbacks called by the model-checking engine
43    * to get and display information about the current state of the
44    * model-checking algorithm: */
45
46   /** Show the current trace/stack
47    *
48    *  Could this be handled in the Session/ModelChecker instead? */
49   virtual RecordTrace get_record_trace() = 0;
50
51   /** Generate a textual execution trace of the simulated application */
52   virtual std::vector<std::string> get_textual_trace() = 0;
53
54   /** Log additional information about the state of the model-checker */
55   virtual void log_state();
56
57   RemoteApp& get_remote_app() { return *remote_app_.get(); }
58 };
59
60 // External constructors so that the types (and the types of their content) remain hidden
61 XBT_PUBLIC Exploration* create_liveness_checker(const std::vector<char*>& args);
62 XBT_PUBLIC Exploration* create_dfs_exploration(const std::vector<char*>& args);
63 XBT_PUBLIC Exploration* create_communication_determinism_checker(const std::vector<char*>& args);
64 XBT_PUBLIC Exploration* create_udpor_checker(const std::vector<char*>& args);
65
66 } // namespace simgrid::mc
67
68 #endif