WvStreams
UniConfTree< Sub > Class Template Reference

A recursively composed dictionary for tree-structured data indexed by UniConfKey. More...

#include <uniconftree.h>

Inheritance diagram for UniConfTree< Sub >:

Classes

class  Iter
 An iterator that walks over all elements on one level of a UniConfTree. More...

Public Types

typedef wv::function< void(const Sub *, void *)> Visitor
typedef wv::function< bool(const Sub *, const Sub *)> Comparator
typedef wv::function< void(const Sub *, void *)> Visitor
typedef wv::function< bool(const Sub *, const Sub *)> Comparator

Public Member Functions

 UniConfTree (Sub *parent, const UniConfKey &key)
 Creates a node and links it to a subtree, if parent is non-NULL.
 ~UniConfTree ()
 Destroy this node's contents and children.
Sub * parent () const
 Returns a pointer to the parent node, or NULL if there is none.
void setparent (Sub *parent)
 Reparents this node.
Sub * root () const
 Returns a pointer to the root node of the tree.
UniConfKey fullkey (const Sub *ancestor=NULL) const
 Returns full path of this node relative to an ancestor.
Sub * find (const UniConfKey &key) const
 Finds the sub-node with the specified key.
Sub * findchild (const UniConfKey &key) const
 Finds the direct child node with the specified key.
void remove (const UniConfKey &key)
 Removes the node for the specified key from the tree and deletes it along with any of its children.
void zap ()
 Removes and deletes all children of this node.
void visit (const Visitor &visitor, void *userdata, bool preorder=true, bool postorder=false) const
 Performs a traversal on this tree using the specified visitor function and traversal type(s).
bool compare (const Sub *other, const Comparator &comparator)
 Compares this tree with another using the specified comparator function.
 UniConfTree (Sub *parent, const UniConfKey &key)
 Creates a node and links it to a subtree, if parent is non-NULL.
 ~UniConfTree ()
 Destroy this node's contents and children.
Sub * parent () const
 Returns a pointer to the parent node, or NULL if there is none.
void setparent (Sub *parent)
 Reparents this node.
Sub * root () const
 Returns a pointer to the root node of the tree.
UniConfKey fullkey (const Sub *ancestor=NULL) const
 Returns full path of this node relative to an ancestor.
Sub * find (const UniConfKey &key) const
 Finds the sub-node with the specified key.
Sub * findchild (const UniConfKey &key) const
 Finds the direct child node with the specified key.
void remove (const UniConfKey &key)
 Removes the node for the specified key from the tree and deletes it along with any of its children.
void zap ()
 Removes and deletes all children of this node.
void visit (const Visitor &visitor, void *userdata, bool preorder=true, bool postorder=false) const
 Performs a traversal on this tree using the specified visitor function and traversal type(s).
bool compare (const Sub *other, const Comparator &comparator)
 Compares this tree with another using the specified comparator function.
const UniConfKeykey () const
 Returns the key field.
const UniConfKeykey () const
 Returns the key field.
bool haschildren () const
 Returns true if the node has children.
bool haschildren () const
 Returns true if the node has children.

Protected Types

typedef WvScatterHash< UniHashTreeBase, UniConfKey, AccessorContainer
typedef WvScatterHash< UniHashTreeBase, UniConfKey, AccessorContainer
typedef UniHashTreeBaseVisitor BaseVisitor
typedef UniHashTreeBaseVisitor BaseVisitor
typedef UniHashTreeBaseComparator BaseComparator
typedef UniHashTreeBaseComparator BaseComparator

Protected Member Functions

UniConfKey _fullkey (const UniHashTreeBase *ancestor=NULL) const
UniConfKey _fullkey (const UniHashTreeBase *ancestor=NULL) const
UniHashTreeBase_find (const UniConfKey &key) const
UniHashTreeBase_find (const UniConfKey &key) const
UniHashTreeBase_findchild (const UniConfKey &key) const
UniHashTreeBase_findchild (const UniConfKey &key) const

Static Protected Member Functions

