Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into 'master'
[simgrid.git] / src / mc / explo / udpor / Unfolding.hpp
1 /* Copyright (c) 2007-2023. 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_UDPOR_UNFOLDING_HPP
7 #define SIMGRID_MC_UDPOR_UNFOLDING_HPP
8
9 #include "src/mc/explo/udpor/UnfoldingEvent.hpp"
10 #include "src/mc/explo/udpor/udpor_forward.hpp"
11
12 #include <memory>
13 #include <unordered_map>
14
15 namespace simgrid::mc::udpor {
16
17 class Unfolding {
18 private:
19   /**
20    * @brief All of the events that are currently are a part of the unfolding
21    *
22    * @invariant Each unfolding event maps itself to the owner of that event,
23    * i.e. the unique pointer that owns the address. The Unfolding owns all
24    * of the addresses that are referenced by EventSet instances and Configuration
25    * instances. UDPOR guarantees that events are persisted for as long as necessary
26    */
27   std::unordered_map<const UnfoldingEvent*, std::unique_ptr<UnfoldingEvent>> global_events_;
28
29 public:
30   Unfolding()                       = default;
31   Unfolding& operator=(Unfolding&&) = default;
32   Unfolding(Unfolding&&)            = default;
33
34   void remove(const UnfoldingEvent* e);
35   void insert(std::unique_ptr<UnfoldingEvent> e);
36   bool contains_event_equivalent_to(const UnfoldingEvent* e) const;
37
38   size_t size() const { return this->global_events_.size(); }
39   bool empty() const { return this->global_events_.empty(); }
40 };
41
42 } // namespace simgrid::mc::udpor
43 #endif