Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update .mailmap [ci-skip]
[simgrid.git] / src / mc / explo / udpor / EventSet.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_EVENT_SET_HPP
7 #define SIMGRID_MC_UDPOR_EVENT_SET_HPP
8
9 #include "src/mc/explo/udpor/udpor_forward.hpp"
10
11 #include <cstddef>
12 #include <initializer_list>
13 #include <unordered_set>
14
15 namespace simgrid::mc::udpor {
16
17 class EventSet {
18 private:
19   std::unordered_set<UnfoldingEvent*> events_;
20
21 public:
22   EventSet()                           = default;
23   EventSet(const EventSet&)            = default;
24   EventSet& operator=(const EventSet&) = default;
25   EventSet& operator=(EventSet&&)      = default;
26   EventSet(EventSet&&)                 = default;
27   explicit EventSet(Configuration&& config);
28   explicit EventSet(std::unordered_set<UnfoldingEvent*>&& raw_events) : events_(raw_events) {}
29   explicit EventSet(std::initializer_list<UnfoldingEvent*> event_list) : events_(std::move(event_list)) {}
30
31   auto begin() const { return this->events_.begin(); }
32   auto end() const { return this->events_.end(); }
33   auto cbegin() const { return this->events_.cbegin(); }
34   auto cend() const { return this->events_.cend(); }
35
36   void remove(UnfoldingEvent*);
37   void subtract(const EventSet&);
38   void subtract(const Configuration&);
39   EventSet subtracting(UnfoldingEvent*) const;
40   EventSet subtracting(const EventSet&) const;
41   EventSet subtracting(const Configuration&) const;
42
43   void insert(UnfoldingEvent*);
44   void form_union(const EventSet&);
45   void form_union(const Configuration&);
46   EventSet make_union(UnfoldingEvent*) const;
47   EventSet make_union(const EventSet&) const;
48   EventSet make_union(const Configuration&) const;
49
50   size_t size() const;
51   bool empty() const;
52   bool contains(UnfoldingEvent*) const;
53   bool contains(const History&) const;
54   bool is_subset_of(const EventSet&) const;
55
56   bool operator==(const EventSet& other) const { return this->events_ == other.events_; }
57   bool operator!=(const EventSet& other) const { return this->events_ != other.events_; }
58
59 public:
60   /**
61    * @brief Whether or not this set of events could
62    * represent a configuration
63    */
64   bool is_valid_configuration() const;
65
66   /**
67    * @brief Whether or not this set of events is
68    * a *maximal event set*, i.e. whether each element
69    * of the set causes none of the others
70    */
71   bool is_maximal_event_set() const;
72 };
73
74 } // namespace simgrid::mc::udpor
75 #endif