Go to the documentation of this file.
4 #ifndef DUNE_TYPETREE_PROXYNODE_HH
5 #define DUNE_TYPETREE_PROXYNODE_HH
10 #include <dune/common/shared_ptr.hh>
20 template<
typename Node>
24 template<
typename ProxiedNode>
28 static const bool proxiedNodeIsConst = std::is_const<typename std::remove_reference<ProxiedNode>::type>::value;
30 template<std::
size_t k>
33 static const bool value = !proxiedNodeIsConst;
38 template<
bool enabled = !proxiedNodeIsConst>
39 typename std::enable_if<enabled,Node&>::type
42 return static_cast<Node&>(*
this);
45 const Node& node()
const
47 return static_cast<const Node&>(*
this);
53 template<std::
size_t k>
55 :
public ProxiedNode::template
Child<k>
65 template<std::
size_t k>
66 typename std::enable_if<lazy_enabled<k>::value,
typename Child<k>::Type&>::type
69 return node().proxiedNode().template child<k>();
76 template<std::
size_t k>
79 return node().proxiedNode().template child<k>();
86 template<std::
size_t k>
90 return node().proxiedNode().template childStorage<k>();
100 template<std::
size_t k>
103 return node().proxiedNode().template childStorage<k>();
107 template<std::
size_t k>
110 node().proxiedNode().template childStorage<k>() = stackobject_to_shared_ptr(
child);
114 template<std::
size_t k>
117 node().proxiedNode().template childStorage<k>() =
child;
122 return node().proxiedNode().nodeStorage();
133 template<
typename ProxiedNode>
140 static const bool proxiedNodeIsConst = std::is_const<typename std::remove_reference<ProxiedNode>::type>::value;
142 template<
bool enabled = !proxiedNodeIsConst>
143 typename std::enable_if<enabled,Node&>::type
146 return static_cast<Node&>(*
this);
149 const Node& node()
const
151 return static_cast<const Node&>(*
this);
163 template<
bool enabled = !proxiedNodeIsConst>
164 typename std::enable_if<enabled,typename ProxiedNode::ChildType&>::type
167 return node().proxiedNode().child(i);
174 const typename ProxiedNode::ChildType&
child (std::size_t i)
const
176 return node().proxiedNode().child(i);
183 template<
bool enabled = !proxiedNodeIsConst>
184 typename std::enable_if<enabled,typename ProxiedNode::ChildStorageType>::type
187 return node().proxiedNode().childStorage(i);
197 typename ProxiedNode::ChildConstStorageType
childStorage (std::size_t i)
const
199 return node().proxiedNode().childStorage(i);
203 template<
bool enabled = !proxiedNodeIsConst>
204 void setChild (std::size_t i,
typename ProxiedNode::ChildType& t,
typename std::enable_if<enabled,void*>::type = 0)
206 node().proxiedNode().childStorage(i) = stackobject_to_shared_ptr(t);
210 template<
bool enabled = !proxiedNodeIsConst>
211 void setChild (std::size_t i,
typename ProxiedNode::ChildStorageType st,
typename std::enable_if<enabled,void*>::type = 0)
213 node().proxiedNode().childStorage(i) = st;
219 template<
typename Node,
typename NodeTag>
223 template<
typename Node>
229 template<
typename Node>
238 template<
typename Node>
254 template<
typename Node>
259 static const bool proxiedNodeIsConst = std::is_const<typename std::remove_reference<Node>::type>::value;
295 template<
bool enabled = !proxiedNodeIsConst>
296 typename std::enable_if<enabled,Node&>::type
309 template<
bool enabled = !proxiedNodeIsConst>
310 typename std::enable_if<enabled,shared_ptr<Node> >::type
328 : _node(stackobject_to_shared_ptr(node))
339 shared_ptr<Node> _node;
347 #endif // DUNE_TYPETREE_PROXYNODE_HH
typename std::decay_t< Node >::NodeTag NodeTag
Returns the node tag of the given Node.
Definition: nodeinterface.hh:62
ProxyNode(shared_ptr< Node > node)
Definition: proxynode.hh:331
ProxiedNode::ChildConstStorageType childStorage(std::size_t i) const
Returns the storage of the i-th child (const version).
Definition: proxynode.hh:197
void setChild(typename Child< k >::type &child, typename std::enable_if< lazy_enabled< k >::value, void * >::type=0)
Sets the i-th child to the passed-in value.
Definition: proxynode.hh:108
const ProxiedNode::NodeStorage & nodeStorage() const
Definition: proxynode.hh:120
Tag designating a composite node.
Definition: nodetags.hh:22
Mixin class providing methods for child access with run-time parameter.
Definition: proxynode.hh:134
ProxyNode(Node &node)
Definition: proxynode.hh:327
static const bool isPower
Mark this class as a non power in the dune-typetree.
Definition: proxynode.hh:275
Node::ChildTypes ChildTypes
Definition: proxynode.hh:233
typename impl::_Child< Node, indices... >::type Child
Template alias for the type of a child node given by a list of child indices.
Definition: childextraction.hh:307
static constexpr std::size_t degree()
Definition: proxynode.hh:283
Mixin class providing methods for child access with compile-time parameter.
Definition: proxynode.hh:25
Dune::TypeTree::NodeTag< Node > NodeTag
Definition: proxynode.hh:269
Definition: accumulate_static.hh:13
std::enable_if< lazy_enabled< k >::value, typename Child< k >::Type & >::type child()
Returns the i-th child.
Definition: proxynode.hh:67
Node::NodeStorage NodeStorage
Definition: proxynode.hh:243
static const std::size_t CHILDREN
The number of children.
Definition: proxynode.hh:281
void setChild(typename Child< k >::storage_type child, typename std::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:115
Node::ChildType ChildType
Definition: proxynode.hh:242
Node ProxiedNode
Definition: proxynode.hh:267
const Child< k >::Type & child() const
Returns the i-th child (const version).
Definition: proxynode.hh:77
Tag designating a power node.
Definition: nodetags.hh:19
std::enable_if< enabled, Node & >::type proxiedNode()
Returns the proxied node.
Definition: proxynode.hh:297
const Node & proxiedNode() const
Returns the proxied node (const version).
Definition: proxynode.hh:303
std::enable_if< enabled, typename ProxiedNode::ChildStorageType >::type childStorage(std::size_t i)
Returns the storage of the i-th child.
Definition: proxynode.hh:185
std::enable_if< enabled, shared_ptr< Node > >::type proxiedNodeStorage()
Returns the storage of the proxied node.
Definition: proxynode.hh:311
const ProxiedNode::ChildType & child(std::size_t i) const
Returns the i-th child (const version).
Definition: proxynode.hh:174
Tag designating a leaf node.
Definition: nodetags.hh:16
Access to the type and storage type of the i-th child.
Definition: proxynode.hh:54
void setChild(std::size_t i, typename ProxiedNode::ChildType &t, typename std::enable_if< enabled, void * >::type=0)
Sets the i-th child to the passed-in value.
Definition: proxynode.hh:204
void setChild(std::size_t i, typename ProxiedNode::ChildStorageType st, typename std::enable_if< enabled, void * >::type=0)
Sets the stored value representing the i-th child to the passed-in value.
Definition: proxynode.hh:211
std::enable_if< enabled, typename ProxiedNode::ChildType & >::type child(std::size_t i)
Returns the i-th child.
Definition: proxynode.hh:165
shared_ptr< const Node > proxiedNodeStorage() const
Returns the storage of the proxied node (const version).
Definition: proxynode.hh:317
static const bool isLeaf
Mark this class as non leaf in the dune-typetree.
Definition: proxynode.hh:272
Tag-based dispatch to appropriate base class that provides necessary functionality.
Definition: proxynode.hh:220
Child< k >::ConstStorage childStorage() const
Returns the storage of the i-th child (const version).
Definition: proxynode.hh:101
std::integral_constant< std::size_t, degree(static_cast< std::decay_t< Node > * >(nullptr), NodeTag< std::decay_t< Node > >()) > StaticDegree
Returns the statically known degree of the given Node type as a std::integral_constant.
Definition: nodeinterface.hh:105
std::enable_if< lazy_enabled< k >::value, typename Child< k >::Storage >::type childStorage()
Returns the storage of the i-th child.
Definition: proxynode.hh:88
Base class for nodes acting as a proxy for an existing node.
Definition: proxynode.hh:21
Node::NodeStorage NodeStorage
Definition: proxynode.hh:234
static const bool isComposite
Mark this class as a composite in the dune-typetree.
Definition: proxynode.hh:278