ionflux.org | Impressum

Ionflux::Tools::Node Class Reference
[Data handling]

Tree node. More...

#include <Node.hpp>

Collaboration diagram for Ionflux::Tools::Node:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Node ()
 Constructor.
 Node (Node &sourceNode)
 Constructor.
 Node (Node *initParent)
 Constructor.
 Node (Node *initParent, int initID)
 Constructor.
 Node (Node *initParent, int initID, const std::string &initName)
 Constructor.
 Node (Node *initParent, int initID, const std::string &initName, int initDataType)
 Constructor.
 Node (Node *initParent, int initID, const std::string &initName, int initDataType, bool initManaged)
 Constructor.
virtual ~Node ()
 Destructor.
virtual void setID (int newID)
 Set ID.
virtual void setName (const std::string &newName)
 Set Name.
virtual void setParent (Node *newParent)
 Set parent Node.
virtual void setDataType (int newDataType)
 Set data type.
virtual int addData (const std::string &newData)
 Add data entry.
virtual int addData (int newData)
 Add data entry.
virtual int addData (double newData)
 Add data entry.
virtual bool setBlob (unsigned int dataIndex, const std::string &newData)
 Set data entry.
virtual bool setData (unsigned int dataIndex, const std::string &newData)
 Set data entry.
virtual bool setData (unsigned int dataIndex, int newData)
 Set data entry.
virtual bool setData (unsigned int dataIndex, unsigned int newData)
 Set data entry.
virtual bool setData (unsigned int dataIndex, double newData)
 Set data entry.
virtual bool setData (const std::string &newData)
 Set data entry.
virtual bool setData (int newData)
 Set data entry.
virtual bool setData (unsigned int newData)
 Set data entry.
virtual bool setData (double newData)
 Set data entry.
virtual std::string getData (unsigned int dataIndex)
 Get data entry.
virtual std::string getBlob (unsigned int dataIndex)
 Get data entry.
virtual int getInt (unsigned int dataIndex)
 Get data entry.
virtual double getDouble (unsigned int dataIndex)
 Get data entry.
virtual bool removeData (unsigned int dataIndex)
 Remove data entry.
virtual void clearData (bool recursive)
 Remove all data entries.
virtual NodeaddChild (int childID=NODE_ID_NOT_SET, const std::string &childName="")
 Add a child.
virtual void addChild (Node *newChild, bool newManage)
 Add a child.
virtual NodefindChild (int searchID, bool recursive=false)
 Find child node.
virtual NodefindChild (const std::string &searchName, bool recursive=false)
 Find child node.
virtual NodegetChild (unsigned int childIndex)
 Get child node.
virtual unsigned int getNumChildren (bool recursive)
 Get number of children.
virtual bool removeChild (unsigned int childIndex)
 Remove child node.
virtual bool removeChild (Node *targetNode, bool recursive)
 Remove child node.
virtual void removeAllChildren (bool recursive)
 Remove all child nodes.
virtual bool setChild (unsigned int childIndex, Node *newChild, bool newManage)
 Set child node.
virtual void removeManagedChildren ()
 Remove managed children.
virtual int getChildIndex (Node *targetNode)
 Get child node index.
virtual unsigned int printDebugInfo (int targetLevel, int callingLevel, int parentID, int childID)
 Print debug information.
virtual unsigned int printDebugInfo (int targetLevel)
 Print debug information.
virtual int getUID (bool treeUID)
 Get unique ID.
virtual void setUIDMode (int newUIDMode)
 Set child node UID assignment mode.
virtual void setAutoCreate (bool newAutoCreate)
 Set auto-create mode.
virtual void setIndexMode (int newIndexMode)
 Set child node indexing mode.
virtual void traverse (NodeDump *target, int order)
 Traverse sub-tree.
virtual void serialize (std::string &target)
 Serialize sub-tree.
virtual bool unpack (const std::string &serialized, unsigned int blockStart, unsigned int blockSize)
 Unpack sub-tree.
virtual void convertToNativeType ()
 Convert node to native data type.
virtual void clearNameIndex ()
 Clear name index.
virtual void clearIDIndex ()
 Clear ID index.
virtual void clearIndexes ()
 Clear all indexes.
virtual void copy (Ionflux::Tools::Node &target, unsigned int maxDepth=0, unsigned int currentDepth=0)
 Copy node.
virtual Nodeoperator[] (int searchID)
 Find child node.
virtual Nodeoperator[] (const std::string &searchName)
 Find child node.
virtual std::string operator= (const std::string &newData)
 Assign value to data entry.
virtual int operator= (int newData)
 Assign value to data entry.
virtual double operator= (double newData)
 Assign value to data entry.
virtual Nodeoperator= (Node &sourceNode)
 Copy assignment.
virtual bool getAutoCreate ()
 Get auto-create mode.
virtual int getUIDMode ()
 Get child node UID assignment mode.
virtual int getIndexMode ()
 Get child node indexing mode.
