|
libpsynth 0.2.1
|
A tree node. More...
#include <tree.hpp>

Public Types | |
| typedef std::unique_ptr< Node > | node_ptr |
| Pointer to the node type. | |
| typedef ptr_iterator < map_iterator< Key, node_ptr > > | iterator |
| Iterator to check the childs of this node. | |
| typedef ptr_const_iterator < map_const_iterator< Key, std::unique_ptr< Node > > > | const_iterator |
| Iterator to check the childs of this node, const version. | |
| typedef Traits | traits |
| Traits being used in this instanciation. | |
Public Member Functions | |
| tree_node () | |
| Constuctor. | |
| ~tree_node () | |
| Destructor. | |
| iterator | begin () |
| Returns an iterator to the first child of this node. | |
| const_iterator | begin () const |
| Returns an iterator to the first child of this node. | |
| iterator | end () |
| Returns an iterator to the end of this node childs. | |
| const_iterator | end () const |
| Returns an iterator to the end of this node childs. | |
| const Node * | parent () const |
Returns a pointer to the parent of this node or null if this is a root node. | |
| Node * | parent () |
Returns a pointer to the parent of this node or null if this is a root node. | |
| const Key & | name () const |
| Returns the name of this node. | |
| iterator | find_child (const Key &name) |
| Returns an iterator to a child given by its key or end () otherwise. | |
| const_iterator | find_child (const Key &name) const |
| Returns an iterator to a child given by its key or end () otherwise. | |
| node_ptr | detach (const Key &name) |
| Detaches a node from the tree. | |
| iterator | remove_child (const Key &name) |
| Deletes a child of this node. | |
| bool | attach (const Key &name, node_ptr node) |
| Attaches a node to a tree. | |
| node_ptr | detach (iterator iter) |
| Detaches a node from the tree. | |
| Key | path_name () const |
| Returns the path of this node from the root to the node. | |
| iterator | remove_child (iterator iter) |
| Deletes a child of this node. | |
| void | clear_childs () |
| Removes all childs. | |
| Node & | child (const Key &name) |
| Returns a reference to the child of this node mathing a name. | |
| Node & | existing_child (const Key &name) |
| Returns a reference to the child of this node mathing a name, throwing an exception if the node does not exist. | |
| const Node & | existing_child (const Key &name) const |
| Returns a reference to the child of this node mathing a name, throwing an exception if the node does not exist. | |
| Node & | path (const Key &name) |
| Returns a reference to the child matching a path. | |
| Node & | existing_path (const Key &name) |
| Returns a reference to the child matching a path, an exception is thrown if the path does not exist. | |
| const Node & | existing_path (const Key &name) const |
| Returns a reference to the child matching a path, an exception is thrown if the path does not exist. | |
Protected Member Functions | |
| virtual void | on_new_child (Node &node) |
| virtual void | on_remove_child (Node &node) |
| virtual void | on_init () |
| virtual void | on_uninit () |
A tree node.
This class in intended to be used by inheriting from it, so you directly gain a tree interface for a composite type. You should pass it the derived class as type parameter.
Note that the void sequence is a valid name, so the key string "..." denotes the node "" -> "" -> "" -> "".
| Node | The type of the class that is inheriting from us. |
| Key | They type of the class that identifies tree nodes. It must be some kind of compound type and in the current implementation it must have std::string semantics. |
| Traits | Additional information about the key type that is used to compose the paths. |
| ThreadingPolicy | Wether you want your tree type to be thread-safe. Note that to avoid problems when creating mix-ins tree_node won't inherit from ThreadingPolicy but it will expect you to do so (it uses Node::lock). |
Fix copy operations.
Fix string operations to be more generic.
Add value_type and other container typedefs.
| typedef ptr_const_iterator<map_const_iterator<Key, std::unique_ptr<Node> > > psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::const_iterator |
Iterator to check the childs of this node, const version.
| typedef ptr_iterator<map_iterator<Key, node_ptr > > psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::iterator |
Iterator to check the childs of this node.
| typedef std::unique_ptr<Node> psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::node_ptr |
Pointer to the node type.
| typedef Traits psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::traits |
Traits being used in this instanciation.
| psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::tree_node | ( | ) | [inline] |
Constuctor.
| psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::~tree_node | ( | ) |
Destructor.
| bool psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::attach | ( | const Key & | name, |
| node_ptr | node | ||
| ) |
Attaches a node to a tree.
Note that this wil fail if the node is already attached to another tree or if the selected key is already used by another child of this tree.
| const_iterator psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::begin | ( | ) | const [inline] |
Returns an iterator to the first child of this node.
Const version.
| iterator psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::begin | ( | ) | [inline] |
Returns an iterator to the first child of this node.
| Node& psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::child | ( | const Key & | name | ) |
Returns a reference to the child of this node mathing a name.
The child is created if it does not exist yet.
| name | The name of the child. |
| void psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::clear_childs | ( | ) |
Removes all childs.
| node_ptr psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::detach | ( | const Key & | name | ) | [inline] |
Detaches a node from the tree.
Once detached you are responsible of freeing the node memory. If the key does not refer to a node it throws an exception.
| node_ptr psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::detach | ( | iterator | iter | ) |
Detaches a node from the tree.
Once detached you are responsible of freeing the node memory. If the iterator points to end () it throws an exception.
| const_iterator psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::end | ( | ) | const [inline] |
Returns an iterator to the end of this node childs.
Const version.
| iterator psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::end | ( | ) | [inline] |
Returns an iterator to the end of this node childs.
| Node& psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::existing_child | ( | const Key & | name | ) |
Returns a reference to the child of this node mathing a name, throwing an exception if the node does not exist.
| name | The name of the child. |
| const Node& psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::existing_child | ( | const Key & | name | ) | const |
Returns a reference to the child of this node mathing a name, throwing an exception if the node does not exist.
| name | The name of the child. |
| Node& psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::existing_path | ( | const Key & | name | ) |
Returns a reference to the child matching a path, an exception is thrown if the path does not exist.
| name | The path to find. |
| const Node& psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::existing_path | ( | const Key & | name | ) | const |
Returns a reference to the child matching a path, an exception is thrown if the path does not exist.
| name | The path to find. |
| iterator psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::find_child | ( | const Key & | name | ) | [inline] |
Returns an iterator to a child given by its key or end () otherwise.
| name | The key name of the child. |
| const_iterator psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::find_child | ( | const Key & | name | ) | const [inline] |
Returns an iterator to a child given by its key or end () otherwise.
| name | The key name of the child. |
| const Key& psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::name | ( | ) | const [inline] |
Returns the name of this node.
| virtual void psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::on_init | ( | ) | [inline, protected, virtual] |
| virtual void psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::on_new_child | ( | Node & | node | ) | [inline, protected, virtual] |
| virtual void psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::on_remove_child | ( | Node & | node | ) | [inline, protected, virtual] |
| virtual void psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::on_uninit | ( | ) | [inline, protected, virtual] |
| Node* psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::parent | ( | ) | [inline] |
Returns a pointer to the parent of this node or null if this is a root node.
| const Node* psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::parent | ( | ) | const [inline] |
Returns a pointer to the parent of this node or null if this is a root node.
| Node& psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::path | ( | const Key & | name | ) |
Returns a reference to the child matching a path.
All nodes in the path are created if they do not exist.
| Key psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::path_name | ( | ) | const |
Returns the path of this node from the root to the node.
| iterator psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::remove_child | ( | const Key & | name | ) | [inline] |
Deletes a child of this node.
| iterator psynth::base::tree_node< Node, Key, Traits, ThreadingPolicy >::remove_child | ( | iterator | iter | ) |
Deletes a child of this node.
1.7.4