static bool _recursivecompare (const UniHashTreeBase *a, const UniHashTreeBase *b, const UniHashTreeBaseComparator &comparator)
static bool _recursivecompare (const UniHashTreeBase *a, const UniHashTreeBase *b, const UniHashTreeBaseComparator &comparator)
static void _recursive_unsorted_visit (const UniHashTreeBase *a, const UniHashTreeBaseVisitor &visitor, void *userdata, bool preorder, bool postorder)
static void _recursive_unsorted_visit (const UniHashTreeBase *a, const UniHashTreeBaseVisitor &visitor, void *userdata, bool preorder, bool postorder)

Protected Attributes

UniHashTreeBasexparent
Container * xchildren

Detailed Description

template<class Sub>
class UniConfTree< Sub >

A recursively composed dictionary for tree-structured data indexed by UniConfKey.

Someday this could be further abstracted into a generic WvTreeDict.

"Sub" is the name of the concrete subclass of UniConfTree.

Definition at line 23 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

Member Typedef Documentation

◆ Visitor [1/2]

template<class Sub>
typedef wv::function<void(const Sub*, void*)> UniConfTree< Sub >::Visitor

◆ Comparator [1/2]

template<class Sub>
typedef wv::function<bool(const Sub*, const Sub*)> UniConfTree< Sub >::Comparator

◆ Visitor [2/2]

template<class Sub>
typedef wv::function<void(const Sub*, void*)> UniConfTree< Sub >::Visitor

Definition at line 27 of file include/uniconftree.h.

◆ Comparator [2/2]

template<class Sub>
typedef wv::function<bool(const Sub*, const Sub*)> UniConfTree< Sub >::Comparator

Definition at line 28 of file include/uniconftree.h.

◆ Container [1/2]

typedef WvScatterHash<UniHashTreeBase, UniConfKey, Accessor> UniHashTreeBase::Container
protectedinherited

◆ Container [2/2]

typedef WvScatterHash<UniHashTreeBase, UniConfKey, Accessor> UniHashTreeBase::Container
protectedinherited

Definition at line 32 of file include/unihashtree.h.

◆ BaseVisitor [1/2]

typedef UniHashTreeBaseVisitor UniHashTreeBase::BaseVisitor
protectedinherited

◆ BaseVisitor [2/2]

typedef UniHashTreeBaseVisitor UniHashTreeBase::BaseVisitor
protectedinherited

Definition at line 33 of file include/unihashtree.h.

◆ BaseComparator [1/2]

typedef UniHashTreeBaseComparator UniHashTreeBase::BaseComparator
protectedinherited

◆ BaseComparator [2/2]

typedef UniHashTreeBaseComparator UniHashTreeBase::BaseComparator
protectedinherited

Definition at line 34 of file include/unihashtree.h.

Constructor & Destructor Documentation

◆ UniConfTree() [1/2]

template<class Sub>
UniConfTree< Sub >::UniConfTree ( Sub * parent,
const UniConfKey & key )
inline

Creates a node and links it to a subtree, if parent is non-NULL.

Definition at line 31 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

References UniHashTreeBase::key(), and parent().

◆ ~UniConfTree() [1/2]

template<class Sub>
UniConfTree< Sub >::~UniConfTree ( )
inline

Destroy this node's contents and children.

Definition at line 36 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

References zap().

◆ UniConfTree() [2/2]

template<class Sub>
UniConfTree< Sub >::UniConfTree ( Sub * parent,
const UniConfKey & key )
inline

Creates a node and links it to a subtree, if parent is non-NULL.

Definition at line 31 of file include/uniconftree.h.

References UniHashTreeBase::key(), and parent().

◆ ~UniConfTree() [2/2]

template<class Sub>
UniConfTree< Sub >::~UniConfTree ( )
inline

Destroy this node's contents and children.

Definition at line 36 of file include/uniconftree.h.

References zap().

Member Function Documentation

◆ parent() [1/2]

template<class Sub>
Sub * UniConfTree< Sub >::parent ( ) const
inline

Returns a pointer to the parent node, or NULL if there is none.

Definition at line 40 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

References UniHashTreeBase::xparent.

Referenced by setparent(), and UniConfTree().

◆ setparent() [1/2]

template<class Sub>
void UniConfTree< Sub >::setparent ( Sub * parent)
inline