virtual int getID ()
 Get node ID.
virtual std::string getName ()
 Get node name.
virtual int getDataType ()
 Get data type.
virtual std::string getData ()
 Get data.
virtual std::string getBlob ()
 Get data as blob.
virtual int getInt ()
 Get data as integer.
virtual double getDouble ()
 Get data as double.
virtual unsigned int getNumData ()
 Get number of data entries.
virtual unsigned int getNumChildren ()
 Get number of children.
virtual NodegetParent ()
 Get parent node.
virtual std::string getPath ()
 Get tree path.
virtual void clear ()
 Clear the node.
virtual Nodemerge (Node &sourceNode, bool replace=false, unsigned int maxDepth=0, unsigned int currentDepth=0)
 Merge nodes.
bool combine (unsigned int from, unsigned int to, Node &target)
 Combine items.
std::string toConfig (const std::string &indent="", unsigned int level=0)
 Get configuration file representation.
void setManaged (bool newManaged)
 Set memory management flag.
bool isManaged ()
 Get memory management flag.
virtual ReportergetLog ()
 Get Console output/logging facility.

Static Public Attributes

static const int NODE_ID_NOT_SET = -1
 Node ID: Not set.
static const int NODE_DATA_BLOB = 0
 Node data type: Blob (Binary large object, including byte strings).
static const int NODE_DATA_INT = 1
 Node data type: Integer.
static const int NODE_DATA_DOUBLE = 2
 Node data type: Double.
static const int UID_MODE_NONE = 0
 Child node UID assignment mode: Do not assign UID (default).
static const int UID_MODE_NODE = 1
 Child node UID assignment mode: Assign ID unique to this node.
static const int UID_MODE_TREE = 2
 Child node UID assignment mode: Assign ID unique to the tree.
static const int TRAVERSAL_INORDER = 0
 Traversal order: Inorder.
static const int TRAVERSAL_PREORDER = 1
 Traversal order: Preorder.
static const int TRAVERSAL_POSTORDER = 2
 Traversal order: Postorder.
static const unsigned int NODE_HEADER_SIZE = 53
 Size of serialized node header in bytes.
static const int INDEX_MODE_NONE = 0
 Indexing mode: Do not use indexing (default).
static const int INDEX_MODE_NODE = 1
 Indexing mode: Per node indexing.
static const int INDEX_MODE_TREE = 2
 Indexing mode: Per tree indexing.
static const unsigned int MAX_ID_INDEX_SIZE = 268435456L
 Maximum size of ID index.

Protected Member Functions

virtual bool validateChildIndex (unsigned int childIndex)
 Validate child node index.
virtual bool validateDataIndex (unsigned int dataIndex)
 Validate data index.
virtual unsigned int refChild (Node *childNode)
 Increase child node reference count.
virtual unsigned int unrefChild (Node *childNode)
 Decrease child node reference count.
virtual unsigned int getRefCount (Node *childNode)
 Get child node reference count.
virtual void addIndexEntry (Node *indexNode)
 Add index entry.
virtual NodegetIndexEntry (const std::string &indexName)
 Get index entry.
virtual void removeIndexEntry (const std::string &indexName)
 Remove index entry.
virtual NodegetIndexEntry (int indexID)
 Get index entry.
virtual void removeIndexEntry (int indexID)
 Remove index entry.
virtual void removeIndexEntries (Node *indexNode)
 Remove index entries.

Protected Attributes

Ionflux::Tools::Reporterlog
 Console output/logging.
int nodeID
 Numerical ID of this node.
std::string nodeName
 Name of this node.
std::vector< NodeInfochildren
 Vector of pointers to children.
std::vector< std::string > nodeData
 Data vector.
int dataType
 Node data type.
Nodeparent
 Parent node.
int maxUID
 Maximum UID assigned by this node.
int uidMode
 Child node UID assignment mode.
bool autoCreate
 Auto-creation mode.
int indexMode
 Indexing mode.
std::map< std::string, Node * > nameIndex
 Index map.
std::vector< Node * > idIndex
 Index vector (TODO: Maybe reimplement this as a hash map).
bool managed
 Memory management mode.
std::map< Node *, unsigned
int > 
childNodeRef
 Child node reference counter.

Detailed Description

Tree node.

A single data node of a tree. Tree nodes can be used to store data of a hierarchical, non-cyclical structure, where each child node has exactly one parent node and loops do not exist. Each node also has a data vector where a large amount of values of identical type may be stored without the need of additional nodes. The type of a node can be one of BLOB, INT or DOUBLE, and all data will be converted as best as possible to fit the specified node data type. The node object also provides transparent serialization and unpacking of sub-trees from a data buffer and node resolution from a fully qualified tree path (see misc/node-serialization.txt and misc/path-resolution.txt for additional information). Dynamic auto-creation of child nodes is also supported.


Constructor & Destructor Documentation

Ionflux::Tools::Node::Node  ) 
 

Constructor.

Construct new Node object.

