Loading...
Searching...
No Matches
DSRTreeNodeCursor< T > Class Template Reference

Class implementing a tree node cursor. More...

## Public Member Functions

| DSRTreeNodeCursor ()
| default constructor
| DSRTreeNodeCursor (const DSRTreeNodeCursor< T > &cursor)
| copy constructor
| DSRTreeNodeCursor (T *node, const DSRPositionCounter *position=NULL)
| constructor.
virtual | ~DSRTreeNodeCursor ()
| destructor
DSRTreeNodeCursor< T > & | operator= (const DSRTreeNodeCursor< T > &cursor)
| assignment operator
DSRTreeNodeCursor< T > & | operator= (T *node)
| assignment operator.
virtual void | clear ()
| clear all member variables.
virtual OFBool | isValid () const
| check whether cursor currently points to a valid node
virtual size_t | countChildNodes (const OFBool searchIntoSub=OFTrue) const
| count number of children of the current node.
OFBool | hasParentNode () const
| check whether the current node has a parent
OFBool | hasChildNodes () const
| check whether the current node has any children
OFBool | hasPreviousNode () const
| check whether the current node has a preceding sibling
OFBool | hasNextNode () const
| check whether the current node has a following sibling
OFBool | hasSiblingNodes () const
| check whether the current node has any siblings
virtual T * | getNode () const
| get pointer to current node
virtual const T * | getParentNode () const
| get pointer to parent node.
virtual const T * | getChildNode () const
| get pointer to first child node.
virtual const T * | getPreviousNode () const
| get pointer to previous node.
virtual const T * | getNextNode () const
| get pointer to next node.
virtual size_t | gotoFirst ()
| goto first node on the same level (first sibling).
virtual size_t | gotoLast ()
| goto last node on the same level (last sibling).
virtual size_t | gotoPrevious ()
| goto previous node on the same level (preceding sibling)
virtual size_t | gotoNext ()
| goto next node on the same level (following sibling)
virtual size_t | goUp ()
| goto parent node (one level up)
virtual size_t | goDown ()
| goto first child node (one level down)
virtual size_t | gotoParent ()
| goto parent node (one level up)
virtual size_t | gotoChild ()
| goto first child node (one level down)
virtual size_t | iterate (const OFBool searchIntoSub=OFTrue)
| iterate over all nodes (starting from current position!)
size_t | gotoNode (const size_t searchID)
| set cursor to specified node.
size_t | gotoNode (const OFString &position, const char separator='.')
| set cursor to specified node.
size_t | gotoNode (const DSRTreeNodeAnnotation &annotation)
| set cursor to specified node.
size_t | gotoNode (const T &nodeValue)
| set cursor to specified node.
size_t | getNodeID () const
| get current node ID.
size_t | getLevel () const
| get current level.
DSRPositionCounter & | getPositionCounter ()
| get reference to internal position counter.
const OFString & | getPosition (OFString &position, const char separator='.') const
| get position string of the current node.

## Protected Member Functions

void | swap (DSRTreeNodeCursor< T > &cursor)
| fast, non-throwing swap function.
void | clearNodeCursorStack ()
| clear the internal node cursor stack
const DSRTreeNodeCursor< T > & | getCursor () const
| get cursor
void | setCursor (const DSRTreeNodeCursor< T > &cursor)
| set cursor to specified object
size_t | setCursor (T *node)
| set cursor to specified node.
T * | getChild () const
| get pointer to first child node

## 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>
class DSRTreeNodeCursor< T >

Class implementing a tree node cursor.

Template Parameters

  T | template type used for the tree node pointers

## Constructor & Destructor Documentation

## DSRTreeNodeCursor() [1/2]

template<typename T>

DSRTreeNodeCursor< T >::DSRTreeNodeCursor | ( | const DSRTreeNodeCursor< T > & | cursor | ) |

copy constructor

Parameters

  cursor | object to be copied

References DSRTreeNodeCursor(), NodeCursor, NodeCursorStack, and Position.

## DSRTreeNodeCursor() [2/2]

template<typename T>

DSRTreeNodeCursor< T >::DSRTreeNodeCursor | ( | T * | node,
|  | const DSRPositionCounter * | position = NULL )

constructor.

See comments on setCursor(T*) method.

Parameters

  node | pointer to tree node used to initialize the cursor
  position | optional pointer to position counter that should be used to initialize the internal counter

References DSRPositionCounter::getFlags(), DSRPositionCounter::isValid(), NodeCursor, NodeCursorStack, and Position.

## Member Function Documentation

## clear()

template<typename T>

void DSRTreeNodeCursor< T >::clear | ( |  | ) |

