4 #ifndef DUNE_TYPETREE_PROXYNODE_HH
5 #define DUNE_TYPETREE_PROXYNODE_HH
8 #include <dune/common/shared_ptr.hh>
18 template<
typename Node>
22 template<
typename ProxiedNode>
26 static const bool proxiedNodeIsConst = IsConst<typename remove_reference<ProxiedNode>::type>
::value;
28 template<std::
size_t k>
31 static const bool value = !proxiedNodeIsConst;
36 template<
bool enabled = !proxiedNodeIsConst>
37 typename enable_if<enabled,Node&>::type
40 return static_cast<Node&
>(*this);
43 const Node& node()
const
45 return static_cast<const Node&
>(*this);
51 template<std::
size_t k>
53 :
public ProxiedNode::template
Child<k>
63 template<std::
size_t k>
67 return node().proxiedNode().template child<k>();
74 template<std::
size_t k>
77 return node().proxiedNode().template child<k>();
84 template<std::
size_t k>
88 return node().proxiedNode().template childStorage<k>();
98 template<std::
size_t k>
101 return node().proxiedNode().template childStorage<k>();
105 template<std::
size_t k>
108 node().proxiedNode().template childStorage<k>() = stackobject_to_shared_ptr(child);
112 template<std::
size_t k>
115 node().proxiedNode().template childStorage<k>() = child;
120 return node().proxiedNode().nodeStorage();
131 template<
typename ProxiedNode>
138 static const bool proxiedNodeIsConst = IsConst<typename remove_reference<ProxiedNode>::type>
::value;
140 template<
bool enabled = !proxiedNodeIsConst>
141 typename enable_if<enabled,Node&>::type
144 return static_cast<Node&
>(*this);
147 const Node& node()
const
149 return static_cast<const Node&
>(*this);
161 template<
bool enabled = !proxiedNodeIsConst>
162 typename enable_if<enabled,typename ProxiedNode::ChildType&>::type
165 return node().proxiedNode().child(i);
172 const typename ProxiedNode::ChildType&
child (std::size_t i)
const
174 return node().proxiedNode().child(i);
181 template<
bool enabled = !proxiedNodeIsConst>
182 typename enable_if<enabled,typename ProxiedNode::ChildStorageType>::type
185 return node().proxiedNode().childStorage(i);
195 typename ProxiedNode::ChildConstStorageType
childStorage (std::size_t i)
const
197 return node().proxiedNode().childStorage(i);
201 template<
bool enabled = !proxiedNodeIsConst>
202 void setChild (std::size_t i,
typename ProxiedNode::ChildType& t,
typename enable_if<enabled,void*>::type = 0)
204 node().proxiedNode().childStorage(i) = stackobject_to_shared_ptr(t);
208 template<
bool enabled = !proxiedNodeIsConst>
209 void setChild (std::size_t i,
typename ProxiedNode::ChildStorageType st,
typename enable_if<enabled,void*>::type = 0)
211 node().proxiedNode().childStorage(i) = st;
217 template<
typename Node,
typename NodeTag>
221 template<
typename Node>
227 template<
typename Node>
236 template<
typename Node>
245 template<
typename Node>
261 template<
typename Node>
266 static const bool proxiedNodeIsConst = IsConst<typename remove_reference<Node>::type>
::value;
288 static const std::size_t
CHILDREN = Node::CHILDREN;
297 template<
bool enabled = !proxiedNodeIsConst>
298 typename enable_if<enabled,Node&>::type
311 template<
bool enabled = !proxiedNodeIsConst>
312 typename enable_if<enabled,shared_ptr<Node> >::type
330 : _node(stackobject_to_shared_ptr(node))
341 shared_ptr<Node> _node;
349 #endif // DUNE_TYPETREE_PROXYNODE_HH
Mixin class providing methods for child access with run-time parameter.
Definition: proxynode.hh:132
void setChild(typename Child< k >::storage_type child, typename enable_if< lazy_enabled< k >::value, void * >::type=0)
Sets the storage of the i-th child to the passed-in value.
Definition: proxynode.hh:113
Node::ChildTypes ChildTypes
Definition: proxynode.hh:231
Node::NodeStorage NodeStorage
Definition: proxynode.hh:232
void setChild(std::size_t i, typename ProxiedNode::ChildStorageType st, typename enable_if< enabled, void * >::type=0)
Sets the stored value representing the i-th child to the passed-in value.
Definition: proxynode.hh:209
Node::NodeStorage NodeStorage
Definition: proxynode.hh:241
Tag designating a power node.
Definition: nodetags.hh:19
static const bool isComposite
Mark this class as a composite in the dune-typetree.
Definition: proxynode.hh:285
shared_ptr< const Node > proxiedNodeStorage() const
Returns the storage of the proxied node (const version).
Definition: proxynode.hh:319
ProxyNode(shared_ptr< Node > node)
Definition: proxynode.hh:333
Node::ChildType ChildType
Definition: proxynode.hh:249
ProxiedNode::ChildConstStorageType childStorage(std::size_t i) const
Returns the storage of the i-th child (const version).
Definition: proxynode.hh:195
Node::NodeStorage NodeStorage
Definition: proxynode.hh:250
static const std::size_t CHILDREN
The number of children.
Definition: proxynode.hh:288
const Node & proxiedNode() const
Returns the proxied node (const version).
Definition: proxynode.hh:305
Mixin class providing methods for child access with compile-time parameter.
Definition: proxynode.hh:23
enable_if< enabled, Node & >::type proxiedNode()
Returns the proxied node.
Definition: proxynode.hh:299
Node::ChildTypes ChildTypes
Definition: proxynode.hh:240
enable_if< enabled, shared_ptr< Node > >::type proxiedNodeStorage()
Returns the storage of the proxied node.
Definition: proxynode.hh:313
Tag-based dispatch to appropiate base class that provides necessary functionality.
Definition: proxynode.hh:218
void setChild(typename Child< k >::type &child, typename enable_if< lazy_enabled< k >::value, void * >::type=0)
Sets the i-th child to the passed-in value.
Definition: proxynode.hh:106
Tag designating a composite node that is based on variadic templates.
Definition: nodetags.hh:25
static const bool isLeaf
Mark this class as non leaf in the dune-typetree.
Definition: proxynode.hh:279
Access to the type and storage type of the i-th child.
Definition: proxynode.hh:52
Node::NodeTag NodeTag
Definition: proxynode.hh:276
enable_if< enabled, typename ProxiedNode::ChildStorageType >::type childStorage(std::size_t i)
Returns the storage of the i-th child.
Definition: proxynode.hh:183
const ProxiedNode::NodeStorage & nodeStorage() const
Definition: proxynode.hh:118
Node ProxiedNode
Definition: proxynode.hh:274
Child< k >::ConstStorage childStorage() const
Returns the storage of the i-th child (const version).
Definition: proxynode.hh:99
const Child< k >::Type & child() const
Returns the i-th child (const version).
Definition: proxynode.hh:75
void setChild(std::size_t i, typename ProxiedNode::ChildType &t, typename enable_if< enabled, void * >::type=0)
Sets the i-th child to the passed-in value.
Definition: proxynode.hh:202
enable_if< enabled, typename ProxiedNode::ChildType & >::type child(std::size_t i)
Returns the i-th child.
Definition: proxynode.hh:163
ProxyNode(Node &node)
Definition: proxynode.hh:329
Base class for nodes acting as a proxy for an existing node.
Definition: proxynode.hh:19
static const std::size_t value
Definition: compositenode.hh:38
enable_if< lazy_enabled< k >::value, typename Child< k >::Type & >::type child()
Returns the i-th child.
Definition: proxynode.hh:65
const ProxiedNode::ChildType & child(std::size_t i) const
Returns the i-th child (const version).
Definition: proxynode.hh:172
enable_if< lazy_enabled< k >::value, typename Child< k >::Storage >::type childStorage()
Returns the storage of the i-th child.
Definition: proxynode.hh:86
static const bool isPower
Mark this class as a non power in the dune-typetree.
Definition: proxynode.hh:282
Type
Definition: treepath.hh:26
Tag designating a leaf node.
Definition: nodetags.hh:16
Tag designating a composite node.
Definition: nodetags.hh:22