DCMTK  Version 3.6.1 20170228
OFFIS DICOM Toolkit
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DSRTreeNodeCursor< T, B > Class Template Reference

Class implementing a tree node cursor. More...

Public Member Functions

 DSRTreeNodeCursor ()
 default constructor
 
 DSRTreeNodeCursor (const DSRTreeNodeCursor< T, B > &cursor)
 copy constructor More...
 
 DSRTreeNodeCursor (T *node, const DSRPositionCounter *position=NULL)
 constructor. More...
 
virtual ~DSRTreeNodeCursor ()
 destructor
 
DSRTreeNodeCursor< T, B > & operator= (const DSRTreeNodeCursor< T, B > &cursor)
 assignment operator More...
 
DSRTreeNodeCursor< T, B > & operator= (T *node)
 assignment operator. More...
 
virtual void clear ()
 clear all member variables. More...
 
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 () const
 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 gotoParent ()
 goto parent node (one level up) More...
 
size_t gotoChild ()
 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...
 
DSRPositionCountergetPositionCounter ()
 get reference to internal position counter. More...
 
const OFStringgetPosition (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
 
const DSRTreeNodeCursor< T, B > & getCursor () const
 get cursor More...
 
void setCursor (const DSRTreeNodeCursor< T, B > &cursor)
 set cursor to specified object More...
 
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.
 
DSRPositionCounter Position
 counter for the current position within the current level and on upper levels
 

Detailed Description

template<typename T = DSRTreeNode, OFBool B = OFFalse>
class DSRTreeNodeCursor< T, B >

Class implementing a tree node cursor.

Template Parameters
Ttemplate type used for the tree node pointers
Bboolean flag that indicates whether to treat certain tree nodes differently (depends on the particular implementation)

Constructor & Destructor Documentation

template<typename T, OFBool B>
DSRTreeNodeCursor< T, B >::DSRTreeNodeCursor ( const DSRTreeNodeCursor< T, B > &  cursor)

copy constructor

Parameters
cursorobject to be copied
template<typename T, OFBool B>
DSRTreeNodeCursor< T, B >::DSRTreeNodeCursor ( T *  node,
const DSRPositionCounter position = NULL 
)

constructor.

See comments on setCursor(T*) method.

Parameters
nodepointer to tree node used to initialize the cursor
positionoptional pointer to position counter that should be used to initialize the internal counter

References DSRPositionCounter::getFlags(), DSRPositionCounter::initialize(), DSRPositionCounter::isValid(), DSRTreeNodeCursor< T, B >::NodeCursor, and DSRTreeNodeCursor< T, B >::Position.

Member Function Documentation

template<typename T , OFBool B>
void DSRTreeNodeCursor< T, B >::clear ( )
virtual

clear all member variables.

The cursor becomes invalid afterwards (same state as after default construction).

Reimplemented in DSRTree< T >, DSRTree< DSRDocumentTreeNode >, DSRDocumentSubTree, DSRRootTemplate, TID1500_MeasurementReport, DSRSubTemplate, and DSRDocumentTree.

template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::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.

Parameters
searchIntoSubflag indicating whether to search into sub-trees ("deep search") or on the first child level only
Returns
number of children of the current node, 0 if none
template<typename T , OFBool B>
const T * DSRTreeNodeCursor< T, B >::getChildNode ( ) const
virtual

get pointer to first child node.

Can be used to have a lookup to the first child node without changing the cursor.

Returns
pointer to first child node (if any), NULL otherwise
template<typename T , OFBool B>
const DSRTreeNodeCursor< T, B > & DSRTreeNodeCursor< T, B >::getCursor ( ) const
inlineprotected

get cursor

Returns
reference to cursor (this object)
template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::getLevel ( ) const
inline

get current level.

The level starts with 1 for the root node, then 2 for its child nodes, etc.

Returns
number of the current level if valid, 0 otherwise
template<typename T , OFBool B>
const T * DSRTreeNodeCursor< T, B >::getNextNode ( ) const
virtual

get pointer to next node.

Can be used to have a lookup to the next node without changing the cursor.

Returns
pointer to next node (if any), NULL otherwise
template<typename T , OFBool B>
T * DSRTreeNodeCursor< T, B >::getNode ( ) const
virtual

get pointer to current node

Returns
pointer to current node (might be NULL)

Reimplemented in DSRDocumentSubTree.

Referenced by DSRTree< T >::clearAnnotations(), and DSRTree< T >::DSRTree().

template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::getNodeID ( ) const
inline

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.

Returns
ID of the current node if valid, 0 otherwise
template<typename T , OFBool B>
const T * DSRTreeNodeCursor< T, B >::getParentNode ( ) const
virtual

get pointer to parent node.

Can be used to have a lookup to the parent node without changing the cursor.

Returns
pointer to parent node (if any), NULL otherwise
template<typename T , OFBool B>
const OFString & DSRTreeNodeCursor< T, B >::getPosition ( OFString position,
const char  separator = '.' 
) const
inline

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.

Parameters
positionvariable where the position string should be stored
separatorcharacter used to separate the figures (default: '.')
Returns
reference to the resulting position string (empty if invalid)
template<typename T , OFBool B>
DSRPositionCounter & DSRTreeNodeCursor< T, B >::getPositionCounter ( )
inline

get reference to internal position counter.

Please note that this method allows for manipulating the internal position counter, so handle with care!

Returns
reference to internal position counter
template<typename T , OFBool B>
const T * DSRTreeNodeCursor< T, B >::getPreviousNode ( ) const
virtual

get pointer to previous node.

Can be used to have a lookup to the previous node without changing the cursor.

Returns
pointer to previous node (if any), NULL otherwise
template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::goDown ( )

goto first child node (one level down)

Returns
ID of the first child node if successful, 0 otherwise
template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::gotoChild ( )
inline

goto first child node (one level down)

Returns
ID of the first child node if successful, 0 otherwise
template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::gotoFirst ( )

goto first node on the same level (first sibling).

Please note that the first node might be identical to the current node.

Returns
ID of the first node if successful, 0 otherwise
template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::gotoLast ( )

goto last node on the same level (last sibling).

Please note that the last node might be identical to the current node.

Returns
ID of the last node if successful, 0 otherwise
template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::gotoNext ( )

goto next node on the same level (following sibling)

Returns
ID of the next node if successful, 0 otherwise
template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::gotoNode ( const size_t  searchID)

set cursor to specified node.

Starts from current position!

Parameters
searchIDID of the node to set the cursor to
Returns
ID of the new current node if successful, 0 otherwise

Referenced by DSRTree< T >::gotoNode().

template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::gotoNode ( const OFString position,
const char  separator = '.' 
)

set cursor to specified node.

Starts from current position!

Parameters
positionposition 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()).
separatorcharacter used to separate the figures (default: '.')
Returns
ID of the new current node if successful, 0 otherwise

