X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/19ac7578ffba786dbf458aa6afc8822ea73f78b6..9307ac7861b490d95759a67b7cb0bfc25d349577:/src/mc/explo/odpor/WakeupTree.hpp diff --git a/src/mc/explo/odpor/WakeupTree.hpp b/src/mc/explo/odpor/WakeupTree.hpp index 8ffbe61854..7a6eb272bc 100644 --- a/src/mc/explo/odpor/WakeupTree.hpp +++ b/src/mc/explo/odpor/WakeupTree.hpp @@ -10,6 +10,7 @@ #include "src/mc/explo/odpor/odpor_forward.hpp" #include +#include #include namespace simgrid::mc::odpor { @@ -19,6 +20,8 @@ private: explicit WakeupTreeNode(const PartialExecution& u) : seq_(u) {} explicit WakeupTreeNode(PartialExecution&& u) : seq_(std::move(u)) {} + WakeupTreeNode* parent_ = nullptr; + /** An ordered list of children of for this node in the tree */ std::list children_; @@ -30,6 +33,7 @@ private: friend WakeupTreeIterator; public: + ~WakeupTreeNode(); WakeupTreeNode(const WakeupTreeNode&) = delete; WakeupTreeNode(WakeupTreeNode&&) = default; WakeupTreeNode& operator=(const WakeupTreeNode&) = delete; @@ -43,16 +47,16 @@ public: const PartialExecution& get_sequence() const { return seq_; } const std::list& get_ordered_children() const { return children_; } bool is_leaf() const { return children_.empty(); } - bool is_single_process() const { return children_.size() == static_cast(1); } + bool is_single_process() const { return seq_.size() == static_cast(1); } + aid_t get_first_actor() const; /** Insert a node `node` as a new child of this node */ - void add_child(WakeupTreeNode* node) { this->children_.push_back(node); } + void add_child(WakeupTreeNode* node); }; class WakeupTree { private: - /** @brief The root node of the tree */ - WakeupTreeNode* const root_; + WakeupTreeNode* root_; /** * @brief All of the nodes that are currently are a part of the tree @@ -64,13 +68,14 @@ private: */ std::unordered_map> nodes_; - /** - * @brief Transfers the lifetime of node `node` to the tree - */ void insert_node(std::unique_ptr node); + void remove_node(WakeupTreeNode* node); + bool contains(WakeupTreeNode* node) const; /** - * @brief Creates a new, disconnected node in this tree + * @brief Adds a new node to the tree, disconnected from + * any other, which represents the partial execution + * "fragment" `u` */ WakeupTreeNode* make_node(const PartialExecution& u); @@ -80,11 +85,22 @@ private: public: WakeupTree(); explicit WakeupTree(std::unique_ptr root); - static WakeupTree new_subtree_rooted_at(WakeupTreeNode* root); auto begin() const { return WakeupTreeIterator(*this); } auto end() const { return WakeupTreeIterator(); } + void remove_subtree_rooted_at(WakeupTreeNode* root); + static WakeupTree make_subtree_rooted_at(WakeupTreeNode* root); + + /** + * @brief Whether or not this tree is considered empty + * + * @note Unlike other collection types, a wakeup tree is + * considered "empty" if it only contains the root node; + * that is, if it is "uninteresting". In such a case, + */ + bool empty() const { return nodes_.size() == static_cast(1); } + /** * @brief Inserts an sequence `seq` of processes into the tree * such that that this tree is a wakeup tree relative to the