Ionflux::Tools::Node::Node Node sourceNode  ) 
 

Constructor.

Construct new Node object.

Parameters:
sourceNode Node which to copy.

Ionflux::Tools::Node::Node Node initParent  ) 
 

Constructor.

Construct new Node object.

Parameters:
initParent Pointer to parent node of this node.

Ionflux::Tools::Node::Node Node initParent,
int  initID
 

Constructor.

Construct new Node object.

Parameters:
initParent Pointer to parent node of this node.
initID Numerical ID of this node.

Ionflux::Tools::Node::Node Node initParent,
int  initID,
const std::string &  initName
 

Constructor.

Construct new Node object.

Parameters:
initParent Pointer to parent node of this node.
initID Numerical ID of this node.
initName Name of this node.

Ionflux::Tools::Node::Node Node initParent,
int  initID,
const std::string &  initName,
int  initDataType
 

Constructor.

Construct new Node object.

Parameters:
initParent Pointer to parent node of this node.
initID Numerical ID of this node.
initName Name of this node.
initDataType Data type of this node.

Ionflux::Tools::Node::Node Node initParent,
int  initID,
const std::string &  initName,
int  initDataType,
bool  initManaged
 

Constructor.

Construct new Node object.

Parameters:
initParent Pointer to parent node of this node.
initID Numerical ID of this node.
initName Name of this node.
initDataType Data type of this node.
initManaged Whether memory allocated for this node should be managed by its parent node.

Ionflux::Tools::Node::~Node  )  [virtual]
 

Destructor.

Destruct Node object.


Member Function Documentation

void Ionflux::Tools::Node::addChild Node newChild,
bool  newManage
[virtual]
 

Add a child.

Adds a new child node to this node.

Parameters:
newChild Pointer to child node.
newManage Whether memory allocated for the child node should be managed by this node.

Node * Ionflux::Tools::Node::addChild int  childID = NODE_ID_NOT_SET,
const std::string &  childName = ""
[virtual]
 

Add a child.

Creates a new child node and adds it to this node. The node thus created is managed by its parent node.

Parameters:
childID ID of the new child node.
childName Name of the new child node.
Note:
By default, the new node will have the same data type, the same UID assignment mode and the same node auto-create mode as its parent.
Returns:
Pointer to the new child node.

int Ionflux::Tools::Node::addData double  newData  )  [virtual]
 

Add data entry.

Adds data to this node.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
newData Data to be added.
Returns:
The index of the data on success, -1 otherwise.

int Ionflux::Tools::Node::addData int  newData  )  [virtual]
 

Add data entry.

Adds data to this node.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
newData Data to be added.
Returns:
The index of the data on success, -1 otherwise.

int Ionflux::Tools::Node::addData const std::string &  newData  )  [virtual]
 

Add data entry.

Adds data to this node.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
newData Data to be added.
Returns:
The index of the data on success, -1 otherwise.

void Ionflux::Tools::Node::addIndexEntry Node indexNode  )  [protected, virtual]
 

Add index entry.

Adds a child node to the name or ID index (or both).

Note:
A child node will be added to an index only if either its name is not the empty string or its ID is not NODE_ID_NOT_SET and not negative. If both keys (name or ID) are set to suitable values, the node will be added to both indexes. If the indexing mode is INDEX_MODE_NONE or indexNode is null, this function will do nothing.
Parameters:
indexNode Node for which an index entry should be added.

void Ionflux::Tools::Node::clear  )  [virtual]
 

Clear the node.

void Ionflux::Tools::Node::clearData bool  recursive  )  [virtual]
 

Remove all data entries.

Remove all data entries from this node. Pass true to remove all data entries from child nodes recursively.

Parameters:
recursive Whether to remove data entries of child nodes recursively.

void Ionflux::Tools::Node::clearIDIndex  )  [virtual]
 

Clear ID index.

void Ionflux::Tools::Node::clearIndexes  )  [virtual]
 

Clear all indexes.

void Ionflux::Tools::Node::clearNameIndex  )  [virtual]
 

Clear name index.

bool Ionflux::Tools::Node::combine unsigned int  from,
unsigned int  to,
Node target
 

Combine items.

Combines each data entry of a first level child node (called a class of items) with data entries from the other first level child nodes (classes). Only nodes in the range from up to (and including) to will be used for combination. The result is stored in target, with each first level node containing a unique combination of items as its data entries.

Returns:
true on success, false otherwise.

void Ionflux::Tools::Node::convertToNativeType  )  [virtual]
 

Convert node to native data type.

Converts the node to the data type best suited for representing its data. This is accomplished by checking the first data entry and converting all data entries to the new type.

Note:
This only applies to nodes of type Node::NODE_DATA_BLOB. For other data types, it is assumed that the data type is already optimal to represent the data contained in the node.

void Ionflux::Tools::Node::copy Ionflux::Tools::Node target,
unsigned int  maxDepth = 0,
unsigned int  currentDepth = 0
[virtual]
 

