DCMTK  Version 3.6.6
OFFIS DICOM Toolkit
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
DSRDocumentTree Class Reference

Class managing the SR document tree. More...

+ Inheritance diagram for DSRDocumentTree:

Public Member Functions

 DSRDocumentTree (const E_DocumentType documentType)
 constructor More...
 
 DSRDocumentTree (const DSRDocumentTree &tree)
 copy constructor. More...
 
virtual ~DSRDocumentTree ()
 destructor
 
DSRDocumentTreeoperator= (DSRDocumentTree tree)
 assignment operator. More...
 
virtual DSRDocumentTreeclone () const
 clone this tree. More...
 
virtual void clear ()
 clear internal member variables. More...
 
virtual OFBool isValid () const
 check whether the current internal state is valid. More...
 
virtual OFCondition print (STD_NAMESPACE ostream &stream, const size_t flags=0)
 print current SR document tree to specified output stream More...
 
virtual OFCondition read (DcmItem &dataset, const E_DocumentType documentType, const size_t flags=0)
 read SR document tree from DICOM dataset. More...
 
virtual OFCondition write (DcmItem &dataset, DcmStack *markedItems=NULL)
 write current SR document tree to DICOM dataset. More...
 
virtual OFCondition readXML (const DSRXMLDocument &doc, DSRXMLCursor cursor, const size_t flags)
 read XML document tree More...
 
virtual OFCondition renderHTML (STD_NAMESPACE ostream &docStream, STD_NAMESPACE ostream &annexStream, const size_t flags=0)
 render current SR document tree in HTML/XHTML format. More...
 
E_DocumentType getDocumentType () const
 get document type More...
 
virtual OFCondition changeDocumentType (const E_DocumentType documentType, const OFBool deleteTree)
 change document type. More...
 
virtual OFBool canAddContentItem (const E_RelationshipType relationshipType, const E_ValueType valueType, const E_AddMode addMode=AM_afterCurrent) const
 check whether specified content item can be added to the current one. More...
 
virtual OFBool canInsertSubTree (const DSRDocumentSubTree *tree, const E_AddMode addMode=AM_belowCurrent, const E_RelationshipType defaultRelType=RT_unknown) const
 check whether specified subtree can be inserted at the current position, i.e. added to the current content item. More...
 
virtual OFCondition checkDocumentTreeConstraints (DSRIODConstraintChecker *checker)
 check whether the document tree complies with the constraints of the given checker. More...
 
void unmarkAllContentItems ()
 unmark all content items in the document tree. More...
 
void removeSignatures ()
 remove digital signatures from the document tree. More...
 
- Public Member Functions inherited from DSRDocumentSubTree
 DSRDocumentSubTree ()
 default constructor
 
 DSRDocumentSubTree (const DSRDocumentSubTree &tree)
 copy constructor. More...
 
virtual ~DSRDocumentSubTree ()
 destructor
 
DSRDocumentSubTreeoperator= (DSRDocumentSubTree tree)
 assignment operator. More...
 
virtual OFBool isCursorValid () const
 check whether the internal cursor, which points to the current content item, is valid More...
 
virtual OFBool isValidDocumentTree (const E_RelationshipType defaultRelType=RT_unknown) const
 check whether this subtree is a valid document tree. More...
 
virtual OFBool isExpandedDocumentTree () const
 check whether this subtree is an expanded document tree. More...
 
virtual OFBool hasTemplateIdentification () const
 check whether template identification is set More...
 
virtual OFBool canUseTemplateIdentification () const
 check whether template identification is possible at all. More...
 
virtual OFCondition writeXML (STD_NAMESPACE ostream &stream, const size_t flags=0)
 write current SR document tree in XML format More...
 
virtual DSRContentItemgetCurrentContentItem ()
 get reference to current content item. More...
 
virtual const DSRDocumentTreeNodegetCurrentNode () const
 get read-only access to current node (content item) More...
 
virtual OFBool getCursorToRootNode (DSRDocumentTreeNodeCursor &cursor) const
 get a cursor to the root node of this document tree. More...
 
