Go to the documentation of this file.
3 #ifndef DUNE_FUNCTIONS_COMMON_TREEDATA_HH
4 #define DUNE_FUNCTIONS_COMMON_TREEDATA_HH
8 #include <dune/common/shared_ptr.hh>
27 template<
class SimpleNodeVisitorImp,
bool leafOnly>
29 public TypeTree::TreeVisitor,
30 public TypeTree::DynamicTraversal
35 template<
typename Node,
typename TreePath,
36 typename std::enable_if<(not leafOnly) and (not Node::isLeaf),
int>::type = 0>
37 void pre(Node& node, TreePath treePath)
39 static_cast<SimpleNodeVisitorImp*
>(
this)->apply(node, treePath);
42 template<
typename Node,
typename TreePath,
43 typename std::enable_if<(leafOnly) and (not Node::isLeaf),
int>::type = 0>
44 void pre(Node& node, TreePath treePath)
47 template<
typename Node,
typename TreePath>
48 void leaf(Node& node, TreePath treePath)
50 static_cast<SimpleNodeVisitorImp*
>(
this)->apply(node, treePath);
80 template<
class T,
template<
class>
class ND,
bool LO>
119 template<
typename Node,
typename TreePath>
120 void apply(Node& node, TreePath treePath)
122 auto&& index = node.treeIndex();
123 if (
data_.size() < index+1)
124 data_.resize(index+1,
nullptr);
139 template<
typename Node,
typename TreePath>
140 void apply(Node& node, TreePath treePath)
142 auto&& index = node.treeIndex();
145 data_[index] =
nullptr;
159 template<
typename Node,
typename TreePath>
160 void apply(Node& node, TreePath treePath)
188 TypeTree::applyToTree(*
tree_, InitVisitor(
data_));
195 TypeTree::applyToTree(*
tree_, InitVisitor(
data_));
196 TypeTree::applyToTree(*
tree_, CopyVisitor(*
this, other));
203 TypeTree::applyToTree(*
tree_, DestroyVisitor(
data_));
205 TypeTree::applyToTree(*
tree_, CopyVisitor(*
this, other));
213 TypeTree::applyToTree(*
tree_, DestroyVisitor(
data_));
221 TypeTree::applyToTree(*
tree_, DestroyVisitor(
data_));
249 #endif // DUNE_FUNCTIONS_COMMON_TREEDATA_HH
static const bool leafOnly
Set if data should only be associated to the leafs.
Definition: treedata.hh:93
Definition: treedata.hh:112
Definition: polynomial.hh:7
TreeData(const TreeData &other)
Copy constructor.
Definition: treedata.hh:192
NodeData< Node > NodeData
Template to determine the data type for given node type.
Definition: treedata.hh:97
void init(const Tree &tree)
Initialize from tree.
Definition: treedata.hh:183
InitVisitor(RawContainer &data)
Definition: treedata.hh:115
NodeData< Node > & operator[](const Node &node)
Get mutable reference to data associated to given node.
Definition: treedata.hh:226
void apply(Node &node, TreePath treePath)
Definition: treedata.hh:160
const TreeData & otherTD_
Definition: treedata.hh:166
const Tree * tree_
Definition: treedata.hh:240
TreeData()
Default constructor.
Definition: treedata.hh:172
void pre(Node &node, TreePath treePath)
Definition: treedata.hh:37
Definition: treedata.hh:151
void leaf(Node &node, TreePath treePath)
Definition: treedata.hh:48
typename Tree::size_type size_type
Type used for indices and size information.
Definition: treedata.hh:90
SubTree Tree
Type of tree the data is associated with.
Definition: treedata.hh:87
const NodeData< Node > & operator[](const Node &node) const
Get reference to data associated to given node.
Definition: treedata.hh:233
DestroyVisitor(RawContainer &data)
Definition: treedata.hh:135
TreeData & thisTD_
Definition: treedata.hh:165
void destroy()
Destroy data.
Definition: treedata.hh:210
void apply(Node &node, TreePath treePath)
Definition: treedata.hh:120
void apply(Node &node, TreePath treePath)
Definition: treedata.hh:140
RawContainer data_
Definition: treedata.hh:241
Container allowing to attach data to each node of a tree.
Definition: treedata.hh:81
~TreeData()
Destructor.
Definition: treedata.hh:218
CopyVisitor(TreeData &thisTD, const TreeData &otherTD)
Definition: treedata.hh:154
RawContainer & data_
Definition: treedata.hh:129
Definition: treedata.hh:132
RawContainer & data_
Definition: treedata.hh:148
Mixin for visitors that should apply the same action on all nodes.
Definition: treedata.hh:28
TreeData & operator=(const TreeData &other)
Copy assignment.
Definition: treedata.hh:200
std::vector< void * > RawContainer
Definition: treedata.hh:100