21 #ifndef __HIERARCHICAL_H 22 #define __HIERARCHICAL_H 26 #include <dolfin/log/log.h> 27 #include <dolfin/log/LogStream.h> 28 #include "NoDeleter.h" 64 it->_child; it = it->_child)
75 {
return _parent ? true :
false; }
83 {
return _child ? true :
false; }
95 "extract parent of hierarchical object",
96 "Object has no parent in hierarchy");
105 "extract parent of hierarchical object",
106 "Object has no parent in hierarchy");
133 "extract child of hierarchical object",
134 "Object has no child in hierarchy");
143 "extract child of hierarchical object",
144 "Object has no child in hierarchy");
184 std::shared_ptr<T> it = _self;
185 for (; it->_parent; it = it->_parent);
192 std::shared_ptr<const T> it = _self;
193 for (; it->_parent; it = it->_parent);
220 std::shared_ptr<T> it = _self;
221 for (; it->_child; it = it->_child);
228 std::shared_ptr<const T> it = _self;
229 for (; it->_child; it = it->_child);
260 info(
"Debugging hierarchical object:");
263 info(
" _parent.get() = %x", _parent.get());
264 info(
" _parent.count() = %d", _parent.use_count());
266 info(
" _child.get() = %x", _parent.get());
267 info(
" _child.count() = %d", _parent.use_count());
273 std::shared_ptr<T> _self;
276 std::shared_ptr<T> _parent;
277 std::shared_ptr<T> _child;
std::shared_ptr< const T > leaf_node_shared_ptr() const
Return shared pointer to leaf node object in hierarchy (const version).
Definition: Hierarchical.h:226
std::shared_ptr< const T > root_node_shared_ptr() const
Return shared pointer to root node object in hierarchy (const version).
Definition: Hierarchical.h:190
std::shared_ptr< T > parent_shared_ptr()
Definition: Hierarchical.h:116
Definition: Hierarchical.h:43
const T & parent() const
Return parent in hierarchy (const version).
Definition: Hierarchical.h:101
virtual ~Hierarchical()
Destructor.
Definition: Hierarchical.h:51
void set_child(std::shared_ptr< T > child)
Set child.
Definition: Hierarchical.h:244
LogStream endl
dolfin::endl;
void clear_child()
Clear child.
Definition: Hierarchical.h:238
Hierarchical(T &self)
Constructor.
Definition: Hierarchical.h:48
const T & child() const
Return child in hierarchy (const version).
Definition: Hierarchical.h:139
void set_parent(std::shared_ptr< T > parent)
Set parent.
Definition: Hierarchical.h:234
bool has_parent() const
Definition: Hierarchical.h:74
bool has_child() const
Definition: Hierarchical.h:82
std::shared_ptr< const T > parent_shared_ptr() const
Return shared pointer to parent (const version).
Definition: Hierarchical.h:120
std::shared_ptr< const T > child_shared_ptr() const
Return shared pointer to child (const version).
Definition: Hierarchical.h:158
std::shared_ptr< T > reference_to_no_delete_pointer(T &r)
Helper function to construct shared pointer with NoDeleter with cleaner syntax.
Definition: NoDeleter.h:43
std::shared_ptr< T > child_shared_ptr()
Definition: Hierarchical.h:154
const Hierarchical & operator=(const Hierarchical &hierarchical)
Assignment operator.
Definition: Hierarchical.h:248
T & child()
Definition: Hierarchical.h:129
void info(std::string msg,...)
Print message.
Definition: log.cpp:72
T & root_node()
Definition: Hierarchical.h:166
std::shared_ptr< T > root_node_shared_ptr()
Definition: Hierarchical.h:182
void dolfin_error(std::string location, std::string task, std::string reason,...)
Definition: log.cpp:129
T & parent()
Definition: Hierarchical.h:91
void _debug() const
Function useful for debugging the hierarchy.
Definition: Hierarchical.h:258
T & leaf_node()
Definition: Hierarchical.h:202
const T & root_node() const
Return root node object in hierarchy (const version).
Definition: Hierarchical.h:172
std::shared_ptr< T > leaf_node_shared_ptr()
Definition: Hierarchical.h:218
const T & leaf_node() const
Return leaf node object in hierarchy (const version).
Definition: Hierarchical.h:208
std::size_t depth() const
Definition: Hierarchical.h:60
LogStream cout
dolfin::cout