virtual OFBool getCursorToRootNode (DSRIncludedTemplateNodeCursor &cursor) const
 get a cursor to the root node of this document tree. More...
 
virtual OFBool getCursorToCurrentNode (DSRDocumentTreeNodeCursor &cursor) const
 get a cursor to the current node of this document tree. More...
 
virtual OFBool getCursorToSubTree (DSRDocumentTreeNodeCursor &cursor) const
 get a cursor to the subtree below the current node. More...
 
size_t countNodes (const OFBool searchIntoSubTemplates=OFFalse, const OFBool countIncludedTemplateNodes=OFTrue) const
 count number of content items (nodes) in the document tree. More...
 
virtual size_t gotoMatchingNode (const DSRDocumentTreeNodeFilter &filter, const OFBool startFromRoot=OFTrue, const OFBool searchIntoSub=OFTrue)
 set internal cursor to a matching node. More...
 
virtual size_t gotoNextMatchingNode (const DSRDocumentTreeNodeFilter &filter, const OFBool searchIntoSub=OFTrue)
 set internal cursor to the next matching node. More...
 
virtual size_t gotoNamedNode (const DSRCodedEntryValue &conceptName, const OFBool startFromRoot=OFTrue, const OFBool searchIntoSub=OFTrue)
 set internal cursor to a named node. More...
 
virtual size_t gotoNamedChildNode (const DSRCodedEntryValue &conceptName)
 set internal cursor to a named node (starting from the first child of the current node and searching on this level only). More...
 
virtual size_t gotoNamedNodeInSubTree (const DSRCodedEntryValue &conceptName, const OFBool searchIntoSub=OFTrue)
 set internal cursor to a named node in the subtree below the current node. More...
 
virtual size_t gotoNextNamedNode (const DSRCodedEntryValue &conceptName, const OFBool searchIntoSub=OFTrue)
 set internal cursor to the next named node. More...
 
virtual size_t gotoAnnotatedNode (const OFString &annotationText, const OFBool startFromRoot=OFTrue)
 set internal cursor to an annotated node. More...
 
virtual size_t gotoNextAnnotatedNode (const OFString &annotationText)
 set internal cursor to the next annotated node. More...
 
virtual OFBool canAddByReferenceRelationship (const E_RelationshipType relationshipType, const E_ValueType targetValueType) const
 check whether specified by-reference relationship can be added to the current content item. More...
 
virtual size_t addContentItem (const E_RelationshipType relationshipType, const E_ValueType valueType, const E_AddMode addMode=AM_afterCurrent)
 add specified content item to the current one. More...
 
virtual OFCondition addContentItem (DSRDocumentTreeNode *node, const E_AddMode addMode=AM_afterCurrent, const OFBool deleteIfFail=OFFalse)
 add specified content item to the current one. More...
 
virtual OFCondition addContentItem (const E_RelationshipType relationshipType, const E_ValueType valueType, const DSRCodedEntryValue &conceptName, const OFBool check=OFTrue)
 add specified content item after the current one. More...
 
virtual OFCondition addChildContentItem (const E_RelationshipType relationshipType, const E_ValueType valueType, const DSRCodedEntryValue &conceptName, const OFBool check=OFTrue)
 add specified content item below the current one. More...
 
virtual size_t addByReferenceRelationship (const E_RelationshipType relationshipType, const size_t referencedNodeID)
 add specified by-reference relationship to the current content item. More...
 
virtual OFCondition updateByReferenceRelationships (const OFBool updateIncludedTemplates=OFFalse)
 update the position strings used to encode by-reference relationships (if any). More...
 
virtual OFCondition insertSubTree (DSRDocumentSubTree *tree, const E_AddMode addMode=AM_belowCurrent, const E_RelationshipType defaultRelType=RT_unknown, const OFBool deleteIfFail=OFFalse)
 insert specified subtree to this tree, i.e. add it to the current content item. More...
 
virtual DSRDocumentSubTreeextractSubTree ()
 extract a subtree, i.e. a fragment from this tree. More...
 
