4 #ifndef DUNE_TYPETREE_FILTEREDCOMPOSITENODE_HH 5 #define DUNE_TYPETREE_FILTEREDCOMPOSITENODE_HH 13 #include <dune/common/shared_ptr.hh> 14 #include <dune/common/typetraits.hh> 35 template<
typename Filter,
typename Tag>
39 template<
typename Filter,
typename Node,
typename ChildTypes>
40 struct apply_filter_wrapper;
42 template<
typename Filter,
typename Node,
typename... Children>
43 struct apply_filter_wrapper<Filter,Node,
std::tuple<Children...> >
44 :
public Filter::template apply<Node,Children...>
48 template<
typename Filter>
49 struct get_filter<Filter,SimpleFilterTag>
53 template<
typename Node,
typename ChildTypes>
55 :
public apply_filter_wrapper<filter<Filter>,Node,ChildTypes>
61 template<
typename Filter>
62 struct get_filter<Filter,AdvancedFilterTag>
66 template<
typename Node,
typename ChildTypes>
68 :
public apply_filter_wrapper<Filter,Node,ChildTypes>
78 template<
typename Node,
typename Filter>
82 typedef typename get_filter<Filter,typename Filter::FilterTag>::type filter;
83 typedef typename filter::template apply<Node,typename Node::ChildTypes>::type filter_result;
84 typedef typename filter_result::template apply<Node> mapped_children;
86 static const bool nodeIsConst = std::is_const<typename std::remove_reference<Node>::type>::value;
88 template<std::
size_t k>
91 static const bool value = !nodeIsConst;
106 static const bool isLeaf =
false;
109 static const bool isPower =
false;
112 static const bool isComposite =
true;
115 static const std::size_t CHILDREN = filter_result::size;
119 return filter_result::size;
123 template<std::
size_t k>
128 typedef typename std::tuple_element<k,typename mapped_children::Children>::type OriginalChild;
130 static const std::size_t mapped_index = std::tuple_element<k,typename filter_result::IndexMap>::type::original_index;
138 typedef typename OriginalChild::type
type;
141 typedef typename OriginalChild::Storage
Storage;
154 template<std::
size_t k>
158 return _node->template child<Child<k>::mapped_index>();
165 template<std::
size_t k>
168 return _node->template child<Child<k>::mapped_index>();
175 template<std::
size_t k>
179 return _node->template childStorage<Child<k>::mapped_index>();
189 template<std::
size_t k>
192 return _node->template childStorage<Child<k>::mapped_index>();
196 template<std::
size_t k>
199 _node->template childStorage<Child<k>::mapped_index>() = stackobject_to_shared_ptr(child);
203 template<std::
size_t k>
206 _node->template childStorage<Child<k>::mapped_index>() = child;
220 template<
bool enabled = !nodeIsConst>
221 typename std::enable_if<enabled,Node&>::type
240 template<
bool enabled = !nodeIsConst>
241 typename std::enable_if<enabled,std::shared_ptr<Node> >::type
270 : _node(stackobject_to_shared_ptr(node))
276 std::shared_ptr<Node> _node;
284 #endif // DUNE_TYPETREE_FILTEREDCOMPOSITENODE_HH mapped_children::ChildTypes ChildTypes
A tuple storing the types of all children.
Definition: filteredcompositenode.hh:103
Access to the type and storage type of the i-th child.
Definition: filteredcompositenode.hh:124
ImplementationDefined child(Node &&node, Indices... indices)
Extracts the child of a node given by a sequence of compile-time and run-time indices.
Definition: childextraction.hh:179
Tag designating a composite node.
Definition: nodetags.hh:22
OriginalChild::type type
The type of the child.
Definition: filteredcompositenode.hh:138
void setChild(typename Child< k >::storage_type child, typename std::enable_if< lazy_enable< k >::value, void *>::type=0)
Sets the storage of the i-th child to the passed-in value.
Definition: filteredcompositenode.hh:204
OriginalChild::ConstStorage ConstStorage
The const storage type of the child.
Definition: filteredcompositenode.hh:144
std::enable_if< enabled, Node & >::type unfiltered()
Returns the unfiltered node.
Definition: filteredcompositenode.hh:222
Definition: accumulate_static.hh:13
const Child< k >::Type & child() const
Returns the i-th child (const version).
Definition: filteredcompositenode.hh:166
std::shared_ptr< const Node > unfilteredStorage() const
Returns the storage object of the unfiltered node (const version).
Definition: filteredcompositenode.hh:251
std::enable_if< enabled, std::shared_ptr< Node > >::type unfilteredStorage()
Returns the storage object of the unfiltered node.
Definition: filteredcompositenode.hh:242
mapped_children::NodeStorage NodeStorage
The type used for storing the children.
Definition: filteredcompositenode.hh:100
std::enable_if< lazy_enable< k >::value, typename Child< k >::Type & >::type child()
Returns the i-th child.
Definition: filteredcompositenode.hh:156
void setChild(typename Child< k >::type &child, typename std::enable_if< lazy_enable< k >::value, void *>::type=0)
Sets the i-th child to the passed-in value.
Definition: filteredcompositenode.hh:197
std::enable_if< lazy_enable< k >::value, typename Child< k >::Storage >::type childStorage()
Returns the storage of the i-th child.
Definition: filteredcompositenode.hh:177
OriginalChild::Storage Storage
The storage type of the child.
Definition: filteredcompositenode.hh:141
const Node & unfiltered() const
Returns the unfiltered node (const version).
Definition: filteredcompositenode.hh:231
CompositeNodeTag NodeTag
The type tag that describes a CompositeNode.
Definition: filteredcompositenode.hh:97
FilteredCompositeNode(Node &node)
Initialize the CompositeNode with a copy of the passed-in storage type.
Definition: filteredcompositenode.hh:269
OriginalChild::Type Type
The type of the child.
Definition: filteredcompositenode.hh:135
Child< k >::ConstStorage childStorage() const
Returns the storage of the i-th child (const version).
Definition: filteredcompositenode.hh:190
FilteredCompositeNode(std::shared_ptr< Node > node)
Initialize the CompositeNode with copies of the passed in Storage objects.
Definition: filteredcompositenode.hh:264
static constexpr std::size_t degree()
Definition: filteredcompositenode.hh:117
Base class for composite nodes representing a filtered view on an underlying composite node...
Definition: filteredcompositenode.hh:79
Type
Definition: treepath.hh:26