3#ifndef DUNE_FUNCTIONS_COMMON_TREEDATA_HH
4#define DUNE_FUNCTIONS_COMMON_TREEDATA_HH
7#warning This file is deprecated. Please use TreeContainer from dune-typetree instead.
13#include <dune/typetree/pairtraversal.hh>
15#include <dune/functions/gridfunctions/gridviewentityset.hh>
16#include <dune/functions/gridfunctions/gridfunction.hh>
34template<
class SimpleNodeVisitorImp,
bool leafOnly>
36[[deprecated(
"This is an implementation detail of the deprecated class TreeDate and thus deprecated itself.")]]
44 template<
typename Node,
typename TreePath,
45 typename std::enable_if<(not leafOnly) and (not Node::isLeaf),
int>::type = 0>
46 void pre(Node& node, TreePath
treePath)
48 static_cast<SimpleNodeVisitorImp*
>(
this)->apply(node,
treePath);
51 template<
typename Node,
typename TreePath,
52 typename std::enable_if<(leafOnly) and (not Node::isLeaf),
int>::type = 0>
53 void pre(Node& node, TreePath
treePath)
56 template<
typename Node,
typename TreePath>
57 void leaf(Node& node, TreePath
treePath)
59 static_cast<SimpleNodeVisitorImp*
>(
this)->apply(node,
treePath);
91template<
class T,
template<
class>
class ND,
bool LO>
93[[deprecated(
"This class is deprecated. Please use TreeContainer from dune-typetree instead.")]]
106 static const bool leafOnly = LO;
113 using RawContainer = std::vector<void*>;
128 InitVisitor(RawContainer& data) :
132 template<
typename Node,
typename TreePath>
133 void apply(Node& node, TreePath
treePath)
135 auto&& index = node.treeIndex();
136 if (data_.size() < index+1)
137 data_.resize(index+1,
nullptr);
145 struct DestroyVisitor :
148 DestroyVisitor(RawContainer& data) :
152 template<
typename Node,
typename TreePath>
153 void apply(Node& node, TreePath
treePath)
155 auto&& index = node.treeIndex();
156 auto p = (NodeData<Node>*)(data_[index]);
158 data_[index] =
nullptr;
165 public UniformNodeVisitor<CopyVisitor, leafOnly>
167 CopyVisitor(TreeData& thisTD,
const TreeData& otherTD) :
172 template<
typename Node,
typename TreePath>
173 void apply(Node& node, TreePath
treePath)
175 thisTD_[node] = otherTD_[node];
179 const TreeData& otherTD_;
Container allowing to attach data to each node of a tree.
Definition: treedata.hh:95
TreeData(const TreeData &other)
Copy constructor.
Definition: treedata.hh:205
void init(const Tree &tree)
Initialize from tree.
Definition: treedata.hh:196
T Tree
Type of tree the data is associated with.
Definition: treedata.hh:100
void destroy()
Destroy data.
Definition: treedata.hh:223
const NodeData< Node > & operator[](const Node &node) const
Get reference to data associated to given node.
Definition: treedata.hh:246
TreeData & operator=(const TreeData &other)
Copy assignment.
Definition: treedata.hh:213
~TreeData()
Destructor.
Definition: treedata.hh:231
ND< Node > NodeData
Template to determine the data type for given node type.
Definition: treedata.hh:110
TreeData()
Default constructor.
Definition: treedata.hh:185
NodeData< Node > & operator[](const Node &node)
Get mutable reference to data associated to given node.
Definition: treedata.hh:239
typename Tree::size_type size_type
Type used for indices and size information.
Definition: treedata.hh:103
constexpr HybridTreePath< T... > treePath(const T &... t)
Constructs a new HybridTreePath from the given indices.
Definition: treepath.hh:191
void applyToTree(Tree &&tree, Visitor &&visitor)
Apply visitor to TypeTree.
Definition: traversal.hh:237
Dune namespace.
Definition: alignedallocator.hh:13
This file implements several utilities related to std::shared_ptr.
Mixin base class for visitors that only need a dynamic TreePath during traversal.
Definition: visitor.hh:424
Convenience base class for visiting the entire tree.
Definition: visitor.hh:433