Copy node.

Copy the node to a specified target node. Child nodes will be copied recursively up to the maximum depth specified, or to the maximum possible depth if no maximum depth is specified.

Parameters:
target Target for the copy.
maxDepth Maximum recursion depth.
currentDepth Depth of current node.

Node * Ionflux::Tools::Node::findChild const std::string &  searchName,
bool  recursive = false
[virtual]
 

Find child node.

Return a child by name.

Parameters:
searchName The name of the child node to be returned.
recursive Whether to search recursively through all child nodes.
Returns:
Pointer of the first child node with the specified name, or 0 if no child with the specified name is found.

Node * Ionflux::Tools::Node::findChild int  searchID,
bool  recursive = false
[virtual]
 

Find child node.

Return a child by numerical ID.

Parameters:
searchID The ID of the child node to be returned.
recursive Whether to search recursively through all child nodes.
Returns:
Pointer of the first child node with the specified ID, or 0 if no child with the specified ID is found.

bool Ionflux::Tools::Node::getAutoCreate  )  [virtual]
 

Get auto-create mode.

Returns:
true if auto-create mode is enabled, false otherwise.

std::string Ionflux::Tools::Node::getBlob  )  [virtual]
 

Get data as blob.

Returns:
Data entry (at index 0).

std::string Ionflux::Tools::Node::getBlob unsigned int  dataIndex  )  [virtual]
 

Get data entry.

Get data entry with specified index.

Note:
If used with an INT or DOUBLE node, this returns the binary representation of the number (in network byte order).
Parameters:
dataIndex Data index.
Returns:
Data entry, or an empty string if entry with specified index does not exist.

Node * Ionflux::Tools::Node::getChild unsigned int  childIndex  )  [virtual]
 

Get child node.

Get child node with specified index.

Parameters:
childIndex Index of the child node to be returned.
Returns:
Pointer to the child node with the specified index, or 0 if no child node with the specified index exists.

int Ionflux::Tools::Node::getChildIndex Node targetNode  )  [virtual]
 

Get child node index.

Get the index of a child node.

Parameters:
targetNode Child node.
Returns:
Index of the specified child node, or -1 if the specified node is not a child node of this node.

std::string Ionflux::Tools::Node::getData  )  [virtual]
 

Get data.

Returns:
Data entry (at index 0).

std::string Ionflux::Tools::Node::getData unsigned int  dataIndex  )  [virtual]
 

Get data entry.

Get data entry with specified index.

Note:
If used with an INT or DOUBLE node, this returns the string representation of the number. If you want the exact binary representation, use getBlob() instead.
Parameters:
dataIndex Data index.
Returns:
Data entry, or an empty string if entry with specified index does not exist.

int Ionflux::Tools::Node::getDataType  )  [virtual]
 

Get data type.

Returns:
Node data type.

double Ionflux::Tools::Node::getDouble  )  [virtual]
 

Get data as double.

Returns:
Data entry (at index 0).

double Ionflux::Tools::Node::getDouble unsigned int  dataIndex  )  [virtual]
 

Get data entry.

Get data entry with specified index.

Note:
If used with a BLOB node, using this may lead to unexpected behavior.
Parameters:
dataIndex Data index.
Returns:
Data entry, or 0 if entry with specified index does not exist.

int Ionflux::Tools::Node::getID  )  [virtual]
 

Get node ID.

Returns:
Node ID.

Node * Ionflux::Tools::Node::getIndexEntry int  indexID  )  [protected, virtual]
 

Get index entry.

Retreives a child node info record by ID.

Note:
If a corresponding node info entry is not found or the indexing mode is INDEX_MODE_NONE or indexID is negative, this function will return null.
Parameters:
indexID ID to search for.
Returns:
Pointer to a node with the specified name, or null if no suitable node is found.

Node * Ionflux::Tools::Node::getIndexEntry const std::string &  indexName  )  [protected, virtual]
 

Get index entry.

Retreives a child node info record by name.

Note:
If a corresponding index entry is not found or the indexing mode is INDEX_MODE_NONE or indexID is negative, this function will return null.
Parameters:
indexName Name to search for.
Returns:
Pointer to a node with the specified name, or null if no suitable node is found.

int Ionflux::Tools::Node::getIndexMode  )  [virtual]
 

Get child node indexing mode.

Returns:
Indexing mode.

int Ionflux::Tools::Node::getInt  )  [virtual]
 

Get data as integer.

Returns:
Data entry (at index 0).

int Ionflux::Tools::Node::getInt unsigned int  dataIndex  )  [virtual]
 

Get data entry.

Get data entry with specified index.

Note:
If used with a BLOB node, using this may lead to unexpected behavior.
Parameters:
dataIndex Data index.
Returns:
Data entry, or 0 if entry with specified index does not exist.

Reporter & Ionflux::Tools::Node::getLog  )  [virtual]
 

Get Console output/logging facility.

Returns:
The console output/logging facility used by this object.

