#include <Node.hpp>
Collaboration diagram for Ionflux::Tools::Node:
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 Node * | addChild (int childID=NODE_ID_NOT_SET, const std::string &childName="") |
Add a child. | |
virtual void | addChild (Node *newChild, bool newManage) |
Add a child. | |
virtual Node * | findChild (int searchID, bool recursive=false) |
Find child node. | |
virtual Node * | findChild (const std::string &searchName, bool recursive=false) |
Find child node. | |
virtual Node * | getChild (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 Node & | operator[] (int searchID) |
Find child node. | |
virtual Node & | operator[] (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 Node & | operator= (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 Node * | getParent () |
Get parent node. | |
virtual std::string | getPath () |
Get tree path. | |
virtual void | clear () |
Clear the node. | |
virtual Node & | merge (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 Reporter & | getLog () |
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 Node * | getIndexEntry (const std::string &indexName) |
Get index entry. | |
virtual void | removeIndexEntry (const std::string &indexName) |
Remove index entry. | |
virtual Node * | getIndexEntry (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::Reporter * | log |
Console output/logging. | |
int | nodeID |
Numerical ID of this node. | |
std::string | nodeName |
Name of this node. | |
std::vector< NodeInfo > | children |
Vector of pointers to children. | |
std::vector< std::string > | nodeData |
Data vector. | |
int | dataType |
Node data type. | |
Node * | parent |
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. |
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. Construct new Node object. |
|
Constructor. Construct new Node object.
|
|
Constructor. Construct new Node object.
|
|
Constructor. Construct new Node object.
|
|
Constructor. Construct new Node object.
|
|
Constructor. Construct new Node object.
|
|
Constructor. Construct new Node object.
|
|
Destructor. Destruct Node object. |
|
Add a child. Adds a new child node to this node.
|
|
Add a child. Creates a new child node and adds it to this node. The node thus created is managed by its parent node.
|
|
Add data entry. Adds data to this node.
|
|
Add data entry. Adds data to this node.
|
|
Add data entry. Adds data to this node.
|
|
Add index entry. Adds a child node to the name or ID index (or both).
|
|
Clear the node.
|
|
Remove all data entries.
Remove all data entries from this node. Pass
|
|
Clear ID index.
|
|
Clear all indexes.
|
|
Clear name index.
|
|
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
|
|
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.
|
|
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.
|
|
Find child node. Return a child by name.
|
|
Find child node. Return a child by numerical ID.
|
|
Get auto-create mode.
|
|
Get data as blob.
|
|
Get data entry. Get data entry with specified index.
|
|
Get child node. Get child node with specified index.
|
|
Get child node index. Get the index of a child node.
|
|
Get data.
|
|
Get data entry. Get data entry with specified index.
|
|
Get data type.
|
|
Get data as double.
|
|
Get data entry. Get data entry with specified index.
|
|
Get node ID.
|
|
Get index entry. Retreives a child node info record by ID.
|
|
Get index entry. Retreives a child node info record by name.
|
|
Get child node indexing mode.
|
|
Get data as integer.
|
|
Get data entry. Get data entry with specified index.
|
|
Get Console output/logging facility.
|
|
Get node name.
|
|
Get number of children.
|
|
Get number of children.
Return the number of children of this node. Pass
|
|
Get number of data entries.
|
|
Get parent node.
|
|
Get tree path. Get the fully qualified tree path from the root node to this node.
|
|
Get child node reference count. Gets the reference count for a child node.
|
|
Get unique ID.
Gets a unique ID (UID) for this node. The return value will be unique to this node if
|
|
Get child node UID assignment mode.
|
|
Get memory management flag. Get the current memory management mode of this node.
|
|
Merge nodes. Merges data entries and child nodes of the source node into the node.
|
|
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.
|
|
Assign value to data entry. Assigns a value to the first data entry.
|
|
Assign value to data entry. Assigns a value to the first data entry.
|
|
Assign value to data entry. Assigns a value to the first data entry.
|
|
Find child node. Return a child by name.
|
|
Find child node. Return a child by numerical ID.
|
|
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. |
|
Print debug information. Prints debug information for child nodes belonging to a certain tree depth level.
|
|
Increase child node reference count. Increases the reference count for a child node by one.
|
|
Remove all child nodes.
Remove all child nodes from this node. Pass
|
|
Remove child node.
Remove a child node from this node. Pass
|
|
Remove child node. Remove a child node from this node.
|
|
Remove data entry. Remove data entry with specified index.
|
|
Remove index entries. Removes a child node from all Indexes. |
|
Remove index entry. Removes a child node info record from the ID index.
|
|
Remove index entry. Removes a child node info record from the name index.
|
|
Remove managed children. Removes all managed child nodes that are descendants of this node recursively. |
|
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.
|
|
Set auto-create mode.
If set to
|
|
Set data entry. Sets value of data entry with specified index.
|
|
Set child node. Set a child node to a specified node.
|
|
Set data entry. Sets value of first data entry with specified index.
|
|
Set data entry. Sets value of first data entry with specified index.
|
|
Set data entry. Sets value of first data entry with specified index.
|
|
Set data entry. Sets value of first data entry with specified index.
|
|
Set data entry. Sets value of data entry with specified index.
|
|
Set data entry. Sets value of data entry with specified index.
|
|
Set data entry. Sets value of data entry with specified index.
|
|
Set data entry. Sets value of data entry with specified index.
|
|
Set data type. Sets the data type of this node. Valid values are set by one of the Node::NODE_DATA_* constants.
|
|
Set ID. Sets the numerical ID of this node.
|
|
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.
|
|
Set memory management flag. This controls whether memory allocated for this node should be managed by its parent node.
|
|
Set Name. Sets the name of this node.
|
|
Set parent Node. Sets the parent node of this node.
|
|
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.
|
|
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.
|
|
Traverse sub-tree. Traverse the sub-tree starting at this node, in the specified order.
|
|
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.
|
|
Decrease child node reference count. Decreases the reference count for a child node by one.
|
|
Validate child node index.
Returns
|
|
Validate data index.
Returns
|
|
Auto-creation mode. Whether to create requested child nodes and data entries on the fly if they do not already exist. |
|
Child node reference counter.
|
|
Vector of pointers to children.
|
|
Node data type.
|
|
Index vector (TODO: Maybe reimplement this as a hash map).
|
|
Indexing mode: Per node indexing.
|
|
Indexing mode: Do not use indexing (default).
|
|
Indexing mode: Per tree indexing.
|
|
Indexing mode.
|
|
Console output/logging.
|
|
Memory management mode.
If set to |
|
Maximum size of ID index.
|
|
Maximum UID assigned by this node.
|
|
Index map.
|
|
Node data type: Blob (Binary large object, including byte strings).
|
|
Node data type: Double.
|
|
Node data type: Integer.
|
|
Size of serialized node header in bytes.
|
|
Node ID: Not set.
|
|
Data vector.
|
|
Numerical ID of this node.
|
|
Name of this node.
|
|
Parent node.
|
|
Traversal order: Inorder.
|
|
Traversal order: Postorder.
|
|
Traversal order: Preorder.
|
|
Child node UID assignment mode: Assign ID unique to this node.
|
|
Child node UID assignment mode: Do not assign UID (default).
|
|
Child node UID assignment mode: Assign ID unique to the tree.
|
|
Child node UID assignment mode.
|