4 #ifndef DUNE_TYPETREE_FILTERS_HH
5 #define DUNE_TYPETREE_FILTERS_HH
9 #include <dune/common/typetraits.hh>
20 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;
71 template<
typename Node,
typename... Children>
78 typedef implementation-defined
type;
99 template<
typename Node>
115 template<
typename Child, std::
size_t new_index, std::
size_t old_index>
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");
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:126
Definition: accumulate_static.hh:13
Type
Definition: treepath.hh:30
A filter entry describing the mapping of one child in the filtered node.
Definition: filters.hh:22
The result of a filter.
Definition: filters.hh:38
std::tuple< FilterEntries... > IndexMap
Definition: filters.hh:42
static const std::size_t size
Definition: filters.hh:40
Definition: filters.hh:46
std::tuple< typename Node::template Child< FilterEntries::original_index >... > Children
Definition: filters.hh:47
std::tuple< typename Node::template Child< FilterEntries::original_index >::Type... > ChildTypes
Definition: filters.hh:48
std::tuple< std::shared_ptr< typename Node::template Child< FilterEntries::original_index >::Type >... > 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
Tag describing an advanced filter that has full control over the construction of the list of FilterEn...
Definition: filters.hh:58
Base class for advanced filters.
Definition: filters.hh:63
AdvancedFilterTag FilterTag
Filter tag for deciding on filter application mechanism.
Definition: filters.hh:66
Apply this filter to the given node and children.
Definition: filters.hh:73
implementation defined type
The result of the filtering process.
Definition: filters.hh:78
Default simple filter that accepts any node and leaves its child structure unchanged.
Definition: filters.hh:92
SimpleFilterTag FilterTag
Filter tag for deciding on filter application mechanism.
Definition: filters.hh:95
Validates the combination of filter and node.
Definition: filters.hh:101
static const bool value
True if the combination of filter and node is valid.
Definition: filters.hh:103
Applies the filter to the given child node.
Definition: filters.hh:117
static const bool value
True if the child will be included in the filtered node.
Definition: filters.hh:119
Filter class for FilteredCompositeNode that selects the children with the given indices.
Definition: filters.hh:159
Adapter class that takes a SimpleFilter, validated it and turns it into an AdvancedFilter.
Definition: filters.hh:210
Apply the filter.
Definition: filters.hh:215
filter_helper< Filter, 0, 0, Children... >::template apply ::type type
Definition: filters.hh:217