std::string Ionflux::Tools::Node::getName  )  [virtual]
 

Get node name.

Returns:
Node name.

unsigned int Ionflux::Tools::Node::getNumChildren  )  [virtual]
 

Get number of children.

Returns:
Number of child nodes.

unsigned int Ionflux::Tools::Node::getNumChildren bool  recursive  )  [virtual]
 

Get number of children.

Return the number of children of this node. Pass true to retrieve the number of children recursively.

Note:
If called for a root node, this may be used to retrieve the number of nodes in a tree.
Parameters:
recursive Whether to get the number of children recursively.
Returns:
Number of child nodes.

unsigned int Ionflux::Tools::Node::getNumData  )  [virtual]
 

Get number of data entries.

Returns:
Number of data entries.

Node * Ionflux::Tools::Node::getParent  )  [virtual]
 

Get parent node.

Returns:
Pointer to parent node, or 0 if this is a root node.

std::string Ionflux::Tools::Node::getPath  )  [virtual]
 

Get tree path.

Get the fully qualified tree path from the root node to this node.

Note:
If a node in the path has a name, that name will be used in the tree path expression with the resolution operator. If a node has no name, but an ID, the ID will be used in the tree path expression using subscripting.
Returns:
Fully qualified tree path expression.

unsigned int Ionflux::Tools::Node::getRefCount Node childNode  )  [protected, virtual]
 

Get child node reference count.

Gets the reference count for a child node.

Parameters:
childNode Pointer to a child node.
Returns:
Reference count for childNode.

int Ionflux::Tools::Node::getUID bool  treeUID  )  [virtual]
 

Get unique ID.

Gets a unique ID (UID) for this node. The return value will be unique to this node if false is passed and unique to the whole tree if true is passed.

Parameters:
treeUID Whether the UID should be unique to the whole tree.
Returns:
Unique ID.

int Ionflux::Tools::Node::getUIDMode  )  [virtual]
 

Get child node UID assignment mode.

Returns:
UID assignment mode.

bool Ionflux::Tools::Node::isManaged  ) 
 

Get memory management flag.

Get the current memory management mode of this node.

Returns:
true if memory allocated for this node is managed by its parent node, false otherwise.

Node & Ionflux::Tools::Node::merge Node sourceNode,
bool  replace = false,
unsigned int  maxDepth = 0,
unsigned int  currentDepth = 0
[virtual]
 

Merge nodes.

Merges data entries and child nodes of the source node into the node.

Note:
The name and ID of each source child node will be checked against names and IDs child nodes of the source node. If replace is false or omitted, child nodes of the target node will not be replaced by child nodes of the source node if names or IDs are equal.
Parameters:
sourceNode Node which should be merged.
replace Whether child nodes in the target node should be replaced by child nodes from the source node.
maxDepth Maximum recursion depth.
currentDepth Depth of current node.

Node & Ionflux::Tools::Node::operator= Node sourceNode  )  [virtual]
 

Copy assignment.

Copies a node (and all its child nodes). The target node will retain its name, ID and parent, but all previous data and child nodes will be replaced by the data entries and child nodes of the node which is copied.

Parameters:
sourceNode Node which should be copied.

double Ionflux::Tools::Node::operator= double  newData  )  [virtual]
 

Assign value to data entry.

Assigns a value to the first data entry.

Parameters:
newData New value for data entry.

int Ionflux::Tools::Node::operator= int  newData  )  [virtual]
 

Assign value to data entry.

Assigns a value to the first data entry.

Parameters:
newData New value for data entry.

std::string Ionflux::Tools::Node::operator= const std::string &  newData  )  [virtual]
 

Assign value to data entry.

Assigns a value to the first data entry.

Parameters:
newData New value for data entry.

Node & Ionflux::Tools::Node::operator[] const std::string &  searchName  )  [virtual]
 

Find child node.

Return a child by name.

Note:
This will always create non-existent nodes, even with auto-create turned off. If you do not want this, you should not use subscripting, but findChild() instead. Also be aware that you cannot use subscription operators to access data fields in your code, while this is possible if you use subscripting in tree path expressions which are parsed at run-time. Use getData() or parsed tree paths if you want to access data entries in your source.
Parameters:
searchName The name of the child node to be returned.
Returns:
First child node with specified name, or a newly created node with that name.
See also:
findChild(), getData()

Node & Ionflux::Tools::Node::operator[] int  searchID  )  [virtual]
 

Find child node.

Return a child by numerical ID.

Note:
This will always create non-existent nodes, even with auto-create turned off. If you do not want this, you should not use subscripting, but findChild() instead. Also be aware that you cannot use subscription operators to access data fields in your code, while this is possible if you use subscripting in tree path expressions which are parsed at run-time. Use getData() or parsed tree paths if you want to access data entries in your source.
Parameters:
searchID The ID of the child node to be returned.
Returns:
First child node with specified ID, or a newly created node with that ID.
See also:
findChild(), getData()

