4 #ifndef DUNE_TYPETREE_FILTERS_HH
5 #define DUNE_TYPETREE_FILTERS_HH
7 #if !(HAVE_VARIADIC_TEMPLATES || DOXYGEN || HEADERCHECK)
8 #error The class FilteredCompositeNode requires compiler support for variadic templates, which your compiler lacks.
11 #if (HAVE_VARIADIC_TEMPLATES || DOXYGEN)
12 #include <dune/common/static_assert.hh>
13 #include <dune/common/tuples.hh>
14 #include <dune/common/typetraits.hh>
24 template<std::
size_t new_k, std::
size_t old_k>
33 static const std::size_t filtered_index = new_k;
34 static const std::size_t original_index = old_k;
41 template<
typename... FilterEntries>
45 static const std::size_t
size =
sizeof...(FilterEntries);
49 template<
typename Node>
52 typedef tuple<typename Node::template Child<FilterEntries::original_index>...>
Children;
54 typedef tuple<typename Node::template Child<FilterEntries::original_index>::Storage...>
NodeStorage;
76 template<
typename Node,
typename... Children>
83 typedef implementation-defined
type;
104 template<
typename Node>
120 template<
typename Child, std::
size_t new_index, std::
size_t old_index>
135 template<
typename Node, std::size_t new_index, std::size_t... indices>
136 struct index_filter_helper
138 template<
typename... FilterEntries>
145 template<
typename Node, std::size_t new_index, std::size_t old_index, std::size_t... indices>
146 struct index_filter_helper<Node,new_index,old_index,indices...>
148 template<
typename... FilterEntries>
150 :
public index_filter_helper<Node,new_index+1,indices...>::template apply<FilterEntries...,
151 FilterEntry<new_index,
161 template<std::size_t... indices>
168 template<
typename Node,
typename... Children>
171 typedef typename index_filter_helper<Node,0,indices...>::template
apply<>::type type;
186 template<
typename Filter, std::size_t new_k, std::size_t old_k,
typename... tail>
189 template<
typename... FilterDescriptors>
196 template<
typename Filter, std::size_t new_k, std::size_t old_k,
typename child,
typename... tail>
197 struct filter_helper<Filter,new_k,old_k,child,tail...>
200 template<
typename... FilterDescriptors>
202 :
public Dune::conditional<Filter::template apply<child,new_k,old_k>::value,
203 typename filter_helper<Filter,new_k+1,old_k+1,tail...>::template apply<FilterDescriptors...,FilterEntry<new_k,old_k> >,
204 typename filter_helper<Filter,new_k,old_k+1,tail...>::template apply<FilterDescriptors...>
213 template<
typename Filter>
218 template<
typename Node,
typename... Children>
235 #endif // (HAVE_VARIADIC_TEMPLATES || DOXYGEN)
237 #endif // DUNE_TYPETREE_FILTERS_HH
Apply this filter to the given node and children.
Definition: filters.hh:77
Filter class for FilteredCompositeNode that selects the children with the given indices.
Definition: filters.hh:162
tuple< FilterEntries...> IndexMap
Definition: filters.hh:47
The result of a filter.
Definition: filters.hh:42
implementation defined type
The result of the filtering process.
Definition: filters.hh:83
filter_helper< Filter, 0, 0, Children...>::template apply::type type
Definition: filters.hh:224
static const bool value
True if the child will be included in the filtered node.
Definition: filters.hh:124
tuple< typename Node::template Child< FilterEntries::original_index >::Type...> ChildTypes
Definition: filters.hh:53
Tag describing an advanced filter that has full control over the construction of the list of FilterEn...
Definition: filters.hh:63
Definition: filters.hh:50
Apply the filter.
Definition: filters.hh:219
Validates the combination of filter and node.
Definition: filters.hh:105
dune_static_assert((Filter::template validate< Node >::value),"Invalid simple filter")
Tag describing a simple filter that can only decide whether or not to include a single given child...
Definition: filters.hh:60
A filter entry describing the mapping of one child in the filtered node.
Definition: filters.hh:26
Base class for advanced filters.
Definition: filters.hh:67
Adapter class that takes a SimpleFilter, validated it and turns it into an AdvancedFilter.
Definition: filters.hh:214
Applies the filter to the given child node.
Definition: filters.hh:121
tuple< typename Node::template Child< FilterEntries::original_index >...> Children
Definition: filters.hh:52
tuple< typename Node::template Child< FilterEntries::original_index >::Storage...> NodeStorage
Definition: filters.hh:54
static const std::size_t value
Definition: compositenode.hh:38
AdvancedFilterTag FilterTag
Filter tag for deciding on filter application mechanism.
Definition: filters.hh:71
Default simple filter that accepts any node and leaves its child structure unchanged.
Definition: filters.hh:96
static const std::size_t size
Definition: filters.hh:45
Type
Definition: treepath.hh:26
SimpleFilterTag FilterTag
Filter tag for deciding on filter application mechanism.
Definition: filters.hh:100
static const bool value
True if the combination of filter and node is valid.
Definition: filters.hh:108