virtual size_t removeCurrentContentItem ()
 remove current content item from tree. More...
 
virtual OFCondition removeSubTree (const size_t searchID=0)
 remove a subtree from this tree. More...
 
virtual DSRDocumentTreeNodecloneCurrentTreeNode () const
 clone the current tree node. More...
 
virtual DSRDocumentSubTreecloneSubTree (const size_t stopAfterNodeID=0) const
 clone a subtree, i.e. a fragment of this tree. More...
 
virtual OFCondition createExpandedSubTree (DSRDocumentSubTree *&tree) const
 created an expanded version of this (sub)tree. More...
 
virtual OFCondition setObservationDateTime (const OFString &observationDateTime, const OFBool check=OFTrue)
 set observation date/time for all content items in the document tree. More...
 
virtual OFBool compareTemplateIdentification (const OFString &templateIdentifier, const OFString &mappingResource, const OFString &mappingResourceUID="") const
 compare template identification of the root node with given values. More...
 
virtual OFCondition getTemplateIdentification (OFString &templateIdentifier, OFString &mappingResource) const
 get template identifier and mapping resource from the root node of this tree. More...
 
virtual OFCondition getTemplateIdentification (OFString &templateIdentifier, OFString &mappingResource, OFString &mappingResourceUID) const
 get template identifier, mapping resource and optional mapping resource UID from the root node of this tree. More...
 
virtual OFCondition setTemplateIdentification (const OFString &templateIdentifier, const OFString &mappingResource, const OFString &mappingResourceUID="", const OFBool check=OFTrue)
 set template identifier and mapping resource to the root node of this tree. More...
 
- Public Member Functions inherited from DSRTree< DSRDocumentTreeNode >
 DSRTree ()
 default constructor
 
 DSRTree (const DSRTree< DSRDocumentTreeNode > &tree)
 copy constructor. More...
 
virtual ~DSRTree ()
 destructor
 
DSRTreeoperator= (DSRTree< DSRDocumentTreeNode > tree)
 assignment operator. More...
 
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 DSRDocumentTreeNode &nodeValue, const OFBool startFromRoot=OFTrue)
 set internal cursor to specified node (given by its value). More...
 

Protected Member Functions

void swap (DSRDocumentTree &tree)
 fast, non-throwing swap function. More...
 
virtual OFCondition print (STD_NAMESPACE ostream &stream, const size_t flags, const DSRPositionCounter *posCounter)
 print current SR document tree to specified output stream. More...
 
- Protected Member Functions inherited from DSRDocumentSubTree
 DSRDocumentSubTree (DSRDocumentTreeNode *rootNode)
 special constructor that receives a pointer to the root node. More...
 
 DSRDocumentSubTree (const DSRDocumentTreeNodeCursor &startCursor, size_t stopAfterNodeID)
 special copy constructor that clones a particular subtree only More...
 
void swap (DSRDocumentSubTree &tree)
 fast, non-throwing swap function. More...
 
virtual DSRDocumentTreeNodegetNode () const
 get pointer to current node. More...
 
virtual size_t addNode (DSRDocumentTreeNode *node, const E_AddMode addMode=AM_afterCurrent)
 add new node to the current one. More...
 
virtual size_t replaceNode (DSRDocumentTreeNode *node)
 replace current node by the given one. More...
 
virtual DSRDocumentTreeNodeextractNode ()
 extract current node from tree. More...
 
virtual DSRDocumentTreeNodegetAndRemoveRootNode ()
 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 OFCondition includeTemplate (const DSRSharedSubTemplate &subTemplate, const E_AddMode addMode=AM_belowCurrent, const E_RelationshipType defaultRelType=RT_unknown)
 include specified sub-template, i.e. add a new DSRIncludedTemplateTreeNode, which references this template, to the current content item. More...
 
virtual OFCondition expandIncludedTemplates (DSRDocumentSubTree *tree) const
 expand all "included template" content items in a given (sub)tree. More...
 