Reparents this node.

Definition at line 44 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

References parent().

◆ root() [1/2]

template<class Sub>
Sub * UniConfTree< Sub >::root ( ) const
inline

Returns a pointer to the root node of the tree.

Definition at line 48 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

◆ fullkey() [1/2]

template<class Sub>
UniConfKey UniConfTree< Sub >::fullkey ( const Sub * ancestor = NULL) const
inline

Returns full path of this node relative to an ancestor.

If ancestor is NULL, returns the root.

Definition at line 55 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

Referenced by UniTransactionGen::deletion_visitor(), and UniTempGen::set().

◆ find() [1/2]

template<class Sub>
Sub * UniConfTree< Sub >::find ( const UniConfKey & key) const
inline

◆ findchild() [1/2]

template<class Sub>
Sub * UniConfTree< Sub >::findchild ( const UniConfKey & key) const
inline

Finds the direct child node with the specified key.

If key.numsegments() == 1, then performs the same task as find(key), but a little faster. Otherwise returns NULL.

Definition at line 71 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

References UniHashTreeBase::key().

Referenced by UniConfRoot::add_callback(), UniTransactionGen::apply_values(), UniTransactionGen::cancel_values(), UniTransactionGen::gencallback(), UniTransactionGen::get(), UniTransactionGen::iterator(), GenStyleChangeTreeIter::next(), and UniTempGen::set().

◆ remove() [1/2]

template<class Sub>
void UniConfTree< Sub >::remove ( const UniConfKey & key)
inline

Removes the node for the specified key from the tree and deletes it along with any of its children.

If the key is UniConfKey::EMPTY, deletes this object.

Definition at line 80 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

References find(), and UniHashTreeBase::key().

◆ zap() [1/2]

template<class Sub>
void UniConfTree< Sub >::zap ( )
inline

Removes and deletes all children of this node.

Definition at line 84 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

References UniHashTreeBase::xchildren.

Referenced by ~UniConfTree().

◆ visit() [1/2]

template<class Sub>
void UniConfTree< Sub >::visit ( const Visitor & visitor,
void * userdata,
bool preorder = true,
bool postorder = false ) const
inline

Performs a traversal on this tree using the specified visitor function and traversal type(s).

"visitor" is the tree visitor function "userdata" is userdata for the tree visitor function

Definition at line 108 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

Referenced by UniTransactionGen::cancel_changes(), and UniTempGen::set().

◆ compare() [1/2]

template<class Sub>
bool UniConfTree< Sub >::compare ( const Sub * other,
const Comparator & comparator )
inline

Compares this tree with another using the specified comparator function.

Comparison of a subtree ends when the comparator returns false. "comparator" is the value compare function "userdata" is userdata for the compare function Returns: true if the comparison function returned true each time

Definition at line 124 of file debian/libwvstreams-dev/usr/include/wvstreams/uniconftree.h.

Referenced by UniIniGen::refresh().

◆ parent() [2/2]

template<class Sub>
Sub * UniConfTree< Sub >::parent ( ) const
inline

Returns a pointer to the parent node, or NULL if there is none.

Definition at line 40 of file include/uniconftree.h.

References UniHashTreeBase::xparent.

◆ setparent() [2/2]

template<class Sub>
void UniConfTree< Sub >::setparent ( Sub * parent)
inline

Reparents this node.

Definition at line 44 of file include/uniconftree.h.

References parent().

◆ root() [2/2]

template<class Sub>
Sub * UniConfTree< Sub >::root ( ) const
inline

Returns a pointer to the root node of the tree.

Definition at line 48 of file include/uniconftree.h.

◆ fullkey() [2/2]

template<class Sub>
UniConfKey UniConfTree< Sub >::fullkey ( const Sub * ancestor = NULL) const
inline

Returns full path of this node relative to an ancestor.

If ancestor is NULL, returns the root.

Definition at line 55 of file include/uniconftree.h.

◆ find() [2/2]

template<class Sub>
Sub * UniConfTree< Sub >::find ( const UniConfKey & key) const
inline

Finds the sub-node with the specified key.

If key.isempty(), returns this node.

