4 #ifndef DUNE_TYPETREE_FILTERS_HH
5 #define DUNE_TYPETREE_FILTERS_HH
7 #include <dune/common/tuples.hh>
8 #include <dune/common/typetraits.hh>
18 template<std::
size_t new_k, std::
size_t old_k>
27 static const std::size_t filtered_index = new_k;
28 static const std::size_t original_index = old_k;
35 template<
typename... FilterEntries>
39 static const std::size_t
size =
sizeof...(FilterEntries);
43 template<
typename Node>
46 typedef tuple<typename Node::template Child<FilterEntries::original_index>...>
Children;
48 typedef tuple<typename Node::template Child<FilterEntries::original_index>::Storage...>
NodeStorage;
70 template<
typename Node,
typename... Children>
77 typedef implementation-defined
type;
98 template<
typename Node>
114 template<
typename Child, std::
size_t new_index, std::
size_t old_index>
129 template<
typename Node, std::size_t new_index, std::size_t... indices>
130 struct index_filter_helper
132 template<
typename... FilterEntries>
139 template<
typename Node, std::size_t new_index, std::size_t old_index, std::size_t... indices>
140 struct index_filter_helper<Node,new_index,old_index,indices...>
142 template<
typename... FilterEntries>
144 :
public index_filter_helper<Node,new_index+1,indices...>::template apply<FilterEntries...,
145 FilterEntry<new_index,
155 template<std::size_t... indices>
162 template<
typename Node,
typename... Children>
165 typedef typename index_filter_helper<Node,0,indices...>::template
apply<>::type type;
180 template<
typename Filter, std::size_t new_k, std::size_t old_k,
typename... tail>
183 template<
typename... FilterDescriptors>
190 template<
typename Filter, std::size_t new_k, std::size_t old_k,
typename child,
typename... tail>
191 struct filter_helper<Filter,new_k,old_k,child,tail...>
194 template<
typename... FilterDescriptors>
196 :
public Dune::conditional<Filter::template apply<child,new_k,old_k>::value,
197 typename filter_helper<Filter,new_k+1,old_k+1,tail...>::template apply<FilterDescriptors...,FilterEntry<new_k,old_k> >,
198 typename filter_helper<Filter,new_k,old_k+1,tail...>::template apply<FilterDescriptors...>
207 template<
typename Filter>
212 template<
typename Node,
typename... Children>
216 static_assert((Filter::template validate<Node>::value),
"Invalid simple filter");
218 typedef typename filter_helper<Filter,0,0,Children...>::template
apply<>::type type;
229 #endif // DUNE_TYPETREE_FILTERS_HH
Validates the combination of filter and node.
Definition: filters.hh:99
Apply this filter to the given node and children.
Definition: filters.hh:71
Default simple filter that accepts any node and leaves its child structure unchanged.
Definition: filters.hh:90
SimpleFilterTag FilterTag
Filter tag for deciding on filter application mechanism.
Definition: filters.hh:94
Definition: accumulate_static.hh:12
implementation defined type
The result of the filtering process.
Definition: filters.hh:77
filter_helper< Filter, 0, 0, Children...>::template apply::type type
Definition: filters.hh:216
static const bool value
True if the child will be included in the filtered node.
Definition: filters.hh:118
tuple< typename Node::template Child< FilterEntries::original_index >::Type...> ChildTypes
Definition: filters.hh:47
Tag describing an advanced filter that has full control over the construction of the list of FilterEn...
Definition: filters.hh:57
Definition: filters.hh:44
Apply the filter.
Definition: filters.hh:213
static const bool value
True if the combination of filter and node is valid.
Definition: filters.hh:102
Adapter class that takes a SimpleFilter, validated it and turns it into an AdvancedFilter.
Definition: filters.hh:208
Base class for advanced filters.
Definition: filters.hh:61
The result of a filter.
Definition: filters.hh:36
Filter class for FilteredCompositeNode that selects the children with the given indices.
Definition: filters.hh:156
tuple< FilterEntries...> IndexMap
Definition: filters.hh:41
Type
Definition: treepath.hh:25
Applies the filter to the given child node.
Definition: filters.hh:115
tuple< typename Node::template Child< FilterEntries::original_index >...> Children
Definition: filters.hh:46
static const std::size_t size
Definition: filters.hh:39
A filter entry describing the mapping of one child in the filtered node.
Definition: filters.hh:20
tuple< typename Node::template Child< FilterEntries::original_index >::Storage...> NodeStorage
Definition: filters.hh:48
Tag describing a simple filter that can only decide whether or not to include a single given child...
Definition: filters.hh:54
AdvancedFilterTag FilterTag
Filter tag for deciding on filter application mechanism.
Definition: filters.hh:65