Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
c9e58d9efd73e6e2c34c22b660ce074d5b476f6a
[simgrid.git] / src / mc / ModelChecker.hpp
1 /* Copyright (c) 2007-2015. 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_MODEL_CHECKER_HPP
8 #define SIMGRID_MC_MODEL_CHECKER_HPP
9
10 #include <sys/types.h>
11
12 #include <simgrid_config.h>
13 #include <xbt/dict.h>
14 #include <xbt/base.h>
15
16 #include "mc_forward.hpp"
17 #include "src/mc/Process.hpp"
18 #include "src/mc/PageStore.hpp"
19 #include "mc_protocol.h"
20
21 namespace simgrid {
22 namespace mc {
23
24 /** State of the model-checker (global variables for the model checker)
25  *
26  *  Each part of the state of the model chercker represented as a global
27  *  variable prevents some sharing between snapshots and must be ignored.
28  *  By moving as much state as possible in this structure allocated
29  *  on the model-checker heap, we avoid those issues.
30  */
31 class ModelChecker {
32   /** String pool for host names */
33   // TODO, use std::unordered_set with heterogeneous comparison lookup (C++14)
34   xbt_dict_t /* <hostname, NULL> */ hostnames_;
35   // This is the parent snapshot of the current state:
36   PageStore page_store_;
37   Process process_;
38 public:
39   mc_snapshot_t parent_snapshot_;
40
41 public:
42   ModelChecker(ModelChecker const&) = delete;
43   ModelChecker& operator=(ModelChecker const&) = delete;
44   ModelChecker(pid_t pid, int socket);
45   ~ModelChecker();
46   Process& process()
47   {
48     return process_;
49   }
50   PageStore& page_store()
51   {
52     return page_store_;
53   }
54   const char* get_host_name(const char* name);
55
56   bool is_important_snapshot(Snapshot const& snapshot) const
57   {
58     return &snapshot == this->parent_snapshot_;
59   }
60 };
61
62 }
63 }
64
65 #endif