UCommon
Public Member Functions | Static Public Member Functions | Protected Attributes
ucommon::treemap< T > Class Template Reference

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

#include <linked.h>

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

Public Member Functions

treemapfind (char *name)
 Find a subnode from our node by name.
T & get (void)
 Return the typed value of this node.
treemapgetChild (char *name)
 Get direct typed child node of our node of specified name.
T & getData (void)
 Get the data value of a data based value tree.
treemapgetFirst (void)
 Get first child of our node.
treemapgetIndexed (unsigned index)
 Get child member node by index.
treemapgetLeaf (char *name)
 Find a direct typed leaf node on our node.
treemapgetParent (void)
 Get the typed parent node for our node.
getPointer (void)
 Get the pointer of a pointer based value tree.
getValue (char *name)
 Get the value pointer of a leaf node of a pointer tree.
bool isAttribute (void)
 Test if this node is a leaf node for a tree pointer table.
treemapleaf (char *name)
 Search for a leaf node of our node.
T & operator* ()
 Return typed value of this node by pointer reference.
void operator= (T &data)
 Assign the value of our node.
treemappath (char *path)
 Find a subnode by pathname.
void set (T &reference)
 Set the value of a data based value tree.
void setPointer (T pointer)
 Set the pointer of a pointer based value tree.
 treemap (char *name=((void *) 0))
 Construct a typed root node for the tree.
 treemap (treemap &source)
 Construct a copy of the treemap object.
 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.
- Public Member Functions inherited from ucommon::NamedTree
OrderedIndexgetIndex (void)
 Get the ordered index of our child nodes.
bool isLeaf (void)
 Test if node has children.
bool isRoot (void)
 Test if node is root node.
 operator bool ()
 Test if this node has a name.
bool operator! ()
 Test if this node is unnamed.
void relist (NamedTree *trunk=((void *) 0))
 Default relist is by tail...
void relistHead (NamedTree *trunk)
 Add leaf to a trunk, by reverse order.
void relistTail (NamedTree *trunk)
 Add leaf to a trunk, by order.
void remove (void)
 Remove our node from our parent list.
void setId (char *name)
 Set or replace the name id of this node.
- Public Member Functions inherited from ucommon::NamedObject
void add (NamedObject **hash, char *name, unsigned size=1)
 Add object to hash indexed list.
virtual int compare (char *name)
 Compare the name of our object to see if equal.
bool equal (char *name)
 Equal function which calls compare.
char * getId (void)
 Get the named id string of this object.
NamedObjectgetNext (void)
 Get next effective object when iterating.
bool operator!= (char *name)
 Comparison operator between our name and a string.
bool operator== (char *name)
 Comparison operator between our name and a string.
- Public Member Functions inherited from ucommon::OrderedObject
void delist (OrderedIndex *index)
 Remove our ordered object from an existing index.
virtual void enlist (OrderedIndex *index)
 List our ordered object in default strategy mode.
void enlistHead (OrderedIndex *index)
 List our ordered object at start of a linked list on an index.
void enlistTail (OrderedIndex *index)
 List our ordered object at end of a linked list on an index.
- Public Member Functions inherited from ucommon::LinkedObject
void delist (LinkedObject **root)
 Locate and remove ourselves from a list of objects.
void enlist (LinkedObject **root)
 Add our object to an existing linked list through a pointer.
bool isMember (LinkedObject *list)
 Search to see if we are a member of a specific list.
virtual void release (void)
 Release list, mark as no longer linked.
virtual void retain (void)
 Retain by marking as self referenced list.
- Public Member Functions inherited from ucommon::ObjectProtocol
ObjectProtocolcopy (void)
 Retain (increase retention of) object when copying.
void operator++ (void)
 Increase retention operator.
void operator-- (void)
 Decrease retention operator.
virtual ~ObjectProtocol ()
 Required virtual destructor.

Static Public Member Functions

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

Protected Attributes

value
- Protected Attributes inherited from ucommon::NamedTree
OrderedIndex child
NamedTreeparent
- Protected Attributes inherited from ucommon::NamedObject
char * id

Additional Inherited Members

- Protected Member Functions inherited from ucommon::NamedTree
 NamedTree (char *name=((void *) 0))
 Create a stand-alone or root tree node, with an optional name.
 NamedTree (NamedTree *parent, char *name)
 Create a tree node as a child of an existing node.
 NamedTree (NamedTree &source)
 Construct a copy of the tree.
void purge (void)
 Performs object destruction.
virtual ~NamedTree ()
 Delete node in a tree.
- Protected Member Functions inherited from ucommon::NamedObject
virtual void clearId (void)
 The behavior of clearing id's can be overridden if they are not assigned as strdup's from the heap...
 NamedObject ()
 Create an empty unnamed cell object.
 NamedObject (NamedObject **hash, char *name, unsigned size=1)
 Create a named object and add to hash indexed list.
 NamedObject (OrderedIndex *index, char *name)
 Created a named object on an ordered list.
 ~NamedObject ()
 Destroy named object.
- Protected Member Functions inherited from ucommon::OrderedObject
 OrderedObject (OrderedIndex *index)
 Construct an ordered object aot end of a an index.
 OrderedObject ()
 Construct an ordered object unattached.