References OFString::c_str(), OFString::empty(), OFString::find(), DSRTypes::stringToNumber(), and OFString::substr().

template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::gotoNode ( const DSRTreeNodeAnnotation annotation)

set cursor to specified node.

Starts from current position!

Parameters
annotationannotation of the node to set the cursor to
Returns
ID of the new current node if successful, 0 otherwise

References DSRTreeNodeAnnotation::isEmpty().

template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::gotoParent ( )
inline

goto parent node (one level up)

Returns
ID of the parent node if successful, 0 otherwise
template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::gotoPrevious ( )

goto previous node on the same level (preceding sibling)

Returns
ID of the previous node if successful, 0 otherwise
template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::goUp ( )

goto parent node (one level up)

Returns
ID of the parent node if successful, 0 otherwise
template<typename T , OFBool B>
OFBool DSRTreeNodeCursor< T, B >::hasChildNodes ( ) const
inline

check whether the current node has any children

Returns
OFTrue if the current node has any children, OFFalse otherwise
template<typename T , OFBool B>
OFBool DSRTreeNodeCursor< T, B >::hasNextNode ( ) const
inline

check whether the current node has a following sibling

Returns
OFTrue if the current node has a following sibling, OFFalse otherwise
template<typename T , OFBool B>
OFBool DSRTreeNodeCursor< T, B >::hasParentNode ( ) const
inline

check whether the current node has a parent

Returns
OFTrue if the current node has a parent, OFFalse otherwise
template<typename T , OFBool B>
OFBool DSRTreeNodeCursor< T, B >::hasPreviousNode ( ) const
inline

check whether the current node has a preceding sibling

Returns
OFTrue if the current node has a preceding sibling, OFFalse otherwise
template<typename T , OFBool B>
OFBool DSRTreeNodeCursor< T, B >::hasSiblingNodes ( ) const
inline

check whether the current node has any siblings

Returns
OFTrue if the current node has any siblings, OFFalse otherwise
template<typename T , OFBool B>
OFBool DSRTreeNodeCursor< T, B >::isValid ( ) const
virtual
template<typename T , OFBool B>
size_t DSRTreeNodeCursor< T, B >::iterate ( const OFBool  searchIntoSub = OFTrue)

iterate over all nodes.

Starts from current position!

Parameters
searchIntoSubflag indicating whether to search into sub-trees ("deep search") or on the current level only
Returns
ID of the next node if successful, 0 otherwise

Referenced by DSRTree< T >::clearAnnotations(), and DSRTree< T >::countNodes().

template<typename T, OFBool B>
DSRTreeNodeCursor< T, B > & DSRTreeNodeCursor< T, B >::operator= ( const DSRTreeNodeCursor< T, B > &  cursor)

assignment operator

Parameters
cursorobject to be copied
Returns
reference to modified cursor (this object)
template<typename T, OFBool B>
DSRTreeNodeCursor< T, B > & DSRTreeNodeCursor< T, B >::operator= ( T *  node)

assignment operator.

See comments on setCursor(T*) method.

Parameters
nodenode to which the cursor should be set
Returns
reference to modified cursor (this object)
template<typename T, OFBool B>
void DSRTreeNodeCursor< T, B >::setCursor ( const DSRTreeNodeCursor< T, B > &  cursor)
inlineprotected

set cursor to specified object

Parameters
cursorobject to set this cursor to

References DSRTreeNodeCursor< T, B >::NodeCursor, DSRTreeNodeCursor< T, B >::NodeCursorStack, and DSRTreeNodeCursor< T, B >::Position.

template<typename T, OFBool B>
size_t DSRTreeNodeCursor< T, B >::setCursor ( T *  node)
protected

set cursor to specified node.

Clears the internal position counter and sets the position of the current level to 1 (if the passed 'node' is valid) or 0 (if the 'node' is invalid).

Parameters
nodenode to which the cursor should be set
Returns
ID of the new current node if successful, 0 otherwise

The documentation for this class was generated from the following files:


Generated on Tue Feb 28 2017 for DCMTK Version 3.6.1 20170228 by Doxygen 1.8.8