ionflux.org | Impressum

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

Data tree. More...

#include <Tree.hpp>

Inheritance diagram for Ionflux::Tools::Tree:

Inheritance graph
[legend]
Collaboration diagram for Ionflux::Tools::Tree:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Tree ()
 Constructor.
 Tree (Node *initRoot, bool initManage)
 Constructor.
virtual ~Tree ()
 Destructor.
virtual NodefindNode (int nodeID)
 Find node.
virtual NodefindNode (const std::string &nodeName)
 Find node.
virtual DataEntry resolve (const std::string &treePathExpr, bool createPath, bool nodesOnly=false)
 Resolve fully qualified tree path.
virtual void setRoot (Node *newRoot, bool newManage)
 Set root node.
virtual void writeToFile (const std::string &fileName)
 Write tree to file.
virtual void readFromFile (const std::string &fileName)
 Read tree from file.
virtual bool eval (const std::string &treeExpr, Node &result, bool createPath)
 Evaluate tree expression.
virtual Nodeoperator[] (int searchID)
 Find child node.
virtual Nodeoperator[] (const std::string &searchName)
 Find child node.
virtual void printDebugInfo ()
 Print debug information.
virtual NodegetRoot ()
 Get root node.
virtual int getNumNodes ()
 Get number of nodes.
virtual void clear ()
 Clear the tree.
virtual ReportergetLog ()
 Get Console output/logging facility.

Protected Attributes

Ionflux::Tools::Reporter log
 Console output/logging.
NodeInfo root
 Root node.

Detailed Description

Data tree.

Tree type data structure. This behaves almost like a Node, but maintains a special node (the root node) as well as providing some convenience functions for I/O.


Constructor & Destructor Documentation

Ionflux::Tools::Tree::Tree  ) 
 

Constructor.

Construct new Tree object.

Ionflux::Tools::Tree::Tree Node initRoot,
bool  initManage
 

Constructor.

Construct new Tree object.

Parameters:
initRoot The root node of this tree.
initManage Whether memory allocated for the root node should be managed by this tree.

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

Destructor.

Destruct Tree object.


Member Function Documentation

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

Clear the tree.

Reimplemented in Ionflux::Tools::ConfigTree.

bool Ionflux::Tools::Tree::eval const std::string &  treeExpr,
Node result,
bool  createPath
[virtual]
 

Evaluate tree expression.

Evaluates a tree expression using nodes from the tree as variables. Pass true to createPath to create tree paths on the fly if it they do not already exist.

Parameters:
treeExpr Tree expression.
result Where to store the result of the evaluation.
createPath Whether to create a path if it does not already exist.
Returns:
true on success, false if there was an error.

Node * Ionflux::Tools::Tree::findNode const std::string &  nodeName  )  [virtual]
 

Find node.

Searches the tree for a node with the specified name.

Parameters:
nodeName The name of the node to be returned.
Returns:
Pointer to node with specified name if found, 0 otherwise.

Node * Ionflux::Tools::Tree::findNode int  nodeID  )  [virtual]
 

Find node.

Searches the tree for a node with the specified ID.

Parameters:
nodeID The ID of the node to be returned.
Returns:
Pointer to node with specified ID if found, 0 otherwise.

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

Get Console output/logging facility.

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

Reimplemented in Ionflux::Tools::Template.

int Ionflux::Tools::Tree::getNumNodes  )  [virtual]
 

Get number of nodes.

Returns:
Number of nodes in the tree.

Node * Ionflux::Tools::Tree::getRoot  )  [virtual]
 

Get root node.

Returns:
The root node of the tree.

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

Find child node.

Return a child of the root node by name. Returns the first child node with the specified 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:
Ionflux::Tools::Node::findChild()

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

Find child node.

Return a child of the root node by numerical ID. Returns the first child node with the specified 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:
Ionflux::Tools::Node::findChild()

void Ionflux::Tools::Tree::printDebugInfo  )  [virtual]
 

Print debug information.

void Ionflux::Tools::Tree::readFromFile const std::string &  fileName  )  [virtual]
 

Read tree from file.

Reads the tree from a file.

Parameters:
fileName Name of the input file.

DataEntry Ionflux::Tools::Tree::resolve const std::string &  treePathExpr,
bool  createPath,
bool  nodesOnly = false
[virtual]
 

Resolve fully qualified tree path.

Resolve a fully qualified tree path. Pass true to createPath to create a tree path on the fly if it does not already exist.

Parameters:
treePathExpr Fully qualified tree path.
createPath Whether to create the path if it does not already exist.
nodesOnly Whether subscripts should be treated as child node references by default.
Returns:
The data entry referenced by the specified tree path. If the specified node is not found (and cannot be auto-created), the corresponding field in the data entry will be set to 0.

void Ionflux::Tools::Tree::setRoot Node newRoot,
bool  newManage
[virtual]
 

Set root node.

Sets the root node of this tree to specified node.

Parameters:
newRoot The root node of this tree.
newManage Whether memory allocated for the root node should be managed by this tree.

void Ionflux::Tools::Tree::writeToFile const std::string &  fileName  )  [virtual]
 

Write tree to file.

Writes the tree to a file.

Parameters:
fileName Name of the output file.


Member Data Documentation

Ionflux::Tools::Reporter Ionflux::Tools::Tree::log [protected]
 

Console output/logging.

Reimplemented in Ionflux::Tools::Template.

NodeInfo Ionflux::Tools::Tree::root [protected]
 

Root node.


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