virtual

clear all member variables.

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

Reimplemented in DSRDocumentSubTree, DSRDocumentTree, DSRRootTemplate, DSRSubTemplate, DSRTree< T >, DSRTree< DSRDocumentTreeNode >, TID1411_VolumetricROIMeasurements< T_Measurement, T_Units, T_Method, T_Derivation >, TID1411_VolumetricROIMeasurements< CID218e_QuantitativeImageFeature, CID7181_AbstractMultiDimensionalImageModelComponentUnit, CID6147_ResponseCriteria, CID7464_GeneralRegionOfInterestMeasurementModifier >, TID1419_ROIMeasurements_Measurement< T_Measurement, T_Units, T_Method, T_Derivation >, TID1419_ROIMeasurements_Measurement< CID218e_QuantitativeImageFeature, CID7181_AbstractMultiDimensionalImageModelComponentUnit, CID6147_ResponseCriteria, CID7464_GeneralRegionOfInterestMeasurementModifier >, TID1500_MeasurementReport, TID1501_MeasurementGroup< T_Measurement, T_Units, T_Method, T_Derivation, T_Purpose >, TID1501_MeasurementGroup< CID218e_QuantitativeImageFeature, CID7181_AbstractMultiDimensionalImageModelComponentUnit, CID6147_ResponseCriteria, CID7464_GeneralRegionOfInterestMeasurementModifier, CID7551_GenericPurposeOfReferenceToImagesAndCoordinatesInMeasurement >, TID300_Measurement< T_Measurement, T_Units, T_Method, T_Derivation, T_Purpose >, and TID300_Measurement< CID218e_QuantitativeImageFeature, CID7181_AbstractMultiDimensionalImageModelComponentUnit, CID6147_ResponseCriteria, CID7464_GeneralRegionOfInterestMeasurementModifier, CID7551_GenericPurposeOfReferenceToImagesAndCoordinatesInMeasurement >.

References clearNodeCursorStack(), NodeCursor, and Position.

## countChildNodes()

template<typename T>

size_t DSRTreeNodeCursor< T >::countChildNodes | ( | const OFBool | searchIntoSub = OFTrue | ) | const

virtual

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

  searchIntoSub | flag 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

Reimplemented in DSRIncludedTemplateNodeCursor.

References DSRTreeNodeCursor(), isValid(), iterate(), and NodeCursor.

## getChild()

template<typename T>

T * DSRTreeNodeCursor< T >::getChild | ( |  | ) | const

protected

get pointer to first child node

Returns
  pointer to first child node (if any), NULL otherwise

References NodeCursor.

## getChildNode()

template<typename T>

const T * DSRTreeNodeCursor< T >::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

Reimplemented in DSRIncludedTemplateNodeCursor.

References NodeCursor.

Referenced by hasChildNodes().

## getCursor()

template<typename T>

const DSRTreeNodeCursor< T > & DSRTreeNodeCursor< T >::getCursor | ( |  | ) | const

inline protected

get cursor

Returns
  reference to cursor (this object)

References DSRTreeNodeCursor().

## getLevel()

template<typename T>

size_t DSRTreeNodeCursor< T >::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

References NodeCursor, and NodeCursorStack.

## getNextNode()

template<typename T>

const T * DSRTreeNodeCursor< T >::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

References NodeCursor.

Referenced by hasNextNode(), and hasSiblingNodes().

## getNode()

template<typename T>

T * DSRTreeNodeCursor< T >::getNode | ( |  | ) | const

virtual

get pointer to current node

Returns
  pointer to current node (might be NULL)

Reimplemented in DSRDocumentSubTree.

References NodeCursor.

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

## getNodeID()

template<typename T>

size_t DSRTreeNodeCursor< T >::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

References NodeCursor.

## getParentNode()

template<typename T>

const T * DSRTreeNodeCursor< T >::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

References hasParentNode(), and NodeCursorStack.

## getPosition()

template<typename T>

const OFString & DSRTreeNodeCursor< T >::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

  position | variable where the position string should be stored
  separator | character used to separate the figures (default: '.')

Returns
  reference to the resulting position string (empty if invalid)

References Position.

## getPositionCounter()

template<typename T>

DSRPositionCounter & DSRTreeNodeCursor< T >::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

References Position.

## getPreviousNode()

template<typename T>

const T * DSRTreeNodeCursor< T >::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

References NodeCursor.

Referenced by hasPreviousNode(), and hasSiblingNodes().

## goDown()

template<typename T>

size_t DSRTreeNodeCursor< T >::goDown | ( |  | ) |

virtual

goto first child node (one level down)

Returns
  ID of the first child node if successful, 0 otherwise

Reimplemented in DSRIncludedTemplateNodeCursor.

References NodeCursor, NodeCursorStack, and Position.

Referenced by gotoChild(), and gotoNode().

## gotoChild()

template<typename T>

size_t DSRTreeNodeCursor< T >::gotoChild | ( |  | ) |

virtual

goto first child node (one level down)

Returns
  ID of the first child node if successful, 0 otherwise

References goDown().

## gotoFirst()

template<typename T>

size_t DSRTreeNodeCursor< T >::gotoFirst | ( |  | ) |

virtual

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

References NodeCursor, and Position.

## gotoLast()

template<typename T>

size_t DSRTreeNodeCursor< T >::gotoLast | ( |  | ) |

virtual

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

References NodeCursor, and Position.

## gotoNext()

template<typename T>

size_t DSRTreeNodeCursor< T >::gotoNext | ( |  | ) |

virtual

goto next node on the same level (following sibling)

Returns
  ID of the next node if successful, 0 otherwise

References NodeCursor, and Position.

Referenced by gotoNode().

## gotoNode() [1/4]

template<typename T>

size_t DSRTreeNodeCursor< T >::gotoNode | ( | const DSRTreeNodeAnnotation & | annotation | ) |

set cursor to specified node.

Starts search from current position.

Parameters

  annotation | annotation of the node to set the cursor to

Returns
  ID of the new current node if successful, 0 otherwise

References DSRTreeNodeAnnotation::isEmpty(), iterate(), and NodeCursor.

## gotoNode() [2/4]

template<typename T>

size_t DSRTreeNodeCursor< T >::gotoNode | ( | const OFString & | position,
|  | const char | separator = '.' )

set cursor to specified node.

Starts search from current position.

Parameters

  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: '.')

Returns
  ID of the new current node if successful, 0 otherwise

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

## gotoNode() [3/4]

template<typename T>

size_t DSRTreeNodeCursor< T >::gotoNode | ( | const size_t | searchID | ) |

set cursor to specified node.

Starts search from current position.

Parameters

  searchID | ID of the node to set the cursor to

Returns
  ID of the new current node if successful, 0 otherwise

References iterate(), and NodeCursor.

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

## gotoNode() [4/4]

template<typename T>

size_t DSRTreeNodeCursor< T >::gotoNode | ( | const T & | nodeValue | ) |

set cursor to specified node.

Starts search from current position. This method requires that T implements the comparison operator "not equal".

Parameters

  nodeValue | value of the node to set the cursor to

Returns
  ID of the new current node if successful, 0 otherwise

References iterate(), and NodeCursor.

## gotoParent()

template<typename T>

size_t DSRTreeNodeCursor< T >::gotoParent | ( |  | ) |

virtual

goto parent node (one level up)

Returns
  ID of the parent node if successful, 0 otherwise

References goUp().

## gotoPrevious()

template<typename T>

size_t DSRTreeNodeCursor< T >::gotoPrevious | ( |  | ) |

virtual

goto previous node on the same level (preceding sibling)

Returns
  ID of the previous node if successful, 0 otherwise

References NodeCursor, and Position.

## goUp()

template<typename T>

size_t DSRTreeNodeCursor< T >::goUp | ( |  | ) |

virtual

goto parent node (one level up)

Returns
  ID of the parent node if successful, 0 otherwise

References NodeCursor, NodeCursorStack, and Position.

Referenced by gotoParent().

## hasChildNodes()

template<typename T>

OFBool DSRTreeNodeCursor< T >::hasChildNodes | ( |  | ) | const

inline

check whether the current node has any children

Returns
  OFTrue if the current node has any children, OFFalse otherwise

References getChildNode().

## hasNextNode()

template<typename T>

OFBool DSRTreeNodeCursor< T >::hasNextNode | ( |  | ) | const

inline

check whether the current node has a following sibling

Returns
  OFTrue if the current node has a following sibling, OFFalse otherwise

References getNextNode().

## hasParentNode()

template<typename T>

OFBool DSRTreeNodeCursor< T >::hasParentNode | ( |  | ) | const

inline

check whether the current node has a parent

Returns
  OFTrue if the current node has a parent, OFFalse otherwise

References NodeCursor, and NodeCursorStack.

Referenced by getParentNode().

## hasPreviousNode()

template<typename T>

OFBool DSRTreeNodeCursor< T >::hasPreviousNode | ( |  | ) | const

inline

check whether the current node has a preceding sibling

Returns
  OFTrue if the current node has a preceding sibling, OFFalse otherwise

References getPreviousNode().

## hasSiblingNodes()

template<typename T>

