Honeycomb  0.1
Component-Model Framework
Public Member Functions | List of all members
honey::TreeClone< TreeNode > Class Template Reference

Clone and track changes to an entire tree. More...

#include <TreeClone.h>

Public Member Functions

 TreeClone ()
 
 ~TreeClone ()
 
TreeNoderegNode (const TreeNode &rootNode)
 Register a node to clone. Returns clone. Clone's state is invalid (not equal to original) until update() is called. More...
 
TreeNodeunregNode (const TreeNode &rootNode)
 Stop tracking changes to a node and its entire subtree. Returns clone of first node unregistered (or null if none found). More...
 
const TreeNodeunregClone (const TreeNode &rootClone)
 Stop a clone and its entire subtree from tracking changes to their original nodes. Returns original node of first clone unregistered (or null if none found). More...
 
void update ()
 Update clones to make them mirror the current data and hierarchy of registered nodes. More...
 
void clear ()
 Reset the state of the tree clone structure, unregister all nodes and destroy all clones. More...
 
TreeNodegetClone (const TreeNode &node) const
 Get the cloned version of a node (node may be registered or unregistered). Returns null if not found. More...
 
const TreeNodegetOrigNode (const TreeNode &clone) const
 Get the original node of a clone. Returns null if not found. More...
 
bool isRegNode (const TreeNode &node) const
 Check if a node is registered. More...
 
bool isRegClone (const TreeNode &clone) const
 Check if a clone is registered. More...
 
szt cloneCount () const
 Get total number of clones being handled by this tree. More...
 
szt regNodeCount () const
 Get total number of registered nodes. More...
 

Detailed Description

template<class TreeNode>
class honey::TreeClone< TreeNode >

Clone and track changes to an entire tree.

Constructor & Destructor Documentation

template<class TreeNode >
honey::TreeClone< TreeNode >::TreeClone ( )
inline
template<class TreeNode >
honey::TreeClone< TreeNode >::~TreeClone ( )
inline

Member Function Documentation

template<class TreeNode >
void honey::TreeClone< TreeNode >::clear ( )
inline

Reset the state of the tree clone structure, unregister all nodes and destroy all clones.

template<class TreeNode >
szt honey::TreeClone< TreeNode >::cloneCount ( ) const
inline

Get total number of clones being handled by this tree.

template<class TreeNode >
TreeNode* honey::TreeClone< TreeNode >::getClone ( const TreeNode node) const
inline

Get the cloned version of a node (node may be registered or unregistered). Returns null if not found.

template<class TreeNode >
const TreeNode* honey::TreeClone< TreeNode >::getOrigNode ( const TreeNode clone) const
inline

Get the original node of a clone. Returns null if not found.

template<class TreeNode >
bool honey::TreeClone< TreeNode >::isRegClone ( const TreeNode clone) const
inline

Check if a clone is registered.

template<class TreeNode >
bool honey::TreeClone< TreeNode >::isRegNode ( const TreeNode node) const
inline

Check if a node is registered.

template<class TreeNode >
TreeNode& honey::TreeClone< TreeNode >::regNode ( const TreeNode rootNode)
inline

Register a node to clone. Returns clone. Clone's state is invalid (not equal to original) until update() is called.

Cloned nodes will track changes to the data and hierarchy of the original node. Any subtrees formed under the original node are automatically tracked and mirrored in the clone.

While registered, the only type of clone safe to be tampered with is a "root clone". A root clone is a clone whose parent is not registered. A root clone is special because it can be attached as a child to any other tree. Do not perform any other operations to registered clones.

Warning: if an original node is destroyed while still registered, then its clone will also be destroyed on the next update() call.

template<class TreeNode >
szt honey::TreeClone< TreeNode >::regNodeCount ( ) const
inline

Get total number of registered nodes.

template<class TreeNode >
const TreeNode* honey::TreeClone< TreeNode >::unregClone ( const TreeNode rootClone)
inline

Stop a clone and its entire subtree from tracking changes to their original nodes. Returns original node of first clone unregistered (or null if none found).

This function will fail if rootClone's parent is registered.

See also
unregNode()
template<class TreeNode >
TreeNode* honey::TreeClone< TreeNode >::unregNode ( const TreeNode rootNode)
inline

Stop tracking changes to a node and its entire subtree. Returns clone of first node unregistered (or null if none found).

This function will fail if rootNode's parent is registered (branches of registered trees can't be detached).

Clone and its subtree are free to be used like normal nodes. Resources for clone and its subtree are held by this class.

Warning: If the original node is re-registered or attached to a registered tree then it will automatically use the same clone resource again. Clones in use are not to be tampered with (check isRegClone).

template<class TreeNode >
void honey::TreeClone< TreeNode >::update ( )
inline

Update clones to make them mirror the current data and hierarchy of registered nodes.


The documentation for this class was generated from the following file: