ROSE
0.11.87.0
|
An edge from a parent to a child.
An edge is the inter-node link between a parent node and a child node. The ChildEdge type is only allowed for data members of a Node and is how the node defines which data members participate as edges in the tree.
To create a node and define that it points to two child nodes, one must declare the two child pointers using the ChildEdge type, and then initialize the parent end of the edges during construction, as follows:
It is also possible to give non-null values to the child ends of the edges during construction:
The ChildEdge members are used as if they were pointers:
#include <util/Sawyer/Tree.h>
Public Member Functions | |
ChildEdge (Node *container) | |
Points to no child. More... | |
ChildEdge (Node *container, const std::shared_ptr< T > &child) | |
Constructor that points to a child. More... | |
ChildEdge (const ChildEdge &)=delete | |
ChildEdge & | operator= (const std::shared_ptr< T > &child) |
Point to a child node. More... | |
void | reset () |
Cause this edge to point to no child. More... | |
std::shared_ptr< T > | operator-> () const |
Obtain shared pointer. More... | |
T & | operator* () const |
Obtain pointed-to node. More... | |
operator bool () const | |
Conversion to bool. More... | |
std::shared_ptr< T > | shared () const |
Pointer to the child. More... | |
operator std::shared_ptr< T > () const | |
Implicit conversion to shared pointer. More... | |
|
explicit |
Sawyer::Tree::ChildEdge< T >::ChildEdge | ( | Node * | container, |
const std::shared_ptr< T > & | child | ||
) |
|
inline |
|
inline |
|
inline |
Obtain shared pointer.
Definition at line 231 of file Tree.h.
References Sawyer::Tree::ChildEdge< T >::shared().
|
inline |
Obtain pointed-to node.
Definition at line 236 of file Tree.h.
References Sawyer::Tree::ChildEdge< T >::shared().
|
inlineexplicit |
Conversion to bool.
Definition at line 242 of file Tree.h.
References Sawyer::Tree::ChildEdge< T >::shared().
std::shared_ptr< T > Sawyer::Tree::ChildEdge< T >::shared | ( | ) | const |
Pointer to the child.
Definition at line 938 of file Tree.h.
References Sawyer::Tree::Node::children.
Referenced by Sawyer::Tree::ChildEdge< T >::operator bool(), Sawyer::Tree::ChildEdge< T >::operator std::shared_ptr< T >(), Sawyer::Tree::ChildEdge< T >::operator*(), and Sawyer::Tree::ChildEdge< T >::operator->().
|
inline |
Implicit conversion to shared pointer.
Definition at line 250 of file Tree.h.
References Sawyer::Tree::ChildEdge< T >::shared().