ucc::treemap< T > Class Template Reference

Embed data objects into a tree structured memory database. More...

#include <linked.h>

Inheritance diagram for ucc::treemap< T >:

Inheritance graph
[legend]
Collaboration diagram for ucc::treemap< T >:

Collaboration graph
[legend]

Public Member Functions

 treemap (char *name=NULL)
 Construct a typed root node for the tree.
 treemap (treemap *parent, char *name)
 Construct a child node on an existing tree.
 treemap (treemap *parent, char *name, T &reference)
 Construct a child node on an existing tree and assign it's value.
T & get (void) const
 Return the typed value of this node.
T & operator* () const
 Return typed value of this node by pointer reference.
bool isAttribute (void) const
 Test if this node is a leaf node for a tree pointer table.
getPointer (void) const
 Get the pointer of a pointer based value tree.
T & getData (void) const
 Get the data value of a data based value tree.
void setPointer (const T pointer)
 Set the pointer of a pointer based value tree.
void set (const T &reference)
 Set the value of a data based value tree.
void operator= (const T &data)
 Assign the value of our node.
treemapgetIndexed (unsigned index) const
 Get child member node by index.
treemapgetParent (void) const
 Get the typed parent node for our node.
treemapgetChild (const char *name) const
 Get direct typed child node of our node of specified name.
treemapgetLeaf (const char *name) const
 Find a direct typed leaf node on our node.
getValue (const char *name) const
 Get the value pointer of a leaf node of a pointer tree.
treemapfind (const char *name) const
 Find a subnode from our node by name.
treemappath (const char *path) const
 Find a subnode by pathname.
treemapleaf (const char *name) const
 Search for a leaf node of our node.
treemapgetFirst (void) const
 Get first child of our node.

Static Public Member Functions

static T getPointer (treemap *node)
 Return value from tree element when value is a pointer.

Protected Attributes

value

Detailed Description

template<class T>
class ucc::treemap< T >

Embed data objects into a tree structured memory database.

This can be used to form XML documentent trees or other data structures that can be organized in trees. The NamedTree class is used to manage the structure of the tree, and the type specified is embedded as a data value object which can be manipulated. Name identifiers are assumed to be dynamically allocated if tree node elements are deletable.

Embedded values can either be of direct types that are then stored as part of the templated object, or of class types that are data pointers. The latter might be used for trees that contain data which might be parsed dynamically from a document and/or saved on a heap. Pointer trees assume that NULL pointers are for nodes that are empty, and that NULL data value nodes with children are trunk nodes. Generally data values are then allocated with a pointer stored in pure leaf nodes.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 1237 of file linked.h.


Constructor & Destructor Documentation

template<class T >
ucc::treemap< T >::treemap ( char *  name = NULL  )  [inline]

Construct a typed root node for the tree.

The root node may be named as a stand-alone node or unnamed.

Parameters:
name of the node we are creating.

Definition at line 1248 of file linked.h.

template<class T >
ucc::treemap< T >::treemap ( treemap< T > *  parent,
char *  name 
) [inline]

Construct a child node on an existing tree.

Parameters:
parent of this node to attach.
name of this node.

Definition at line 1255 of file linked.h.

template<class T >
ucc::treemap< T >::treemap ( treemap< T > *  parent,
char *  name,
T &  reference 
) [inline]

Construct a child node on an existing tree and assign it's value.

Parameters:
parent of this node to attach.
name of this node.
reference to value to assign to this node.

Definition at line 1263 of file linked.h.


Member Function Documentation

template<class T >
treemap* ucc::treemap< T >::find ( const char *  name  )  const [inline]

Find a subnode from our node by name.

This performs a recursive search.

Parameters:
name to search for.
Returns:
typed node that is found or NULL if none is found.

Reimplemented from ucc::NamedTree.

Definition at line 1379 of file linked.h.

template<class T >
T& ucc::treemap< T >::get ( void   )  const [inline]

Return the typed value of this node.

Returns:
reference to value of node.

Definition at line 1270 of file linked.h.

template<class T >
treemap* ucc::treemap< T >::getChild ( const char *  name  )  const [inline]

Get direct typed child node of our node of specified name.

This does not perform a recursive search.

