Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sanitize our detection of pybind11
[simgrid.git] / src / mc / Session.hpp
1 /* Copyright (c) 2016-2019. 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_SESSION_HPP
7 #define SIMGRID_MC_SESSION_HPP
8
9 #include "src/mc/ModelChecker.hpp"
10
11 #include <functional>
12
13 namespace simgrid {
14 namespace mc {
15
16 /** A model-checking session
17  *
18  *  This is expected to become the interface used by model-checking
19  *  algorithms to control the execution of the model-checked process
20  *  and the exploration of the execution graph. Model-checking
21  *  algorithms should be able to be written in high-level languages
22  *  (e.g. Python) using bindings on this interface.
23  */
24 class Session {
25 private:
26   std::unique_ptr<ModelChecker> model_checker_;
27   std::shared_ptr<simgrid::mc::Snapshot> initial_snapshot_;
28
29   // No copy:
30   Session(Session const&) = delete;
31   Session& operator=(Session const&) = delete;
32
33 public:
34   /** Create a new session by executing the provided code in a fork()
35    *
36    *  This sets up the environment for the model-checked process
37    *  (environment variables, sockets, etc.).
38    *
39    *  The code is expected to `exec` the model-checked application.
40    */
41   Session(const std::function<void()>& code);
42
43   ~Session();
44   void close();
45
46   void initialize();
47   void execute(Transition const& transition);
48   void log_state();
49
50   void restore_initial_state();
51 };
52
53 // Temporary :)
54 extern simgrid::mc::Session* session;
55
56 }
57 }
58
59 #endif