4 #ifndef DUNE_TYPETREE_FILTEREDCOMPOSITENODE_HH 5 #define DUNE_TYPETREE_FILTEREDCOMPOSITENODE_HH 12 #include <dune/common/shared_ptr.hh> 13 #include <dune/common/typetraits.hh> 34 template<
typename Filter,
typename Tag>
38 template<
typename Filter,
typename Node,
typename ChildTypes>
39 struct apply_filter_wrapper;
41 template<
typename Filter,
typename Node,
typename... Children>
42 struct apply_filter_wrapper<Filter,Node,
std::tuple<Children...> >
43 :
public Filter::template apply<Node,Children...>
47 template<
typename Filter>
48 struct get_filter<Filter,SimpleFilterTag>
52 template<
typename Node,
typename ChildTypes>
54 :
public apply_filter_wrapper<filter<Filter>,Node,ChildTypes>
60 template<
typename Filter>
61 struct get_filter<Filter,AdvancedFilterTag>
65 template<
typename Node,
typename ChildTypes>
67 :
public apply_filter_wrapper<Filter,Node,ChildTypes>
77 template<
typename Node,
typename Filter>
81 typedef typename get_filter<Filter,typename Filter::FilterTag>::type filter;
82 typedef typename filter::template apply<Node,typename Node::ChildTypes>::type filter_result;
83 typedef typename filter_result::template apply<Node> mapped_children;
85 static const bool nodeIsConst = IsConst<typename remove_reference<Node>::type>::value;
87 template<std::
size_t k>
90 static const bool value = !nodeIsConst;
105 static const bool isLeaf =
false;
108 static const bool isPower =
false;
111 static const bool isComposite =
true;
114 static const std::size_t CHILDREN = filter_result::size;
117 template<std::
size_t k>
122 typedef typename std::tuple_element<k,typename mapped_children::Children>::type OriginalChild;
124 static const std::size_t mapped_index = std::tuple_element<k,typename filter_result::IndexMap>::type::original_index;
132 typedef typename OriginalChild::type
type;
135 typedef typename OriginalChild::Storage
Storage;
148 template<std::
size_t k>
152 return _node->template child<Child<k>::mapped_index>();
159 template<std::
size_t k>
162 return _node->template child<Child<k>::mapped_index>();
169 template<std::
size_t k>
173 return _node->template childStorage<Child<k>::mapped_index>();
183 template<std::
size_t k>
186 return _node->template childStorage<Child<k>::mapped_index>();
190 template<std::
size_t k>
193 _node->template childStorage<Child<k>::mapped_index>() = stackobject_to_shared_ptr(child);
197 template<std::
size_t k>
200 _node->template childStorage<Child<k>::mapped_index>() = child;
214 template<
bool enabled = !nodeIsConst>
215 typename enable_if<enabled,Node&>::type
234 template<
bool enabled = !nodeIsConst>
235 typename enable_if<enabled,std::shared_ptr<Node> >::type
264 : _node(stackobject_to_shared_ptr(node))
270 std::shared_ptr<Node> _node;
278 #endif // DUNE_TYPETREE_FILTEREDCOMPOSITENODE_HH enable_if< lazy_enable< k >::value, typename Child< k >::Storage >::type childStorage()
Returns the storage of the i-th child.
Definition: filteredcompositenode.hh:171
const Child< k >::Type & child() const
Returns the i-th child (const version).
Definition: filteredcompositenode.hh:160
OriginalChild::Storage Storage
The storage type of the child.
Definition: filteredcompositenode.hh:135
Access to the type and storage type of the i-th child.
Definition: filteredcompositenode.hh:118
FilteredCompositeNode(std::shared_ptr< Node > node)
Initialize the CompositeNode with copies of the passed in Storage objects.
Definition: filteredcompositenode.hh:258
OriginalChild::type type
The type of the child.
Definition: filteredcompositenode.hh:132
OriginalChild::Type Type
The type of the child.
Definition: filteredcompositenode.hh:129
CompositeNodeTag NodeTag
The type tag that describes a CompositeNode.
Definition: filteredcompositenode.hh:96
OriginalChild::ConstStorage ConstStorage
The const storage type of the child.
Definition: filteredcompositenode.hh:138
enable_if< lazy_enable< k >::value, typename Child< k >::Type & >::type child()
Returns the i-th child.
Definition: filteredcompositenode.hh:150
enable_if< enabled, std::shared_ptr< Node > >::type unfilteredStorage()
Returns the storage object of the unfiltered node.
Definition: filteredcompositenode.hh:236
void setChild(typename Child< k >::storage_type child, typename enable_if< lazy_enable< k >::value, void * >::type=0)
Sets the storage of the i-th child to the passed-in value.
Definition: filteredcompositenode.hh:198
const Node & unfiltered() const
Returns the unfiltered node (const version).
Definition: filteredcompositenode.hh:225
Type
Definition: treepath.hh:26
FilteredCompositeNode(Node &node)
Initialize the CompositeNode with a copy of the passed-in storage type.
Definition: filteredcompositenode.hh:263
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:472
void setChild(typename Child< k >::type &child, typename enable_if< lazy_enable< k >::value, void * >::type=0)
Sets the i-th child to the passed-in value.
Definition: filteredcompositenode.hh:191
enable_if< enabled, Node & >::type unfiltered()
Returns the unfiltered node.
Definition: filteredcompositenode.hh:216
mapped_children::NodeStorage NodeStorage
The type used for storing the children.
Definition: filteredcompositenode.hh:99
mapped_children::ChildTypes ChildTypes
A tuple storing the types of all children.
Definition: filteredcompositenode.hh:102
Base class for composite nodes representing a filtered view on an underlying composite node...
Definition: filteredcompositenode.hh:78
Child< k >::ConstStorage childStorage() const
Returns the storage of the i-th child (const version).
Definition: filteredcompositenode.hh:184
Definition: accumulate_static.hh:12
std::shared_ptr< const Node > unfilteredStorage() const
Returns the storage object of the unfiltered node (const version).
Definition: filteredcompositenode.hh:245
Tag designating a composite node.
Definition: nodetags.hh:22