Parameters:
name of child node.
Returns:
typed child node pointer or NULL if not found.

Reimplemented from ucc::NamedTree.

Definition at line 1351 of file linked.h.

template<class T >
T& ucc::treemap< T >::getData ( void   )  const [inline]

Get the data value of a data based value tree.

Returns:
data value of node.

Definition at line 1306 of file linked.h.

template<class T >
treemap* ucc::treemap< T >::getFirst ( void   )  const [inline]

Get first child of our node.

This is useful for iterating children.

Returns:
first child or NULL.

Reimplemented from ucc::NamedTree.

Definition at line 1404 of file linked.h.

template<class T >
treemap* ucc::treemap< T >::getIndexed ( unsigned  index  )  const [inline]

Get child member node by index.

Parameters:
index of child member.
Returns:
node or NULL if past end.

Reimplemented from ucc::NamedTree.

Definition at line 1335 of file linked.h.

template<class T >
treemap* ucc::treemap< T >::getLeaf ( const char *  name  )  const [inline]

Find a direct typed leaf node on our node.

A leaf node is a node that has no children of it's own. This does not perform a recursive search.

Parameters:
name of leaf child node to find.
Returns:
typed leaf node object of leaf or NULL.

Reimplemented from ucc::NamedTree.

Definition at line 1360 of file linked.h.

template<class T >
treemap* ucc::treemap< T >::getParent ( void   )  const [inline]

Get the typed parent node for our node.

Returns:
parent node or NULL if root of tree.

Reimplemented from ucc::NamedTree.

Definition at line 1342 of file linked.h.

template<class T >
T ucc::treemap< T >::getPointer ( void   )  const [inline]

Get the pointer of a pointer based value tree.

Returns:
value pointer of node.

Definition at line 1299 of file linked.h.

template<class T >
static T ucc::treemap< T >::getPointer ( treemap< T > *  node  )  [inline, static]

Return value from tree element when value is a pointer.

Parameters:
node in our typed tree.
Returns:
value of node.

Definition at line 1285 of file linked.h.

template<class T >
T ucc::treemap< T >::getValue ( const char *  name  )  const [inline]

Get the value pointer of a leaf node of a pointer tree.

This allows one to find a leaf node and return it's pointer value in a single operation.

Parameters:
name of leaf node.
Returns:
value of leaf pointer if found and contains value, or NULL.

Definition at line 1370 of file linked.h.

template<class T >
bool ucc::treemap< T >::isAttribute ( void   )  const [inline]

Test if this node is a leaf node for a tree pointer table.

Returns:
true if value pointer is not NULL and there are no children.

Definition at line 1292 of file linked.h.

template<class T >
treemap* ucc::treemap< T >::leaf ( const char *  name  )  const [inline]

Search for a leaf node of our node.

This performs a recursive search.

Parameters:
name to search for.
Returns:
typed not that is found or NULL if none is found.

Reimplemented from ucc::NamedTree.

Definition at line 1397 of file linked.h.

template<class T >
T& ucc::treemap< T >::operator* (  )  const [inline]

Return typed value of this node by pointer reference.

Returns:
value of node.

Definition at line 1277 of file linked.h.

template<class T >
void ucc::treemap< T >::operator= ( const T &  data  )  [inline]

Assign the value of our node.

Parameters:
data value to assign.

Definition at line 1327 of file linked.h.

template<class T >
treemap* ucc::treemap< T >::path ( const char *  path  )  const [inline]

Find a subnode by pathname.

This is the same as the NamedTree path member function.

Parameters:
path name to search for node.
Returns:
typed node that is found at path or NULL.

Reimplemented from ucc::NamedTree.

Definition at line 1388 of file linked.h.

template<class T >
void ucc::treemap< T >::set ( const T &  reference  )  [inline]

Set the value of a data based value tree.

Parameters:
reference to value to copy into node.

Definition at line 1320 of file linked.h.

template<class T >
void ucc::treemap< T >::setPointer ( const T  pointer  )  [inline]

Set the pointer of a pointer based value tree.

Parameters:
pointer to set.

Definition at line 1313 of file linked.h.


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

Generated on Wed May 13 08:43:07 2009 for UCommon by  doxygen 1.5.7.1