Definition at line 62 of file include/uniconftree.h.

References UniHashTreeBase::key().

◆ findchild() [2/2]

template<class Sub>
Sub * UniConfTree< Sub >::findchild ( const UniConfKey & key) const
inline

Finds the direct child node with the specified key.

If key.numsegments() == 1, then performs the same task as find(key), but a little faster. Otherwise returns NULL.

Definition at line 71 of file include/uniconftree.h.

References UniHashTreeBase::key().

◆ remove() [2/2]

template<class Sub>
void UniConfTree< Sub >::remove ( const UniConfKey & key)
inline

Removes the node for the specified key from the tree and deletes it along with any of its children.

If the key is UniConfKey::EMPTY, deletes this object.

Definition at line 80 of file include/uniconftree.h.

References find(), and UniHashTreeBase::key().

◆ zap() [2/2]

template<class Sub>
void UniConfTree< Sub >::zap ( )
inline

Removes and deletes all children of this node.

Definition at line 84 of file include/uniconftree.h.

References UniHashTreeBase::xchildren.

◆ visit() [2/2]

template<class Sub>
void UniConfTree< Sub >::visit ( const Visitor & visitor,
void * userdata,
bool preorder = true,
bool postorder = false ) const
inline

Performs a traversal on this tree using the specified visitor function and traversal type(s).

"visitor" is the tree visitor function "userdata" is userdata for the tree visitor function

Definition at line 108 of file include/uniconftree.h.

◆ compare() [2/2]

template<class Sub>
bool UniConfTree< Sub >::compare ( const Sub * other,
const Comparator & comparator )
inline

Compares this tree with another using the specified comparator function.

Comparison of a subtree ends when the comparator returns false. "comparator" is the value compare function "userdata" is userdata for the compare function Returns: true if the comparison function returned true each time

Definition at line 124 of file include/uniconftree.h.

◆ key() [1/2]

const UniConfKey & UniHashTreeBase::key ( ) const
inlineinherited

◆ key() [2/2]

const UniConfKey & UniHashTreeBase::key ( ) const
inlineinherited

Returns the key field.

Definition at line 40 of file include/unihashtree.h.

◆ haschildren()

bool UniHashTreeBase::haschildren ( ) const
inherited

Returns true if the node has children.

Definition at line 114 of file unihashtree.cc.

References xchildren.

Referenced by UniTempGen::haschildren().

◆ _fullkey()

UniConfKey UniHashTreeBase::_fullkey ( const UniHashTreeBase * ancestor = NULL) const
protectedinherited

Definition at line 63 of file unihashtree.cc.

◆ _find()

UniHashTreeBase * UniHashTreeBase::_find ( const UniConfKey & key) const
protectedinherited

Definition at line 90 of file unihashtree.cc.

◆ _findchild()

UniHashTreeBase * UniHashTreeBase::_findchild ( const UniConfKey & key) const
protectedinherited

Definition at line 105 of file unihashtree.cc.

◆ _recursivecompare()

bool UniHashTreeBase::_recursivecompare ( const UniHashTreeBase * a,
const UniHashTreeBase * b,
const UniHashTreeBaseComparator & comparator )
staticprotectedinherited

Definition at line 163 of file unihashtree.cc.

◆ _recursive_unsorted_visit()

void UniHashTreeBase::_recursive_unsorted_visit ( const UniHashTreeBase * a,
const UniHashTreeBaseVisitor & visitor,
void * userdata,
bool preorder,
bool postorder )
staticprotectedinherited

Definition at line 148 of file unihashtree.cc.

Member Data Documentation

◆ xparent

UniHashTreeBase * UniHashTreeBase::xparent
protectedinherited

the parent of this subtree

Definition at line 62 of file debian/libwvstreams-dev/usr/include/wvstreams/unihashtree.h.

Referenced by haschildren(), and UniConfTree< Sub >::parent().

◆ xchildren

Container * UniHashTreeBase::xchildren
protectedinherited

the hash table of children

Definition at line 63 of file debian/libwvstreams-dev/usr/include/wvstreams/unihashtree.h.

Referenced by haschildren(), and UniConfTree< Sub >::zap().


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