template<typename T_Cursor >
OFCondition checkByReferenceRelationships (const size_t mode=0, const size_t flags=0)
 check the by-reference relationships (if any) for validity. More...
 
virtual void resetReferenceTargetFlag ()
 reset flag for all content items whether they are target of a by-reference relationship. More...
 
virtual void updateTreeForOutput ()
 update the tree for subsequent output, e.g. for being printed or added to an SR document. More...
 
virtual OFCondition checkSubTreeConstraints (const DSRDocumentSubTree *tree, const DSRIODConstraintChecker *checker) const
 check whether the given subtree complies with the constraints of the given checker More...
 
virtual OFBool validByReferenceRelationship (const OFString &sourcePosition, const OFString &targetPosition)
 check whether a by-reference relationship from a given source to a target node (specified by the position strings) is valid, i.e. is allowed according to the DICOM standard. More...
 
- Protected Member Functions inherited from DSRTree< DSRDocumentTreeNode >
 DSRTree (DSRDocumentTreeNode *rootNode)
 special constructor that receives a pointer to the root node. More...
 
 DSRTree (const DSRTreeNodeCursor< DSRDocumentTreeNode > &startCursor, size_t stopAfterNodeID)
 special copy constructor that clones a particular subtree only More...
 
void swap (DSRTree< DSRDocumentTreeNode > &tree)
 fast, non-throwing swap function. More...
 
virtual DSRDocumentTreeNodegetRoot () const
 get pointer to root node More...
 
virtual void deleteTreeFromRootNode (DSRDocumentTreeNode *rootNode)
 delete a tree given by its root node. More...
 

Private Attributes

E_DocumentType DocumentType
 document type of the associated SR document
 

Additional Inherited Members

- Static Protected Member Functions inherited from DSRDocumentSubTree
static DSRDocumentSubTreecloneSubTree (const DSRDocumentTreeNodeCursor &startCursor, const size_t stopAfterNodeID=0)
 clone a particular subtree, i.e. a fragment of a tree More...
 
- Protected Attributes inherited from DSRDocumentSubTree
DSRIODConstraintCheckerConstraintChecker
 check relationship content constraints of the associated IOD
 

Detailed Description

Class managing the SR document tree.

This tree structure consists of content items (nodes) that are related to each other. It is called "SR Document Content Tree" in the DICOM standard. There is always a single node at the root, which has the value type CONTAINER. Depending on the document type, certain restrictions apply on which value and relationship types are allowed. The rules are specified and checked by a so-called IOD constraint checker.

Constructor & Destructor Documentation

◆ DSRDocumentTree() [1/2]

DSRDocumentTree::DSRDocumentTree ( const E_DocumentType  documentType)

constructor

Parameters
documentTypedocument type of the associated document

◆ DSRDocumentTree() [2/2]

DSRDocumentTree::DSRDocumentTree ( const DSRDocumentTree tree)

copy constructor.

Please note that the internal cursor is not copied but reset, i.e. set to the root node.

Parameters
treetree to be copied

Member Function Documentation

◆ canAddContentItem()

virtual OFBool DSRDocumentTree::canAddContentItem ( const E_RelationshipType  relationshipType,
const E_ValueType  valueType,
const E_AddMode  addMode = AM_afterCurrent 
) const
virtual

check whether specified content item can be added to the current one.

This method can be used to decide which type of content items can be added prior to really doing so. If the tree is currently empty, only a CONTAINER with the internal relationship type DSRTypes::RT_isRoot is allowed (as the new root node). Always returns true if no constraint checker is available but 'relationshipType' and 'valueType' have valid values.

Parameters
relationshipTyperelationship type of node to be checked with regard to the current one
valueTypevalue type of node to be checked
addModeflag specifying at which position the new node would be added (e.g. after or below the current node)
Returns
OFTrue if specified node can be added, OFFalse otherwise

Reimplemented from DSRDocumentSubTree.

◆ canInsertSubTree()

virtual OFBool DSRDocumentTree::canInsertSubTree ( const DSRDocumentSubTree tree,
const E_AddMode  addMode = AM_belowCurrent,
const E_RelationshipType  defaultRelType = RT_unknown 
) const
virtual