unsigned int Ionflux::Tools::Node::printDebugInfo int  targetLevel  )  [virtual]
 

Print debug information.

Prints debug information for child nodes belonging to a certain tree depth level, while this node is assumed to be the root node.

unsigned int Ionflux::Tools::Node::printDebugInfo int  targetLevel,
int  callingLevel,
int  parentID,
int  childID
[virtual]
 

Print debug information.

Prints debug information for child nodes belonging to a certain tree depth level.

Parameters:
targetLevel The tree depth level for which debugging information should be printed.
callingLevel The tree depth level of the calling node.
parentID The child ID of the calling node.
childID The child ID of this node.
Returns:
Number of nodes of the specified tree depth.

unsigned int Ionflux::Tools::Node::refChild Node childNode  )  [protected, virtual]
 

Increase child node reference count.

Increases the reference count for a child node by one.

Parameters:
childNode Pointer to a child node.
Returns:
Reference count for childNode (after increment).

void Ionflux::Tools::Node::removeAllChildren bool  recursive  )  [virtual]
 

Remove all child nodes.

Remove all child nodes from this node. Pass true to recursively remove all child nodes.

Note:
If a child node to be removed is managed by its parent node, it will also be deleted. Also, child nodes of managed nodes will always be removed recursively, whether you pass true or not. This is necessary to ensure that all managed nodes are deleted if their parent node is deleted.
Parameters:
recursive Whether to remove child nodes recursively.

bool Ionflux::Tools::Node::removeChild Node targetNode,
bool  recursive
[virtual]
 

Remove child node.

Remove a child node from this node. Pass true to recursively try to remove the specified node.

Note:
If the child node to be removed is managed by this node and its (parent node internal) reference count drops to zero, it will also be deleted.
Parameters:
targetNode Pointer to the node to be deleted.
recursive Whether to remove the node recursively.
Returns:
true if the specified node has been deleted successfully, false otherwise.

bool Ionflux::Tools::Node::removeChild unsigned int  childIndex  )  [virtual]
 

Remove child node.

Remove a child node from this node.

Note:
If the child node to be removed is managed by this node and its (parent node internal) reference count drops to zero, it will also be deleted.
Parameters:
childIndex Index of the child node to be deleted.
Returns:
true if the specified node has been deleted successfully, false otherwise.

bool Ionflux::Tools::Node::removeData unsigned int  dataIndex  )  [virtual]
 

Remove data entry.

Remove data entry with specified index.

Parameters:
dataIndex Data index.
Returns:
true on success, false otherwise.

void Ionflux::Tools::Node::removeIndexEntries Node indexNode  )  [protected, virtual]
 

Remove index entries.

Removes a child node from all Indexes.

void Ionflux::Tools::Node::removeIndexEntry int  indexID  )  [protected, virtual]
 

Remove index entry.

Removes a child node info record from the ID index.

Parameters:
indexID ID to search for.

void Ionflux::Tools::Node::removeIndexEntry const std::string &  indexName  )  [protected, virtual]
 

Remove index entry.

Removes a child node info record from the name index.

Parameters:
indexName Name to search for.

void Ionflux::Tools::Node::removeManagedChildren  )  [virtual]
 

Remove managed children.

Removes all managed child nodes that are descendants of this node recursively.

void Ionflux::Tools::Node::serialize std::string &  target  )  [virtual]
 

Serialize sub-tree.

Serialize the sub-tree starting at this node. Any data resulting from the serialization will be appended to the target byte string.

Note:
See misc/node-serialization.txt for a description of the serialization format.
Parameters:
target Where to store the serialized sub-tree.
See also:
unpack()

void Ionflux::Tools::Node::setAutoCreate bool  newAutoCreate  )  [virtual]
 

Set auto-create mode.

If set to true, any operation that tries to access a non-existent child node or data entry will automatically create that child node or data entry. If set to false, such operations will (usually) return 0.

Parameters:
newAutoCreate Auto-create mode.

bool Ionflux::Tools::Node::setBlob unsigned int  dataIndex,
const std::string &  newData
[virtual]
 

Set data entry.

Sets value of data entry with specified index.

Note:
This function will always set the data entry to the specified bytes, regardless of the node data type.
Parameters:
dataIndex Data index.
newData New value for data entry.
Returns:
true on success, false otherwise.

bool Ionflux::Tools::Node::setChild unsigned int  childIndex,
Node newChild,
bool  newManage
[virtual]
 

Set child node.

Set a child node to a specified node.

Parameters:
childIndex Index of the child node to be set.
newChild Node to be set as child node.
newManage Whether memory allocated for the child node should be managed by this node.
Returns:
true on success, false otherwise.

bool Ionflux::Tools::Node::setData double  newData  )  [virtual]
 

Set data entry.

Sets value of first data entry with specified index.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
newData New value for data entry.
Returns:
true on success, false otherwise.

bool Ionflux::Tools::Node::setData unsigned int  newData  )  [virtual]
 

Set data entry.

