4 #ifndef DUNE_TYPETREE_FILTERS_HH 5 #define DUNE_TYPETREE_FILTERS_HH 9 #include <dune/common/typetraits.hh> 19 template<std::
size_t new_k, std::
size_t old_k>
28 static const std::size_t filtered_index = new_k;
29 static const std::size_t original_index = old_k;
36 template<
typename... FilterEntries>
40 static const std::size_t size =
sizeof...(FilterEntries);
44 template<
typename Node>
47 typedef std::tuple<typename Node::template Child<FilterEntries::original_index>...>
Children;
49 typedef std::tuple<typename Node::template Child<FilterEntries::original_index>::Storage...>
NodeStorage;
71 template<
typename Node,
typename... Children>
78 typedef implementation-defined
type;
99 template<
typename Node>
103 static const bool value =
true;
115 template<
typename Child, std::
size_t new_index, std::
size_t old_index>
119 static const bool value =
true;
130 template<
typename Node, std::size_t new_index, std::size_t... indices>
131 struct index_filter_helper
133 template<
typename... FilterEntries>
140 template<
typename Node, std::size_t new_index, std::size_t old_index, std::size_t... indices>
141 struct index_filter_helper<Node,new_index,old_index,indices...>
143 template<
typename... FilterEntries>
145 :
public index_filter_helper<Node,new_index+1,indices...>::template
apply<FilterEntries...,
146 FilterEntry<new_index,
156 template<std::size_t... indices>
163 template<
typename Node,
typename... Children>
166 typedef typename index_filter_helper<Node,0,indices...>::template
apply<>::type type;
181 template<
typename Filter, std::size_t new_k, std::size_t old_k,
typename... tail>
184 template<
typename... FilterDescriptors>
191 template<
typename Filter, std::size_t new_k, std::size_t old_k,
typename child,
typename... tail>
192 struct filter_helper<Filter,new_k,old_k,child,tail...>
195 template<
typename... FilterDescriptors>
197 :
public std::conditional<Filter::template apply<child,new_k,old_k>::value,
198 typename filter_helper<Filter,new_k+1,old_k+1,tail...>::template apply<FilterDescriptors...,FilterEntry<new_k,old_k> >,
199 typename filter_helper<Filter,new_k,old_k+1,tail...>::template apply<FilterDescriptors...>
208 template<
typename Filter>
213 template<
typename Node,
typename... Children>
217 static_assert((Filter::template validate<Node>::value),
"Invalid simple filter");
219 typedef typename filter_helper<Filter,0,0,Children...>::template
apply<>::type type;
230 #endif // DUNE_TYPETREE_FILTERS_HH filter_helper< Filter, 0, 0, Children... >::template apply ::type type
Definition: filters.hh:217
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
Type
Definition: treepath.hh:26
Definition: accumulate_static.hh:13
std::tuple< typename Node::template Child< FilterEntries::original_index >::Storage... > NodeStorage
Definition: filters.hh:49
Tag describing a simple filter that can only decide whether or not to include a single given child...
Definition: filters.hh:55
std::tuple< typename Node::template Child< FilterEntries::original_index >... > Children
Definition: filters.hh:47
Apply the filter.
Definition: filters.hh:214
Validates the combination of filter and node.
Definition: filters.hh:100
A filter entry describing the mapping of one child in the filtered node.
Definition: filters.hh:21
Adapter class that takes a SimpleFilter, validated it and turns it into an AdvancedFilter.
Definition: filters.hh:209
Base class for advanced filters.
Definition: filters.hh:62
Definition: filters.hh:45
Default simple filter that accepts any node and leaves its child structure unchanged.
Definition: filters.hh:91
Tag describing an advanced filter that has full control over the construction of the list of FilterEn...
Definition: filters.hh:58
AdvancedFilterTag FilterTag
Filter tag for deciding on filter application mechanism.
Definition: filters.hh:66
The result of a filter.
Definition: filters.hh:37
std::tuple< FilterEntries... > IndexMap
Definition: filters.hh:42
std::tuple< typename Node::template Child< FilterEntries::original_index >::Type... > ChildTypes
Definition: filters.hh:48
Applies the filter to the given child node.
Definition: filters.hh:116
Apply this filter to the given node and children.
Definition: filters.hh:72
implementation defined type
The result of the filtering process.
Definition: filters.hh:78
SimpleFilterTag FilterTag
Filter tag for deciding on filter application mechanism.
Definition: filters.hh:95
Filter class for FilteredCompositeNode that selects the children with the given indices.
Definition: filters.hh:157