A node in a generic tree, which can contain an object by value. More...
#include <osvr/Util/TreeNode.h>
Inherits noncopyable, and operators< TreeNode< ValueType > >.
Public Types | |
typedef TreeNode< ValueType > | type |
This template instantiation's type. | |
typedef TreeNodePointer < ValueType >::type | ptr_type |
The pointer for holding this template instantiation - used primarily/only in holding the root node. | |
typedef type * | parent_ptr_type |
The pointer for accessing a node's parent. Does not confer ownership. | |
typedef ValueType | value_type |
The contained value type. | |
Public Member Functions | |
type & | getOrCreateChildByName (std::string const &name) |
Get the named child, creating it if it doesn't exist. | |
type const & | getChildByName (std::string const &name) const |
Get the named child, throwing NoSuchChild if it doesn't exist. | |
std::string const & | getName () const |
Gets the name of the current node. This will be empty if and only if this is the root. | |
bool | isRoot () const |
Is the current node a root node? | |
parent_ptr_type | getParent () const |
Gets the node's parent, or nullptr if no parent (root node) | |
bool | hasChildren () const |
Does the node have any children? More... | |
size_t | numChildren () const |
How many children does the node have? | |
value_type & | value () |
Reference accessor for contained value. | |
value_type const & | value () const |
Const reference accessor for contained value. | |
template<typename F > | |
void | visitChildren (F &visitor) |
Generic visitation method that calls a functor on each of the children in an undefined order. More... | |
template<typename F > | |
void | visitConstChildren (F &visitor) const |
Generic constant visitation method that calls a functor on each of the children (as const) in an undefined order. | |
template<typename F > | |
void | visitChildren (F &visitor) const |
Generic constant visitation method that calls a functor on each of the children in an undefined order. More... | |
bool | operator== (const type &x) const |
Equality comparison operator - tests object identity. | |
Static Public Member Functions | |
static type & | create (TreeNode &parent, std::string const &name) |
Create a child tree node. More... | |
static type & | create (TreeNode &parent, std::string const &name, value_type const &val) |
Create a child tree node with a value. More... | |
static ptr_type | createRoot () |
Create a root. | |
static ptr_type | createRoot (value_type const &val) |
Create a root with a value. | |
A node in a generic tree, which can contain an object by value.
ValueType | The contained value type: must be default-constructible. |
Key features:
Definition at line 72 of file TreeNode.h.
|
inlinestatic |
Create a child tree node.
std::logic_error | if a child of that name already exists or if the name provided is empty. |
Definition at line 209 of file TreeNode.h.
|
inlinestatic |
Create a child tree node with a value.
std::logic_error | if a child of that name already exists or if the name provided is empty. |
Definition at line 223 of file TreeNode.h.
|
inline |
Does the node have any children?
May be faster than testing numChildren() != 0
Definition at line 291 of file TreeNode.h.
|
inline |
Generic visitation method that calls a functor on each of the children in an undefined order.
Using indices and re-evaluating size each time to safely handle visitors that add things.
Definition at line 141 of file TreeNode.h.
|
inline |
Generic constant visitation method that calls a functor on each of the children in an undefined order.
Definition at line 162 of file TreeNode.h.