Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / src / mc / explo / udpor / History.hpp
index 2deb65563ca9248ebd45b0fe8a0d2afc12a7fdc6..dc17c27e5854e9cb03a8f5fb0705407086140f4c 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <boost/iterator/iterator_facade.hpp>
 #include <functional>
+#include <initializer_list>
 #include <optional>
 
 namespace simgrid::mc::udpor {
@@ -54,8 +55,9 @@ public:
   History& operator=(History const&) = default;
   History(History&&)                 = default;
 
-  explicit History(UnfoldingEvent* e) : events_({e}) {}
+  explicit History(const UnfoldingEvent* e) : events_({e}) {}
   explicit History(EventSet event_set = EventSet()) : events_(std::move(event_set)) {}
+  explicit History(std::initializer_list<const UnfoldingEvent*> list) : events_(std::move(list)) {}
 
   auto begin() const { return Iterator(events_); }
   auto end() const { return Iterator(EventSet()); }
@@ -94,13 +96,24 @@ public:
    */
   EventSet get_all_maximal_events() const;
 
+  /**
+   * @brief Computes the set of events that are not contained
+   * in the given configuration
+   *
+   * A configuration is a causally-closed, conflict-free set
+   * of events. Thus, you can determine which events lie outside
+   * of a configuration during the search more efficiently: the moment
+   * you discover an event contained in the configuration, you
+   * do not need to search that event or any of its ancestors as
+   * they will all be contained in the configuration
+   */
   EventSet get_event_diff_with(const Configuration& config) const;
 
 private:
   /**
    * @brief An iterator which traverses the history of a set of events
    */
-  struct Iterator : boost::iterator_facade<Iterator, UnfoldingEvent* const, boost::forward_traversal_tag> {
+  struct Iterator : boost::iterator_facade<Iterator, const UnfoldingEvent* const, boost::forward_traversal_tag> {
   public:
     using optional_configuration = std::optional<std::reference_wrapper<const Configuration>>;
     Iterator(const EventSet& initial_events, optional_configuration config = std::nullopt);
@@ -122,7 +135,7 @@ private:
     void increment();
     bool equal(const Iterator& other) const;
 
-    UnfoldingEvent* const& dereference() const;
+    const UnfoldingEvent* const& dereference() const;
 
     // Allows boost::iterator_facade<...> to function properly
     friend class boost::iterator_core_access;