DCMTK
Version 3.6.1 20150924
OFFIS DICOM Toolkit
|
Class implementing a tree node cursor. More...
Public Member Functions | |
DSRTreeNodeCursor () | |
default constructor | |
DSRTreeNodeCursor (const DSRTreeNodeCursor< T > &cursor) | |
copy constructor More... | |
DSRTreeNodeCursor (T *node) | |
constructor More... | |
virtual | ~DSRTreeNodeCursor () |
destructor | |
DSRTreeNodeCursor< T > & | operator= (const DSRTreeNodeCursor< T > &cursor) |
assignment operator More... | |
DSRTreeNodeCursor< T > & | operator= (T *node) |
assignment operator More... | |
virtual void | clear () |
clear all member variables | |
virtual OFBool | isValid () const |
check whether cursor currently points to a valid node More... | |
size_t | countChildNodes (const OFBool searchIntoSub=OFTrue) const |
count number of children of the current node. More... | |
OFBool | hasParentNode () const |
check whether the current node has a parent More... | |
OFBool | hasChildNodes () const |
check whether the current node has any children More... | |
OFBool | hasPreviousNode () const |
check whether the current node has a preceding sibling More... | |
OFBool | hasNextNode () const |
check whether the current node has a following sibling More... | |
OFBool | hasSiblingNodes () const |
check whether the current node has any siblings More... | |
virtual T * | getNode () const |
get pointer to current node More... | |
virtual const T * | getParentNode () |
get pointer to parent node. More... | |
virtual const T * | getChildNode () const |
get pointer to first child node. More... | |
virtual const T * | getPreviousNode () const |
get pointer to previous node. More... | |
virtual const T * | getNextNode () const |
get pointer to next node. More... | |
size_t | gotoFirst () |
goto first node on the same level (first sibling). More... | |
size_t | gotoLast () |
goto last node on the same level (last sibling). More... | |
size_t | gotoPrevious () |
goto previous node on the same level (preceding sibling) More... | |
size_t | gotoNext () |
goto next node on the same level (following sibling) More... | |
size_t | goUp () |
goto parent node (one level up) More... | |
size_t | goDown () |
goto first child node (one level down) More... | |
size_t | iterate (const OFBool searchIntoSub=OFTrue) |
iterate over all nodes. More... | |
size_t | gotoNode (const size_t searchID) |
set cursor to specified node. More... | |
size_t | gotoNode (const OFString &position, const char separator= '.') |
set cursor to specified node. More... | |
size_t | gotoNode (const DSRTreeNodeAnnotation &annotation) |
set cursor to specified node. More... | |
size_t | getNodeID () const |
get current node ID. More... | |
size_t | getLevel () const |
get current level. More... | |
const OFString & | getPosition (OFString &position, const char separator= '.') const |
get position string of the current node. More... | |
Protected Member Functions | |
void | clearNodeCursorStack () |
clear the internal node cursor stack | |
size_t | setCursor (T *node) |
set cursor to specified node. More... | |
Protected Attributes | |
T * | NodeCursor |
pointer to current node | |
OFStack< T * > | NodeCursorStack |
stack of node pointers. Used to store the cursor position of upper levels. | |
size_t | Position |
current position within the current level | |
OFList< size_t > | PositionList |
list of position counters in upper levels | |
Class implementing a tree node cursor.
DSRTreeNodeCursor< T >::DSRTreeNodeCursor | ( | const DSRTreeNodeCursor< T > & | cursor | ) |
copy constructor
cursor | object to be copied |
DSRTreeNodeCursor< T >::DSRTreeNodeCursor | ( | T * | node | ) |
constructor
node | pointer to tree node used to initialize the cursor (set to this node) |
size_t DSRTreeNodeCursor< T >::countChildNodes | ( | const OFBool | searchIntoSub = OFTrue | ) | const |
count number of children of the current node.
This method iterates over all children of the current node, either on all sub-levels or on the first child level only.
searchIntoSub | flag indicating whether to search into sub-trees ("deep search") or on the first child level only |
References DSRTreeNodeCursor< T >::NodeCursor.
|
virtual |
get pointer to first child node.
Can be used to have a lookup to the first child node without changing the cursor.
References DSRTreeNodeCursor< T >::NodeCursor.
Referenced by DSRTreeNodeCursor< T >::hasChildNodes().
size_t DSRTreeNodeCursor< T >::getLevel | ( | ) | const |
get current level.
The level starts with 1 for the root node, then 2 for its child nodes, etc.
References DSRTreeNodeCursor< T >::NodeCursor, DSRTreeNodeCursor< T >::NodeCursorStack, and OFStack< T >::size().
|
virtual |
get pointer to next node.
Can be used to have a lookup to the next node without changing the cursor.
References DSRTreeNodeCursor< T >::NodeCursor.
Referenced by DSRTreeNodeCursor< T >::hasNextNode(), and DSRTreeNodeCursor< T >::hasSiblingNodes().
|
virtual |
get pointer to current node
References DSRTreeNodeCursor< T >::NodeCursor.
Referenced by DSRTree< T >::clearAnnotations(), and DSRTree< T >::DSRTree().
size_t DSRTreeNodeCursor< T >::getNodeID | ( | ) | const |
get current node ID.
The node ID uniquely identifies a content item in the document tree. Most of the navigation methods above do return this ID too.
References DSRTreeNodeCursor< T >::NodeCursor.
|
virtual |
get pointer to parent node.
Can be used to have a lookup to the parent node without changing the cursor.
References DSRTreeNodeCursor< T >::hasParentNode(), DSRTreeNodeCursor< T >::NodeCursorStack, and OFStack< T >::top().
const OFString & DSRTreeNodeCursor< T >::getPosition | ( | OFString & | position, |
const char | separator = '.' |
||
) | const |
get position string of the current node.
Specifies the position of each node by means of a dot separated string of position counters. The first figure of this string specifies the position within the first level (e.g. "1"), the second one the position in the second level (e.g. "2"), the third one the position in the third level (e.g. "3"), etc. A position string of "1.2.3" would, therefore, point to the third child of the second child of the first node.
position | variable where the position string should be stored |
separator | character used to separate the figures (default: '.') |
References OFList< T >::begin(), OFString::clear(), OFString::empty(), OFList< T >::end(), DSRTypes::numberToString(), DSRTreeNodeCursor< T >::Position, and DSRTreeNodeCursor< T >::PositionList.
|
virtual |
get pointer to previous node.
Can be used to have a lookup to the previous node without changing the cursor.
References DSRTreeNodeCursor< T >::NodeCursor.
Referenced by DSRTreeNodeCursor< T >::hasPreviousNode(), and DSRTreeNodeCursor< T >::hasSiblingNodes().
size_t DSRTreeNodeCursor< T >::goDown | ( | ) |
goto first child node (one level down)
References DSRTreeNodeCursor< T >::NodeCursor, DSRTreeNodeCursor< T >::NodeCursorStack, DSRTreeNodeCursor< T >::Position, DSRTreeNodeCursor< T >::PositionList, OFStack< T >::push(), and OFList< T >::push_back().
Referenced by DSRTreeNodeCursor< T >::gotoNode().
size_t DSRTreeNodeCursor< T >::gotoFirst | ( | ) |
goto first node on the same level (first sibling).
Please note that the first node might be identical to the current node.
References DSRTreeNodeCursor< T >::NodeCursor, and DSRTreeNodeCursor< T >::Position.
size_t DSRTreeNodeCursor< T >::gotoLast | ( | ) |
goto last node on the same level (last sibling).
Please note that the last node might be identical to the current node.
References DSRTreeNodeCursor< T >::NodeCursor, and DSRTreeNodeCursor< T >::Position.
size_t DSRTreeNodeCursor< T >::gotoNext | ( | ) |
goto next node on the same level (following sibling)
References DSRTreeNodeCursor< T >::NodeCursor, and DSRTreeNodeCursor< T >::Position.
Referenced by DSRTreeNodeCursor< T >::gotoNode().
size_t DSRTreeNodeCursor< T >::gotoNode | ( | const size_t | searchID | ) |
set cursor to specified node.
Starts from current position!
searchID | ID of the node to set the cursor to |
References DSRTreeNodeCursor< T >::iterate(), and DSRTreeNodeCursor< T >::NodeCursor.
Referenced by DSRTree< T >::gotoNode().
size_t DSRTreeNodeCursor< T >::gotoNode | ( | const OFString & | position, |
const char | separator = '.' |
||
) |
set cursor to specified node.
Starts from current position!
position | 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 getPosition()). |
separator | character used to separate the figures (default: '.') |
References OFString::c_str(), OFString::empty(), OFString::find(), DSRTreeNodeCursor< T >::goDown(), DSRTreeNodeCursor< T >::gotoNext(), DSRTreeNodeCursor< T >::NodeCursor, DSRTypes::stringToNumber(), and OFString::substr().
size_t DSRTreeNodeCursor< T >::gotoNode | ( | const DSRTreeNodeAnnotation & | annotation | ) |
set cursor to specified node.
Starts from current position!
annotation | annotation of the node to set the cursor to |
References DSRTreeNodeAnnotation::isEmpty(), DSRTreeNodeCursor< T >::iterate(), and DSRTreeNodeCursor< T >::NodeCursor.
size_t DSRTreeNodeCursor< T >::gotoPrevious | ( | ) |
goto previous node on the same level (preceding sibling)
References DSRTreeNodeCursor< T >::NodeCursor, and DSRTreeNodeCursor< T >::Position.
size_t DSRTreeNodeCursor< T >::goUp | ( | ) |
goto parent node (one level up)
References OFList< T >::back(), OFStack< T >::empty(), OFList< T >::empty(), DSRTreeNodeCursor< T >::NodeCursor, DSRTreeNodeCursor< T >::NodeCursorStack, OFStack< T >::pop(), OFList< T >::pop_back(), DSRTreeNodeCursor< T >::Position, DSRTreeNodeCursor< T >::PositionList, and OFStack< T >::top().
Referenced by DSRTree< T >::DSRTree().
OFBool DSRTreeNodeCursor< T >::hasChildNodes | ( | ) | const |
check whether the current node has any children
References DSRTreeNodeCursor< T >::getChildNode().
OFBool DSRTreeNodeCursor< T >::hasNextNode | ( | ) | const |
check whether the current node has a following sibling
References DSRTreeNodeCursor< T >::getNextNode().
OFBool DSRTreeNodeCursor< T >::hasParentNode | ( | ) | const |
check whether the current node has a parent
References OFStack< T >::empty(), DSRTreeNodeCursor< T >::NodeCursor, and DSRTreeNodeCursor< T >::NodeCursorStack.
Referenced by DSRTreeNodeCursor< T >::getParentNode().
OFBool DSRTreeNodeCursor< T >::hasPreviousNode | ( | ) | const |
check whether the current node has a preceding sibling
References DSRTreeNodeCursor< T >::getPreviousNode().
OFBool DSRTreeNodeCursor< T >::hasSiblingNodes | ( | ) | const |
check whether the current node has any siblings
References DSRTreeNodeCursor< T >::getNextNode(), and DSRTreeNodeCursor< T >::getPreviousNode().
|
virtual |
check whether cursor currently points to a valid node
Reimplemented in DSRRootTemplate, DSRDocumentSubTree, DSRDocumentTree, and DSRSubTemplate.
References DSRTreeNodeCursor< T >::NodeCursor.
Referenced by DSRTree< T >::clearAnnotations(), and DSRTree< T >::countNodes().
size_t DSRTreeNodeCursor< T >::iterate | ( | const OFBool | searchIntoSub = OFTrue | ) |
iterate over all nodes.
Starts from current position!
searchIntoSub | flag indicating whether to search into sub-trees ("deep search") or on the current level only |
References OFList< T >::back(), OFStack< T >::empty(), OFList< T >::empty(), DSRTreeNodeCursor< T >::NodeCursor, DSRTreeNodeCursor< T >::NodeCursorStack, OFStack< T >::pop(), OFList< T >::pop_back(), DSRTreeNodeCursor< T >::Position, DSRTreeNodeCursor< T >::PositionList, OFStack< T >::push(), OFList< T >::push_back(), and OFStack< T >::top().
Referenced by DSRTree< T >::clearAnnotations(), DSRTree< T >::countNodes(), and DSRTreeNodeCursor< T >::gotoNode().
DSRTreeNodeCursor< T > & DSRTreeNodeCursor< T >::operator= | ( | const DSRTreeNodeCursor< T > & | cursor | ) |
assignment operator
cursor | object to be copied |
References DSRTreeNodeCursor< T >::NodeCursor, DSRTreeNodeCursor< T >::NodeCursorStack, DSRTreeNodeCursor< T >::Position, and DSRTreeNodeCursor< T >::PositionList.
DSRTreeNodeCursor< T > & DSRTreeNodeCursor< T >::operator= | ( | T * | node | ) |
assignment operator
node | node to which the cursor should be set |
References DSRTreeNodeCursor< T >::setCursor().
|
protected |
set cursor to specified node.
Clears the internal position list/stack and sets the position counter to 1.
node | node to which the cursor should be set |
References OFList< T >::clear(), DSRTreeNodeCursor< T >::clearNodeCursorStack(), DSRTreeNodeCursor< T >::NodeCursor, DSRTreeNodeCursor< T >::Position, and DSRTreeNodeCursor< T >::PositionList.
Referenced by DSRTree< T >::gotoRoot(), and DSRTreeNodeCursor< T >::operator=().