4 #ifndef DUNE_TYPETREE_COMPOSITENODE_HH
5 #define DUNE_TYPETREE_COMPOSITENODE_HH
8 #include <dune/common/tuples.hh>
9 #include <dune/common/shared_ptr.hh>
19 template<
typename... Children>
45 static const std::size_t
CHILDREN =
sizeof...(Children);
48 template<std::
size_t k>
51 static_assert((k < CHILDREN),
"child index out of range");
54 typedef typename tuple_element<k,ChildTypes>::type
Type;
57 typedef typename tuple_element<k,ChildTypes>::type
type;
60 typedef typename tuple_element<k,NodeStorage>::type
Storage;
63 typedef shared_ptr<const typename tuple_element<k,ChildTypes>::type>
ConstStorage;
73 template<std::
size_t k>
76 return *get<k>(_children);
83 template<std::
size_t k>
86 return *get<k>(_children);
93 template<std::
size_t k>
96 return get<k>(_children);
106 template<std::
size_t k>
109 return get<k>(_children);
113 template<std::
size_t k>
116 get<k>(_children) = stackobject_to_shared_ptr(child);
120 template<std::
size_t k>
123 get<k>(_children) = child;
150 template<
typename... Args,
typename =
typename enable_if<(
sizeof...(Args) == CHILDREN)>::type>
152 : _children(convert_arg(
std::forward<Args>(args))...)
157 : _children(children...)
162 : _children(children)
176 #endif // DUNE_TYPETREE_COMPOSITENODE_HH
tuple_element< k, NodeStorage >::type Storage
The storage type of the child.
Definition: compositenode.hh:60
static const bool isPower
Mark this class as a non power in the dune-typetree.
Definition: compositenode.hh:39
Definition: accumulate_static.hh:12
void setChild(typename Child< k >::Type &child)
Sets the i-th child to the passed-in value.
Definition: compositenode.hh:114
CompositeNode(const NodeStorage &children)
Initialize the CompositeNode with a copy of the passed-in storage type.
Definition: compositenode.hh:161
tuple_element< k, ChildTypes >::type Type
The type of the child.
Definition: compositenode.hh:51
const NodeStorage & nodeStorage() const
Definition: compositenode.hh:126
CompositeNodeTag NodeTag
The type tag that describes a CompositeNode.
Definition: compositenode.hh:27
Tag designating a composite node.
Definition: nodetags.hh:22
shared_ptr< const typename tuple_element< k, ChildTypes >::type > ConstStorage
The const storage type of the child.
Definition: compositenode.hh:63
Child< k >::ConstStorage childStorage() const
Returns the storage of the i-th child (const version).
Definition: compositenode.hh:107
const Child< k >::Type & child() const
Returns the i-th child (const version).
Definition: compositenode.hh:84
CompositeNode()
Default constructor.
Definition: compositenode.hh:146
Base class for composite nodes based on variadic templates.
Definition: compositenode.hh:21
CompositeNode(shared_ptr< Children >...children)
Initialize the CompositeNode with copies of the passed in Storage objects.
Definition: compositenode.hh:156
Access to the type and storage type of the i-th child.
Definition: compositenode.hh:49
Child< k >::Storage childStorage()
Returns the storage of the i-th child.
Definition: compositenode.hh:94
static const bool isComposite
Mark this class as a composite in the dune-typetree.
Definition: compositenode.hh:42
static const bool isLeaf
Mark this class as non leaf in the dune-typetree.
Definition: compositenode.hh:36
void setChild(typename Child< k >::Storage child)
Sets the storage of the i-th child to the passed-in value.
Definition: compositenode.hh:121
tuple< shared_ptr< Children >... > NodeStorage
The type used for storing the children.
Definition: compositenode.hh:30
CompositeNode(Args &&...args)
Initialize all children with the passed-in objects.
Definition: compositenode.hh:151
Child< k >::Type & child()
Returns the i-th child.
Definition: compositenode.hh:74
static const std::size_t CHILDREN
The number of children.
Definition: compositenode.hh:45
tuple< Children...> ChildTypes
A tuple storing the types of all children.
Definition: compositenode.hh:33
tuple_element< k, ChildTypes >::type type
The type of the child.
Definition: compositenode.hh:57