DCMTK
Version 3.6.6
OFFIS DICOM Toolkit
|
Class managing a tree of nodes. More...
Public Member Functions | |
DSRTree () | |
default constructor | |
DSRTree (const DSRTree< T > &tree) | |
copy constructor. More... | |
virtual | ~DSRTree () |
destructor | |
DSRTree & | operator= (DSRTree< T > tree) |
assignment operator. More... | |
virtual void | clear () |
clear all member variables, i.e. the tree with all nodes | |
void | clearAnnotations () |
clear annotations of all tree nodes | |
OFBool | isEmpty () const |
check whether tree has any nodes More... | |
size_t | countNodes () const |
count number of nodes in the tree. More... | |
size_t | getNextNodeID () const |
get ID of the next node to be created. More... | |
size_t | gotoRoot () |
set internal cursor to root node More... | |
size_t | gotoNode (const size_t searchID, const OFBool startFromRoot=OFTrue) |
set internal cursor to specified node More... | |
size_t | gotoNode (const OFString &reference, const OFBool startFromRoot=OFTrue) |
set internal cursor to specified node More... | |
size_t | gotoNode (const DSRTreeNodeAnnotation &annotation, const OFBool startFromRoot=OFTrue) |
set internal cursor to specified node More... | |
size_t | gotoNode (const T &nodeValue, const OFBool startFromRoot=OFTrue) |
set internal cursor to specified node (given by its value). More... | |
virtual size_t | addNode (T *node, const E_AddMode addMode=AM_afterCurrent) |
add new node to the current one. More... | |
virtual size_t | replaceNode (T *node) |
replace current node by the given one. More... | |
virtual T * | extractNode () |
extract current node from tree. More... | |
virtual T * | getAndRemoveRootNode () |
get pointer to root node and "forget" the internal reference to this node. More... | |
virtual size_t | removeNode () |
remove current node from tree. More... | |
virtual DSRTree< T > * | extractSubTree () |
extract a subtree, i.e. a fragment from this tree. More... | |
virtual DSRTree< T > * | cloneSubTree (const size_t stopAfterNodeID=0) const |
clone a subtree, i.e. a fragment of this tree. More... | |
Protected Member Functions | |
DSRTree (T *rootNode) | |
special constructor that receives a pointer to the root node. More... | |
DSRTree (const DSRTreeNodeCursor< T > &startCursor, size_t stopAfterNodeID) | |
special copy constructor that clones a particular subtree only More... | |
void | swap (DSRTree< T > &tree) |
fast, non-throwing swap function. More... | |
virtual T * | getRoot () const |
get pointer to root node More... | |
virtual void | deleteTreeFromRootNode (T *rootNode) |
delete a tree given by its root node. More... | |
Private Attributes | |
T * | RootNode |
pointer to the root tree node | |
Class managing a tree of nodes.
copy constructor.
Please note that the internal cursor is not copied but reset, i.e. set to the root node.
tree | tree to be copied |
References DSRTree< T >::addNode(), OFStack< T >::empty(), DSRTree< T >::getRoot(), DSRTree< T >::gotoRoot(), DSRTree< T >::isEmpty(), OFStack< T >::pop(), OFStack< T >::push(), and OFStack< T >::top().
special constructor that receives a pointer to the root node.
Please note that the 'rootNode' and the associated tree is not copied!
rootNode | pointer to the root node of the "new" tree |
References DSRTree< T >::gotoRoot().
|
protected |
special copy constructor that clones a particular subtree only
startCursor | cursor pointing to first node of the subtree to be copied |
stopAfterNodeID | ID of the node after which the cloning should stop |
References DSRTree< T >::addNode(), OFStack< T >::empty(), DSRTreeNodeCursor< T >::getNode(), DSRTree< T >::gotoRoot(), OFStack< T >::pop(), OFStack< T >::push(), and OFStack< T >::top().
|
virtual |
add new node to the current one.
Please note that no copy of the given node is created. Therefore, the node should be created with new() - do not use a reference to a local variable. If the node could be added successfully, the cursor is set to it automatically.
node | pointer to the new node to be added |
addMode | flag specifying at which position to add the new node |
Reimplemented in DSRDocumentSubTree.
References DSRTreeNode::Down, DSRTreeNode::getIdent(), DSRTreeNode::Next, and DSRTreeNode::Prev.
Referenced by DSRTree< T >::DSRTree().
|
virtual |
clone a subtree, i.e. a fragment of this tree.
The cloning starts with the current node and ends with the given node.
stopAfterNodeID | ID of the node after which the cloning should stop. By default (0), the process ends after cloning the current node with all of its child nodes (if any). |
Reimplemented in DSRDocumentSubTree.
size_t DSRTree< T >::countNodes |
count number of nodes in the tree.
This method iterates over all nodes that are stored in the tree.
References DSRTreeNodeCursor< T >::isValid(), and DSRTreeNodeCursor< T >::iterate().
|
protectedvirtual |
delete a tree given by its root node.
Please note that the given 'rootNode' pointer becomes invalid afterwards.
rootNode | pointer to the root node of the tree to be deleted |
|
virtual |
extract current node from tree.
Please note that not only the specified node but also all of its child nodes are extracted from the tree. The cursor is set automatically to a new valid position.
Reimplemented in DSRDocumentSubTree.
References DSRTreeNode::Down, DSRTreeNode::getNext(), DSRTreeNode::getPrev(), DSRTreeNode::Next, and DSRTreeNode::Prev.
extract a subtree, i.e. a fragment from this tree.
The subtree is specified by the current node, which becomes the root of the subtree.
Reimplemented in DSRDocumentSubTree.
|
virtual |
get pointer to root node and "forget" the internal reference to this node.
In other words: after calling this method, the stored tree will be empty. This also means that the caller is responsible for deleting the allocated memory.
Reimplemented in DSRDocumentSubTree.
|
inline |
get ID of the next node to be created.
The node ID uniquely identifies a content item in the document tree.
References DSRTreeNode::getIdentCounter().
|
protectedvirtual |
get pointer to root node
Referenced by DSRTree< T >::DSRTree().
size_t DSRTree< T >::gotoNode | ( | const DSRTreeNodeAnnotation & | annotation, |
const OFBool | startFromRoot = OFTrue |
||
) |
set internal cursor to specified node
annotation | annotation of the node to set the cursor to |
startFromRoot | flag indicating whether to start from the root node or the current one |
References DSRTreeNodeCursor< T >::gotoNode(), and DSRTreeNodeAnnotation::isEmpty().
size_t DSRTree< T >::gotoNode | ( | const OFString & | reference, |
const OFBool | startFromRoot = OFTrue |
||
) |
set internal cursor to specified node
reference | position string of the node to set the cursor to. (the format is e.g. "1.2.3" for the third child of the second child of the first node - see DSRTreeNodeCursor). |
startFromRoot | flag indicating whether to start from the root node or the current one |
References OFString::empty(), and DSRTreeNodeCursor< T >::gotoNode().
size_t DSRTree< T >::gotoNode | ( | const size_t | searchID, |
const OFBool | startFromRoot = OFTrue |
||
) |
set internal cursor to specified node
searchID | ID of the node to set the cursor to |
startFromRoot | flag indicating whether to start from the root node or the current one |
References DSRTreeNodeCursor< T >::gotoNode().
size_t DSRTree< T >::gotoNode | ( | const T & | nodeValue, |
const OFBool | startFromRoot = OFTrue |
||
) |
set internal cursor to specified node (given by its value).
This method requires that T implements the comparison operator "not equal".
nodeValue | value of the node to set the cursor to |
startFromRoot | flag indicating whether to start from the root node or the current one |
References DSRTreeNodeCursor< T >::gotoNode().
|
inline |
set internal cursor to root node
Referenced by DSRTree< T >::DSRTree().
|
inline |
check whether tree has any nodes
Referenced by DSRTree< T >::DSRTree().
assignment operator.
Please note that internally the copy constructor is used, so the same comments apply.
tree | tree to be copied |
|
virtual |
remove current node from tree.
Please note that not only the specified node but also all of its child nodes are removed from the tree and then deleted. The cursor is set automatically to a new valid position.
Reimplemented in DSRDocumentSubTree.
References OFStack< T >::empty(), OFStack< T >::pop(), OFStack< T >::push(), and OFStack< T >::top().
|
virtual |
replace current node by the given one.
Please note that no copy of the given node is created. Therefore, the node should be created with new() - do not use a reference to a local variable. If the node could be replaced successfully, the "old" node (and all of its child nodes) are deleted, and the cursor is set to the new one.
node | pointer to the new node to replace the current one |
Reimplemented in DSRDocumentSubTree.
References DSRTreeNode::Down, and DSRTreeNode::Next.
fast, non-throwing swap function.
The time complexity of this function is constant.
tree | tree to swap with |
References OFswap(), DSRTree< T >::RootNode, and DSRTreeNodeCursor< T >::swap().