Sets value of first data entry with specified index.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
newData New value for data entry.
Returns:
true on success, false otherwise.

bool Ionflux::Tools::Node::setData int  newData  )  [virtual]
 

Set data entry.

Sets value of first data entry with specified index.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
newData New value for data entry.
Returns:
true on success, false otherwise.

bool Ionflux::Tools::Node::setData const std::string &  newData  )  [virtual]
 

Set data entry.

Sets value of first data entry with specified index.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
newData New value for data entry.
Returns:
true on success, false otherwise.

bool Ionflux::Tools::Node::setData unsigned int  dataIndex,
double  newData
[virtual]
 

Set data entry.

Sets value of data entry with specified index.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
dataIndex Data index.
newData New value for data entry.
Returns:
true on success, false otherwise.

bool Ionflux::Tools::Node::setData unsigned int  dataIndex,
unsigned int  newData
[virtual]
 

Set data entry.

Sets value of data entry with specified index.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
dataIndex Data index.
newData New value for data entry.
Returns:
true on success, false otherwise.

bool Ionflux::Tools::Node::setData unsigned int  dataIndex,
int  newData
[virtual]
 

Set data entry.

Sets value of data entry with specified index.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
dataIndex Data index.
newData New value for data entry.
Returns:
true on success, false otherwise.

bool Ionflux::Tools::Node::setData unsigned int  dataIndex,
const std::string &  newData
[virtual]
 

Set data entry.

Sets value of data entry with specified index.

Note:
This function tries to convert as best as possible if the argument type does not match the node data type.
Parameters:
dataIndex Data index.
newData New value for data entry.
Returns:
true on success, false otherwise.

void Ionflux::Tools::Node::setDataType int  newDataType  )  [virtual]
 

Set data type.

Sets the data type of this node. Valid values are set by one of the Node::NODE_DATA_* constants.

Parameters:
newDataType Data type to be used for this node.

void Ionflux::Tools::Node::setID int  newID  )  [virtual]
 

Set ID.

Sets the numerical ID of this node.

Parameters:
newID Numerical ID of this node.

void Ionflux::Tools::Node::setIndexMode int  newIndexMode  )  [virtual]
 

Set child node indexing mode.

Set the child node indexing mode. Use this to automatically create and maintain an index of child nodes, which may result in faster access times but will consume more memory. Valid values are set by one of the Node::INDEX_MODE_* constants.

Parameters:
newIndexMode Child node indexing mode.

void Ionflux::Tools::Node::setManaged bool  newManaged  ) 
 

Set memory management flag.

This controls whether memory allocated for this node should be managed by its parent node.

Note:
This is used internally by the implementation and should not, under normal circumstances, be explicitly called from the application level.
Warning:
Do not call this function explicitly! If you need control over the memory management mode, use addChild() with appropriate arguments instead. Calling this function explicitly may result in unexpected behavior, or worse.
See also:
addChild()

void Ionflux::Tools::Node::setName const std::string &  newName  )  [virtual]
 

Set Name.

Sets the name of this node.

Parameters:
newName Name of this node.

void Ionflux::Tools::Node::setParent Node newParent  )  [virtual]
 

Set parent Node.

Sets the parent node of this node.

Parameters:
newParent Pointer to parent node.

void Ionflux::Tools::Node::setUIDMode int  newUIDMode  )  [virtual]
 

Set child node UID assignment mode.

Set the child node UID assignment mode. Use this to automatically assign IDs to child nodes created by addChild(). Valid values are set by one of the Node::UID_MODE_* constants.

Parameters:
newUIDMode Child node UID assignment mode.

std::string Ionflux::Tools::Node::toConfig const std::string &  indent = "",
unsigned int  level = 0
 

Get configuration file representation.

Create a representation of the node (and its children) suitable for insertion into a config file, using the extended (nested) syntax.

Note:
The configuration file representation is human-readable and editable in any text editor. It may consist of multiple lines.
Parameters:
indent Use this string to indent the lines of the string representation.
level The indentation level.
Returns:
Configuration file representation of the node.

void Ionflux::Tools::Node::traverse NodeDump target,
int  order
[virtual]
 

Traverse sub-tree.

Traverse the sub-tree starting at this node, in the specified order.

Parameters:
target Target to pass nodes to.
order Order of traversal.

bool Ionflux::Tools::Node::unpack const std::string &  serialized,
unsigned int  blockStart,
unsigned int  blockSize
[virtual]
 

Unpack sub-tree.

Unpack the sub-tree starting at this node. This will delete all data and remove all children currently in this node. Data extraction begins at 'blockStart' and at most 'blockSize' bytes will be used for unpacking nodes. If you pass 0 as the block size, the block size will be set to the size of the serialized input.

Note:
See misc/node-serialization.txt for a description of the serialization format.
Parameters:
serialized Sub-Tree in serialized form.
blockStart Position in the serialized data where the block to be unpacked starts.
blockSize Size of the block to be unpacked.
See also:
serialize()
Returns:
true if the data is successfully unpacked, false otherwise.