OFBool DSRTreeNodeCursor< T >::hasSiblingNodes | ( |  | ) | const

inline

check whether the current node has any siblings

Returns
  OFTrue if the current node has any siblings, OFFalse otherwise

References getNextNode(), and getPreviousNode().

## isValid()

template<typename T>

OFBool DSRTreeNodeCursor< T >::isValid | ( |  | ) | const

virtual

check whether cursor currently points to a valid node

Returns
  OFTrue if valid, OFFalse otherwise

Reimplemented in DSRDocumentSubTree, DSRDocumentTree, DSRRootTemplate, DSRSubTemplate, TID1411_VolumetricROIMeasurements< T_Measurement, T_Units, T_Method, T_Derivation >, TID1411_VolumetricROIMeasurements< CID218e_QuantitativeImageFeature, CID7181_AbstractMultiDimensionalImageModelComponentUnit, CID6147_ResponseCriteria, CID7464_GeneralRegionOfInterestMeasurementModifier >, TID1419_ROIMeasurements_Measurement< T_Measurement, T_Units, T_Method, T_Derivation >, TID1419_ROIMeasurements_Measurement< CID218e_QuantitativeImageFeature, CID7181_AbstractMultiDimensionalImageModelComponentUnit, CID6147_ResponseCriteria, CID7464_GeneralRegionOfInterestMeasurementModifier >, TID1500_MeasurementReport, TID1501_MeasurementGroup< T_Measurement, T_Units, T_Method, T_Derivation, T_Purpose >, TID1501_MeasurementGroup< CID218e_QuantitativeImageFeature, CID7181_AbstractMultiDimensionalImageModelComponentUnit, CID6147_ResponseCriteria, CID7464_GeneralRegionOfInterestMeasurementModifier, CID7551_GenericPurposeOfReferenceToImagesAndCoordinatesInMeasurement >, TID1600_ImageLibrary, TID300_Measurement< T_Measurement, T_Units, T_Method, T_Derivation, T_Purpose >, and TID300_Measurement< CID218e_QuantitativeImageFeature, CID7181_AbstractMultiDimensionalImageModelComponentUnit, CID6147_ResponseCriteria, CID7464_GeneralRegionOfInterestMeasurementModifier, CID7551_GenericPurposeOfReferenceToImagesAndCoordinatesInMeasurement >.

References NodeCursor.

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

## iterate()

template<typename T>

size_t DSRTreeNodeCursor< T >::iterate | ( | const OFBool | searchIntoSub = OFTrue | ) |

virtual

iterate over all nodes (starting from current position!)

Parameters

  searchIntoSub | flag 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

Reimplemented in DSRIncludedTemplateNodeCursor.

References NodeCursor, NodeCursorStack, and Position.

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

## operator=() [1/2]

template<typename T>

DSRTreeNodeCursor< T > & DSRTreeNodeCursor< T >::operator= | ( | const DSRTreeNodeCursor< T > & | cursor | ) |

assignment operator

Parameters

  cursor | object to be copied

Returns
  reference to modified cursor (this object)

References DSRTreeNodeCursor(), and setCursor().

## operator=() [2/2]

template<typename T>

DSRTreeNodeCursor< T > & DSRTreeNodeCursor< T >::operator= | ( | T * | node | ) |

assignment operator.

See comments on setCursor(T*) method.

Parameters

  node | node to which the cursor should be set

Returns
  reference to modified cursor (this object)

References DSRTreeNodeCursor(), and setCursor().

## setCursor() [1/2]

template<typename T>

void DSRTreeNodeCursor< T >::setCursor | ( | const DSRTreeNodeCursor< T > & | cursor | ) |

inline protected

set cursor to specified object

Parameters

  cursor | object to set this cursor to

References DSRTreeNodeCursor(), NodeCursor, NodeCursorStack, and Position.

Referenced by operator=(), and operator=().

## setCursor() [2/2]

template<typename T>

size_t DSRTreeNodeCursor< T >::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

  node | node to which the cursor should be set

Returns
  ID of the new current node if successful, 0 otherwise

References clearNodeCursorStack(), NodeCursor, and Position.

## swap()

template<typename T>

void DSRTreeNodeCursor< T >::swap | ( | DSRTreeNodeCursor< T > & | cursor | ) |

protected

fast, non-throwing swap function.

The time complexity of this function is constant.

Parameters

  cursor | cursor to swap with

References DSRTreeNodeCursor(), NodeCursor, NodeCursorStack, OFswap(), and Position.

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

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

- dcmsr/include/dcmtk/dcmsr/dsrtncsr.h

Generated on for DCMTK Version 3.7.0 by Doxygen 1.15.0