- Protected Member Functions inherited from ucommon::LinkedObject
 LinkedObject (LinkedObject **root)
 Construct base class attached to a chain of objects.
 LinkedObject ()
 Construct base class unattached to anyone.

Detailed Description

template<typename T>
class ucommon::treemap< T >

Embed data objects into a tree structured memory database.

This can be used to form XML document 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 template 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.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 1538 of file linked.h.


Constructor & Destructor Documentation

template<typename T >
ucommon::treemap< T >::treemap ( char *  name = ((void *)0))
inline

Construct a typed root node for the tree.

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

Parameters:
nameof the node we are creating.

Definition at line 1549 of file linked.h.

template<typename T >
ucommon::treemap< T >::treemap ( treemap< T > &  source)
inline

Construct a copy of the treemap object.

Parameters:
sourceof copy for new object.

Definition at line 1555 of file linked.h.

template<typename T >
ucommon::treemap< T >::treemap ( treemap< T > *  parent,
char *  name 
)
inline

Construct a child node on an existing tree.

Parameters:
parentof this node to attach.
nameof this node.

Definition at line 1563 of file linked.h.

template<typename T >
ucommon::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:
parentof this node to attach.
nameof this node.
referenceto value to assign to this node.

Definition at line 1571 of file linked.h.


Member Function Documentation

template<typename T >
treemap* ucommon::treemap< T >::find ( char *  name)
inline

Find a subnode from our node by name.

This performs a recursive search.

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

Reimplemented from ucommon::NamedTree.

Definition at line 1687 of file linked.h.

template<typename T >
T& ucommon::treemap< T >::get ( void  )
inline

Return the typed value of this node.

Returns:
reference to value of node.

Definition at line 1578 of file linked.h.

template<typename T >
treemap* ucommon::treemap< T >::getChild ( char *  name)
inline

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

This does not perform a recursive search.

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

Reimplemented from ucommon::NamedTree.

Definition at line 1659 of file linked.h.

template<typename T >
T& ucommon::treemap< T >::getData ( void  )
inline

Get the data value of a data based value tree.

Returns:
data value of node.

Definition at line 1614 of file linked.h.

template<typename T >
treemap* ucommon::treemap< T >::getFirst ( void  )
inline

Get first child of our node.

This is useful for iterating children.

Returns:
first child or NULL.

Reimplemented from ucommon::NamedTree.

Definition at line 1712 of file linked.h.

template<typename T >
treemap* ucommon::treemap< T >::getIndexed ( unsigned  index)
inline

Get child member node by index.

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

Reimplemented from ucommon::NamedTree.

Definition at line 1643 of file linked.h.

template<typename T >
treemap* ucommon::treemap< T >::getLeaf ( char *  name)
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:
nameof leaf child node to find.
Returns:
typed leaf node object of leaf or NULL.

Reimplemented from ucommon::NamedTree.

Definition at line 1668 of file linked.h.

template<typename T >
treemap* ucommon::treemap< T >::getParent ( void  )
inline

Get the typed parent node for our node.

Returns:
parent node or NULL if root of tree.

Reimplemented from ucommon::NamedTree.

Definition at line 1650 of file linked.h.

template<typename T >
static T ucommon::treemap< T >::getPointer ( treemap< T > *  node)
inlinestatic

Return value from tree element when value is a pointer.

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

Definition at line 1593 of file linked.h.

template<typename T >
T ucommon::treemap< T >::getPointer ( void  )
inline

Get the pointer of a pointer based value tree.

Returns:
value pointer of node.

Definition at line 1607 of file linked.h.

template<typename T >
T ucommon::treemap< T >::getValue ( char *  name)
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:
nameof leaf node.
Returns:
value of leaf pointer if found and contains value, or NULL.

Definition at line 1678 of file linked.h.

template<typename T >
bool ucommon::treemap< T >::isAttribute ( void  )
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 1600 of file linked.h.

template<typename T >
treemap* ucommon::treemap< T >::leaf ( char *  name)
inline

Search for a leaf node of our node.

This performs a recursive search.

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

Reimplemented from ucommon::NamedTree.

Definition at line 1705 of file linked.h.

template<typename T >
T& ucommon::treemap< T >::operator* ( )
inline

Return typed value of this node by pointer reference.

Returns:
value of node.

Definition at line 1585 of file linked.h.

template<typename T >
void ucommon::treemap< T >::operator= ( T &  data)
inline

Assign the value of our node.

Parameters:
datavalue to assign.

Definition at line 1635 of file linked.h.

template<typename T >
treemap* ucommon::treemap< T >::path ( char *  path)
inline

Find a subnode by pathname.

This is the same as the NamedTree path member function.

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

Reimplemented from ucommon::NamedTree.

Definition at line 1696 of file linked.h.

template<typename T >
void ucommon::treemap< T >::set ( T &  reference)
inline

Set the value of a data based value tree.

Parameters:
referenceto value to copy into node.

Definition at line 1628 of file linked.h.

template<typename T >
void ucommon::treemap< T >::setPointer ( pointer)
inline

Set the pointer of a pointer based value tree.

Parameters:
pointerto set.

Definition at line 1621 of file linked.h.


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