check whether specified subtree can be inserted at the current position, i.e. added to the current content item.

If this tree is currently empty, only a CONTAINER with the internal relationship type DSRTypes::RT_isRoot is allowed as the new root node (of the given subtree). In all other cases, the method DSRDocumentSubTree::canInsertSubTree() is called.

Parameters
treepointer to new subtree to be inserted (should not be empty)
addModeflag specifying at which position the new subtree would be added (e.g. after or below the current node)
defaultRelTypedefault relationship type between the top-level nodes of the given subtree and the current node. This relationship type is used if the one of a top-level node is "unknown".
Returns
OFTrue if specified subtree can be inserted, OFFalse otherwise

Reimplemented from DSRDocumentSubTree.

◆ changeDocumentType()

virtual OFCondition DSRDocumentTree::changeDocumentType ( const E_DocumentType  documentType,
const OFBool  deleteTree 
)
virtual

change document type.

First, it is checked whether the specified 'documentType' is supported at all. If so, the currently stored document tree is either deleted (see 'deleteTree' parameter) or it is checked whether the tree also complies with the relationship content constraints of the new SR IOD. Otherwise the current document remains in force. Please note that the 'documentType' is not compared with the type of the currently stored document tree, i.e. the above described process is always performed, even if the document type does not change.

Parameters
documentTypenew document type to be set (should not be DSRTypes::DT_invalid)
deleteTreedelete the currently stored document tree if OFTrue. Otherwise, it is checked whether the tree can be preserved.
Returns
status, EC_Normal if successful, an error code otherwise

◆ checkDocumentTreeConstraints()

virtual OFCondition DSRDocumentTree::checkDocumentTreeConstraints ( DSRIODConstraintChecker checker)
virtual

check whether the document tree complies with the constraints of the given checker.

This method also checks whether the currently stored document tree is either empty or valid, and whether the template identification of the root node (if any) is as expected. However, the latter only results in a warning message to the logger.

Parameters
checkerpointer to relationship content constraints checker to be used
Returns
status, EC_Normal if successful, an error code otherwise

◆ clear()

virtual void DSRDocumentTree::clear ( )
virtual

clear internal member variables.

The document type is not changed (e.g. set to DSRTypes::DT_invalid).

Reimplemented from DSRDocumentSubTree.

Reimplemented in TID1500_MeasurementReport, and DSRRootTemplate.

◆ clone()

virtual DSRDocumentTree* DSRDocumentTree::clone ( ) const
virtual

clone this tree.

Internally, the copy constructor is used, so the corresponding comments apply.

Returns
copy of this tree

Reimplemented from DSRDocumentSubTree.

Reimplemented in DSRRootTemplate.

◆ getDocumentType()

E_DocumentType DSRDocumentTree::getDocumentType ( ) const
inline

get document type

Returns
current document type (might be DSRTypes::DT_invalid)

◆ isValid()

virtual OFBool DSRDocumentTree::isValid ( ) const
virtual

check whether the current internal state is valid.

The SR document tree is valid if the document type is supported, the tree is not empty, the root item is a container and has the internal relationship type DSRTypes::RT_isRoot. Also see DSRDocumentSubTree::isValidDocumentTree().

Returns
OFTrue if valid, OFFalse otherwise

Reimplemented from DSRDocumentSubTree.

Reimplemented in TID1500_MeasurementReport, and DSRRootTemplate.

◆ operator=()

DSRDocumentTree& DSRDocumentTree::operator= ( DSRDocumentTree  tree)

assignment operator.

Please note that internally the copy constructor is used, so the same comments apply.

Parameters
treetree to be copied
Returns
reference to this tree after copying

◆ print() [1/2]

virtual OFCondition DSRDocumentTree::print ( STD_NAMESPACE ostream &  stream,
const size_t  flags,
const DSRPositionCounter posCounter 
)
protectedvirtual

print current SR document tree to specified output stream.

