1 #pragma once
2 
3 #include "../core.hh"
4 #include <set>
5 #include <map>
6 
7 namespace cpprofiler
8 {
9 namespace tree
10 {
11 
12 class VisualFlags
13 {
14 
15     std::vector<bool> label_shown_;
16 
17     std::vector<bool> node_hidden_;
18 
19     std::vector<bool> shape_highlighted_;
20 
21     /// Somewhat redundant given m_shape_highlighted, but it is
22     /// more efficient for unhighlighting previously highlighted subtrees
23     std::set<NodeID> highlighted_shapes_;
24 
25     /// A set providing quick access to all hidden nodes (redundant)
26     std::set<NodeID> hidden_nodes_;
27 
28     std::map<NodeID, int> lantern_sizes_;
29 
30     void ensure_id_exists(NodeID id);
31 
32   public:
33     void setLabelShown(NodeID nid, bool val);
34     bool isLabelShown(NodeID nid) const;
35 
36     void setHidden(NodeID nid, bool val);
37     bool isHidden(NodeID nid) const;
38 
39     /// set all nodes to not be hidden (without traversing the tree)
40     void unhideAll();
41 
42     /// Return the number of hidden nodes
43     int hiddenCount();
44 
hidden_nodes()45     const std::set<NodeID> &hidden_nodes() { return hidden_nodes_; }
46 
47     void setHighlighted(NodeID nid, bool val);
48     bool isHighlighted(NodeID nid) const;
49 
50     /// Remove all map entries about lantern sizes
51     void resetLanternSizes();
52     /// Insert a map entry for `nid` to hold `val` as its lantern size
53     void setLanternSize(NodeID nid, int val);
54     /// Get lantern size for `nid`; return 0 if no entry found (not a lantern)
55     int lanternSize(NodeID nid) const;
56 
57     void unhighlightAll();
58 };
59 
60 } // namespace tree
61 } // namespace cpprofiler