unsigned int Ionflux::Tools::Node::unrefChild Node childNode  )  [protected, virtual]
 

Decrease child node reference count.

Decreases the reference count for a child node by one.

Note:
If the reference count of a child node drops to zero, it will be removed from all indexes and, if managed by its parent node, deleted.
Parameters:
childNode Pointer to a child node.
Returns:
Reference count for childNode (after decrement).

bool Ionflux::Tools::Node::validateChildIndex unsigned int  childIndex  )  [protected, virtual]
 

Validate child node index.

Returns true if the child node index references a valid child node.

Note:
If the child node does not exist, but auto-create mode is set to true, the child node will be created.
Parameters:
childIndex The child node index to be validated.
Returns:
true if a child node with specified index exists, false otherwise.

bool Ionflux::Tools::Node::validateDataIndex unsigned int  dataIndex  )  [protected, virtual]
 

Validate data index.

Returns true if a data index references a valid data entry.

Note:
If the data entry does not exist, but auto-create mode is set to true, the data entry will be created.
Parameters:
dataIndex The data index to be validated.
Returns:
true if a data entry with specified index exists, false otherwise.


Member Data Documentation

bool Ionflux::Tools::Node::autoCreate [protected]
 

Auto-creation mode.

Whether to create requested child nodes and data entries on the fly if they do not already exist.

std::map<Node*, unsigned int> Ionflux::Tools::Node::childNodeRef [protected]
 

Child node reference counter.

std::vector<NodeInfo> Ionflux::Tools::Node::children [protected]
 

Vector of pointers to children.

int Ionflux::Tools::Node::dataType [protected]
 

Node data type.

std::vector<Node*> Ionflux::Tools::Node::idIndex [protected]
 

Index vector (TODO: Maybe reimplement this as a hash map).

const int Ionflux::Tools::Node::INDEX_MODE_NODE = 1 [static]
 

Indexing mode: Per node indexing.

const int Ionflux::Tools::Node::INDEX_MODE_NONE = 0 [static]
 

Indexing mode: Do not use indexing (default).

const int Ionflux::Tools::Node::INDEX_MODE_TREE = 2 [static]
 

Indexing mode: Per tree indexing.

int Ionflux::Tools::Node::indexMode [protected]
 

Indexing mode.

Ionflux::Tools::Reporter* Ionflux::Tools::Node::log [protected]
 

Console output/logging.

bool Ionflux::Tools::Node::managed [protected]
 

Memory management mode.

If set to true, this indicates that memory allocated for this node is managed by its parent node.

const unsigned int Ionflux::Tools::Node::MAX_ID_INDEX_SIZE = 268435456L [static]
 

Maximum size of ID index.

int Ionflux::Tools::Node::maxUID [protected]
 

Maximum UID assigned by this node.

std::map<std::string, Node*> Ionflux::Tools::Node::nameIndex [protected]
 

Index map.

const int Ionflux::Tools::Node::NODE_DATA_BLOB = 0 [static]
 

Node data type: Blob (Binary large object, including byte strings).

const int Ionflux::Tools::Node::NODE_DATA_DOUBLE = 2 [static]
 

Node data type: Double.

const int Ionflux::Tools::Node::NODE_DATA_INT = 1 [static]
 

Node data type: Integer.

const unsigned int Ionflux::Tools::Node::NODE_HEADER_SIZE = 53 [static]
 

Size of serialized node header in bytes.

const int Ionflux::Tools::Node::NODE_ID_NOT_SET = -1 [static]
 

Node ID: Not set.

std::vector<std::string> Ionflux::Tools::Node::nodeData [protected]
 

Data vector.

int Ionflux::Tools::Node::nodeID [protected]
 

Numerical ID of this node.

std::string Ionflux::Tools::Node::nodeName [protected]
 

Name of this node.

Node* Ionflux::Tools::Node::parent [protected]
 

Parent node.

const int Ionflux::Tools::Node::TRAVERSAL_INORDER = 0 [static]
 

Traversal order: Inorder.

const int Ionflux::Tools::Node::TRAVERSAL_POSTORDER = 2 [static]
 

Traversal order: Postorder.

const int Ionflux::Tools::Node::TRAVERSAL_PREORDER = 1 [static]
 

Traversal order: Preorder.

const int Ionflux::Tools::Node::UID_MODE_NODE = 1 [static]
 

Child node UID assignment mode: Assign ID unique to this node.

const int Ionflux::Tools::Node::UID_MODE_NONE = 0 [static]
 

Child node UID assignment mode: Do not assign UID (default).

const int Ionflux::Tools::Node::UID_MODE_TREE = 2 [static]
 

Child node UID assignment mode: Assign ID unique to the tree.

int Ionflux::Tools::Node::uidMode [protected]
 

Child node UID assignment mode.


The documentation for this class was generated from the following files:
Generated on Tue Mar 14 21:09:04 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6