29#include "timemory/backends/process.hpp"
30#include "timemory/backends/threading.hpp"
41#include <unordered_map>
57template <
typename NodeT>
80 m_dummies.insert({ m_depth, m_current });
93 TIMEMORY_NODISCARD
bool has_head()
const {
return m_has_head; }
94 TIMEMORY_NODISCARD
auto dummy_count()
const {
return m_dummies.size(); }
95 TIMEMORY_NODISCARD
bool at_sea_level()
const {
return (m_depth == m_sea_level); }
97 int64_t&
depth() {
return m_depth; }
98 TIMEMORY_NODISCARD int64_t
depth()
const {
return m_depth; }
100 TIMEMORY_NODISCARD int64_t
sea_level()
const {
return m_sea_level; }
117 DEBUG_PRINT_HERE(
"[%s][%i]> synchronizing sea-level for depth = %i, master "
119 demangle<NodeT>().c_str(), (
int) threading::get_id(),
149 DEBUG_PRINT_HERE(
"[%s][%i]> Adding dummy for depth = %i, master depth = %i",
150 demangle<NodeT>().c_str(), (
int) threading::get_id(),
153 auto _current = m_master->
current();
154 auto _id = _current->id();
155 auto _depth = _current->depth();
157 NodeT node(_id, NodeT::get_dummy(), _depth, threading::get_id(),
158 process::get_id(),
true);
160 m_sea_level = _depth;
161 m_current = m_graph.
insert_after(m_head, std::move(node));
163 m_dummies.insert({ m_depth, m_current });
177 if(m_depth > 0 && !m_graph.
is_head(m_current))
182 else if(m_depth == 0)
199 for(
auto sitr =
entry.begin(); sitr !=
entry.end(); ++sitr)
201 if(sitr && *itr == *sitr &&
218 _accum += _parent->id();
229 return (m_current = m_graph.
append_child(m_current, node));
235 return (m_current = m_graph.
append_child(m_current, std::move(node)));
256 for(
const auto& itr : m_dummies)
257 ret.push_back({ itr.first, itr.second });
258 std::reverse(ret.begin(), ret.end());
263 bool m_has_head =
false;
265 int64_t m_sea_level = 0;
270 std::multimap<int64_t, iterator> m_dummies = {};
tim::graph instance + current node + head note + sea-level. Sea-level is defined as the node depth af...
void set_master(graph_data *_master)
typename graph_t::sibling_iterator sibling_iterator
const_iterator end() const
iterator append_child(const NodeT &node)
tim::graph< NodeT > graph_t
graph_data(this_type &&)=delete
bool at_sea_level() const
typename graph_t::iterator iterator
graph_data(const this_type &)=delete
typename graph_t::const_iterator const_iterator
std::vector< std::pair< int64_t, iterator > > inverse_insert_t
int64_t get_rolling_hash(iterator itr) const
graph_data & operator=(this_type &&)=delete
iterator append_child(NodeT &&node)
iterator append_head(NodeT &node)
iterator emplace_child(iterator _itr, const NodeT &node)
int64_t sea_level() const
inverse_insert_t get_inverse_insert() const
iterator find(iterator itr) const
typename graph_t::pre_order_iterator pre_order_iterator
const_iterator begin() const
iterator emplace_child(iterator _itr, NodeT &&node)
graph_data & operator=(const this_type &)=delete
graph_data(const NodeT &rhs, int64_t _depth, graph_data *_master=nullptr)
const graph_t & graph() const
void clear()
Erase all nodes of the graph.
void erase_children(const iterator_base &)
Erase all children of the node pointed to by iterator.
IterT append_child(IterT position)
Insert empty node as last/first child of node pointed to by position.
static bool is_head(const iterator_base &)
Determine whether the iterator is one of the 'head' nodes at the top level, i.e. has no parent.
IterT insert_after(IterT position, const T &x)
Insert node as next sibling of node pointed to by position.
pre_order_iterator end() const
Return iterator to the end of the graph.
pre_order_iterator iterator
The default iterator types throughout the graph class.
pre_order_iterator set_head(const T &x)
Short-hand to insert topmost node in otherwise empty graph.
static IterT parent(IterT)
Return iterator to the parent of a node.
const iterator const_iterator
pre_order_iterator begin() const
Return iterator to the beginning of the graph.
Declare the storage types.
#define DEBUG_PRINT_HERE(...)