This method is only needed to avoid compiler warnings regarding an "overloaded virtual function" hiding DSRDocumentSubTree::print() from the base class, which has different parameters than the public print() method of this class.

Parameters
streamoutput stream
flagsflag used to customize the output (see DSRTypes::PF_xxx)
posCounterpointer to position counter that should be used to initialize the counter for line indentation or numbering of nested content items
Returns
status, EC_Normal if successful, an error code otherwise

Reimplemented from DSRDocumentSubTree.

◆ print() [2/2]

virtual OFCondition DSRDocumentTree::print ( STD_NAMESPACE ostream &  stream,
const size_t  flags = 0 
)
virtual

print current SR document tree to specified output stream

Parameters
streamoutput stream
flagsoptional flag used to customize the output (see DSRTypes::PF_xxx)
Returns
status, EC_Normal if successful, an error code otherwise

◆ read()

virtual OFCondition DSRDocumentTree::read ( DcmItem dataset,
const E_DocumentType  documentType,
const size_t  flags = 0 
)
virtual

read SR document tree from DICOM dataset.

Please note that the current document tree is also deleted if the reading fails. If logging is enabled, the reason for any error might be obtained from the error/warning output.

Parameters
datasetreference to DICOM dataset where the tree should be read from
documentTypedocument type of the SR document from which the tree is read
flagsflag used to customize the reading process (see DSRTypes::RF_xxx)
Returns
status, EC_Normal if successful, an error code otherwise

Reimplemented in DSRRootTemplate.

◆ readXML()

virtual OFCondition DSRDocumentTree::readXML ( const DSRXMLDocument doc,
DSRXMLCursor  cursor,
const size_t  flags 
)
virtual

read XML document tree

Parameters
docdocument containing the XML file content
cursorcursor pointing to the starting node
flagsflag used to customize the reading process (see DSRTypes::XF_xxx)
Returns
status, EC_Normal if successful, an error code otherwise

Reimplemented in DSRRootTemplate.

◆ removeSignatures()

void DSRDocumentTree::removeSignatures ( )

remove digital signatures from the document tree.

This method clears the MACParametersSequence and the DigitalSignaturesSequence for all content items which have been filled during reading.

◆ renderHTML()

virtual OFCondition DSRDocumentTree::renderHTML ( STD_NAMESPACE ostream &  docStream,
STD_NAMESPACE ostream &  annexStream,
const size_t  flags = 0 
)
virtual

render current SR document tree in HTML/XHTML format.

Please note that included (non-expanded) sub-templates are not supported.

Parameters
docStreamoutput stream to which the main HTML/XHTML document is written
annexStreamoutput stream to which the HTML/XHTML document annex is written
flagsoptional flag used to customize the output (see DSRTypes::HF_xxx)
Returns
status, EC_Normal if successful, an error code otherwise

◆ swap()

void DSRDocumentTree::swap ( DSRDocumentTree tree)
protected

fast, non-throwing swap function.

The time complexity of this function is constant.

Parameters
treetree to swap with

◆ unmarkAllContentItems()

void DSRDocumentTree::unmarkAllContentItems ( )

unmark all content items in the document tree.

Use method DSRDocumentTreeNode::setMark() to mark and unmark a single content item. Pointers to the DICOM dataset/item of marked content items are added to the optional stack when calling the DSRDocument::write() method. This mechanism can e.g. be used to digitally sign particular content items.

◆ write()

virtual OFCondition DSRDocumentTree::write ( DcmItem dataset,
DcmStack markedItems = NULL 
)
virtual

write current SR document tree to DICOM dataset.

Please note that included (non-expanded) sub-templates are not supported.

Parameters
datasetreference to DICOM dataset where the current tree should be written to. The 'dataset' is not cleared before writing to it!
markedItemsoptional stack where pointers to all 'marked' content items (DICOM datasets/items) are added to during the write process. Can be used to digitally sign parts of the document tree.
Returns
status, EC_Normal if successful, an error code otherwise

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


Generated on Thu Jan 14 2021 for DCMTK Version 3.6.6 by Doxygen 1.8.18