6#ifndef DUNE_TYPETREE_FILTERS_HH
7#define DUNE_TYPETREE_FILTERS_HH
11#include <dune/common/typetraits.hh>
22 template<std::
size_t new_k, std::
size_t old_k>
30 static const std::size_t filtered_index = new_k;
31 static const std::size_t original_index = old_k;
38 template<
typename... FilterEntries>
42 static const std::size_t
size =
sizeof...(FilterEntries);
46 template<
typename Node>
49 typedef std::tuple<typename Node::template Child<FilterEntries::original_index>...>
Children;
50 typedef std::tuple<typename Node::template Child<FilterEntries::original_index>::Type...>
ChildTypes;
51 typedef std::tuple<std::shared_ptr<typename Node::template Child<FilterEntries::original_index>::Type>...>
NodeStorage;
73 template<
typename Node,
typename... Children>
80 typedef implementation-defined
type;
101 template<
typename Node>
117 template<
typename Child, std::
size_t new_index, std::
size_t old_index>
132 template<
typename Node, std::size_t new_index, std::size_t... indices>
133 struct index_filter_helper
135 template<
typename... FilterEntries>
142 template<
typename Node, std::size_t new_index, std::size_t old_index, std::size_t... indices>
143 struct index_filter_helper<Node,new_index,old_index,indices...>
145 template<
typename... FilterEntries>
147 :
public index_filter_helper<Node,new_index+1,indices...>::template apply<FilterEntries...,
148 FilterEntry<new_index,
158 template<std::size_t... indices>
165 template<
typename Node,
typename... Children>
168 typedef typename index_filter_helper<Node,0,indices...>::template
apply<>::type type;
183 template<
typename Filter, std::size_t new_k, std::size_t old_k,
typename... tail>
186 template<
typename... FilterDescriptors>
193 template<
typename Filter, std::size_t new_k, std::size_t old_k,
typename child,
typename... tail>
194 struct filter_helper<Filter,new_k,old_k,
child,tail...>
197 template<
typename... FilterDescriptors>
199 :
public std::conditional<Filter::template apply<child,new_k,old_k>::value,
200 typename filter_helper<Filter,new_k+1,old_k+1,tail...>::template apply<FilterDescriptors...,FilterEntry<new_k,old_k> >,
201 typename filter_helper<Filter,new_k,old_k+1,tail...>::template apply<FilterDescriptors...>
210 template<
typename Filter>
215 template<
typename Node,
typename... Children>
219 static_assert((Filter::template validate<Node>::value),
"Invalid simple filter");
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:128
Definition accumulate_static.hh:16
A filter entry describing the mapping of one child in the filtered node.
Definition filters.hh:24
The result of a filter.
Definition filters.hh:40
std::tuple< FilterEntries... > IndexMap
Definition filters.hh:44
static const std::size_t size
Definition filters.hh:42
std::tuple< typename Node::template Child< FilterEntries::original_index >... > Children
Definition filters.hh:49
std::tuple< typename Node::template Child< FilterEntries::original_index >::Type... > ChildTypes
Definition filters.hh:50
std::tuple< std::shared_ptr< typename Node::template Child< FilterEntries::original_index >::Type >... > NodeStorage
Definition filters.hh:51
Tag describing a simple filter that can only decide whether or not to include a single given child.
Definition filters.hh:57
Tag describing an advanced filter that has full control over the construction of the list of FilterEn...
Definition filters.hh:60
Base class for advanced filters.
Definition filters.hh:65
AdvancedFilterTag FilterTag
Filter tag for deciding on filter application mechanism.
Definition filters.hh:68
Apply this filter to the given node and children.
Definition filters.hh:75
implementation defined type
The result of the filtering process.
Definition filters.hh:80
Default simple filter that accepts any node and leaves its child structure unchanged.
Definition filters.hh:94
SimpleFilterTag FilterTag
Filter tag for deciding on filter application mechanism.
Definition filters.hh:97
Validates the combination of filter and node.
Definition filters.hh:103
static const bool value
True if the combination of filter and node is valid.
Definition filters.hh:105
Applies the filter to the given child node.
Definition filters.hh:119
static const bool value
True if the child will be included in the filtered node.
Definition filters.hh:121
Filter class for FilteredCompositeNode that selects the children with the given indices.
Definition filters.hh:161
Adapter class that takes a SimpleFilter, validated it and turns it into an AdvancedFilter.
Definition filters.hh:212
Apply the filter.
Definition filters.hh:217
filter_helper< Filter, 0, 0, Children... >::template apply ::type type
Definition filters.hh:221