1 /* 2 * 3 * Copyright (C) 2015-2017, J. Riesmeier, Oldenburg, Germany 4 * All rights reserved. See COPYRIGHT file for details. 5 * 6 * This software and supporting documentation are maintained by 7 * 8 * OFFIS e.V. 9 * R&D Division Health 10 * Escherweg 2 11 * D-26121 Oldenburg, Germany 12 * 13 * 14 * Module: dcmsr 15 * 16 * Author: Joerg Riesmeier 17 * 18 * Purpose: 19 * classes: DSRRootTemplate 20 * 21 */ 22 23 24 #ifndef DSRRTPL_H 25 #define DSRRTPL_H 26 27 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 28 29 #include "dcmtk/dcmsr/dsrdoctr.h" 30 #include "dcmtk/dcmsr/dsrctpl.h" 31 32 33 /*-----------------------* 34 * forward declaration * 35 *-----------------------*/ 36 37 class DSRSubTemplate; 38 39 40 /*---------------------* 41 * class declaration * 42 *---------------------*/ 43 44 /** Class managing an SR document tree that is based on an SR root template. 45 * This class provides a more template-specific API than the general document tree class 46 * and should be used for root templates only. 47 ** @note The main focus of this class currently lies in the creation of SR documents that 48 * are based on an SR root template. Support for reading SR documents into the 49 * underlying structures might be added in the future. 50 */ 51 class DCMTK_DCMSR_EXPORT DSRRootTemplate 52 : protected DSRDocumentTree, 53 public DSRTemplateCommon 54 { 55 56 public: 57 58 /** constructor 59 ** @param documentType document type of the associated document 60 * @param templateIdentifier identifier of the template 61 * @param mappingResource mapping resource that defines the template 62 * @param mappingResourceUID uniquely identifies the mapping resource (optional) 63 */ 64 DSRRootTemplate(const E_DocumentType documentType, 65 const OFString &templateIdentifier, 66 const OFString &mappingResource, 67 const OFString &mappingResourceUID = ""); 68 69 /** copy constructor. 70 * Also see notes on DSRDocumentTree's copy constructor. 71 ** @param rootTemplate template to be copied 72 */ 73 DSRRootTemplate(const DSRRootTemplate &rootTemplate); 74 75 /** destructor 76 */ 77 virtual ~DSRRootTemplate(); 78 79 /** clone this template. 80 * Internally, the copy constructor is used, so the corresponding comments apply. 81 ** @return copy of this template 82 */ 83 virtual DSRRootTemplate *clone() const; 84 85 /** clone the internally stored document tree of this template. 86 * Internally, the copy constructor of DSRDocumentTree is used, so the corresponding 87 * comments apply. In addition, the template identification is set for the root node 88 * of the cloned tree (if applicable). 89 ** @return copy of the internally stored document tree 90 */ 91 virtual DSRDocumentTree *cloneTree() const; 92 93 /** clear internal member variables. 94 * Also see notes on the clear() method of the base classes. 95 */ 96 virtual void clear(); 97 98 /** check whether the current internal state is valid. 99 * That means, whether both the internally stored document tree and the template 100 * identification are valid. 101 ** @return OFTrue if valid, OFFalse otherwise 102 */ 103 virtual OFBool isValid() const; 104 105 /** check whether this template is a root template, i.e.\ describes a complete SR 106 * document tree starting from the root node 107 ** @return always returns OFTrue since this class handles root templates 108 */ isRootTemplate()109 inline OFBool isRootTemplate() const 110 { 111 return OFTrue; 112 } 113 114 /** get read-only access to internally stored document tree. 115 * This method is not "const" because the template identification is set/updated 116 * automatically for the root node of the document tree (if applicable). 117 ** @return constant reference to internally stored document tree 118 */ 119 virtual const DSRDocumentTree &getTree(); 120 121 /** add extra content item to the current one (if the template is extensible). 122 * See DSRDocumentTree::addContentItem() for details. 123 ** @param relationshipType relationship type of node to be added with regard to 124 * the current one 125 * @param valueType value type of node to be added 126 * @param addMode flag specifying at which position to add the new node 127 * (e.g. after or below the current node) 128 ** @return status, EC_Normal if successful, an error code otherwise 129 */ 130 virtual OFCondition addExtraContentItem(const E_RelationshipType relationshipType, 131 const E_ValueType valueType, 132 const E_AddMode addMode = AM_afterCurrent); 133 134 /** insert tree from given extra template to internally stored document tree. 135 * If possible, this method adds a copy of the given tree to the current content item. 136 * However, in case this template is non-extensible, an error code will be returned. 137 ** @param subTemplate template that contains the tree that should be inserted 138 * @param addMode flag specifying at which position to add the new subtree 139 * (e.g. after or below the current node) 140 * @param defaultRelType default relationship type between the top-level nodes of 141 * the given subtree and the current node. This relationship 142 * type is used if the one of a top-level node is "unknown". 143 ** @return status, EC_Normal if successful, an error code otherwise 144 */ 145 virtual OFCondition insertExtraTemplate(const DSRSubTemplate &subTemplate, 146 const E_AddMode addMode = AM_belowCurrent, 147 const E_RelationshipType defaultRelType = RT_unknown); 148 149 150 // --- introduce some methods from base class to public API 151 152 using DSRDocumentTree::isEmpty; 153 using DSRDocumentTree::isCursorValid; 154 using DSRDocumentTree::getDocumentType; 155 using DSRDocumentTree::print; 156 using DSRDocumentTree::writeXML; 157 using DSRDocumentTree::countNodes; 158 using DSRDocumentTree::countChildNodes; 159 using DSRDocumentTree::hasParentNode; 160 using DSRDocumentTree::hasChildNodes; 161 using DSRDocumentTree::hasPreviousNode; 162 using DSRDocumentTree::hasNextNode; 163 using DSRDocumentTree::hasSiblingNodes; 164 using DSRDocumentTree::iterate; 165 using DSRDocumentTree::gotoRoot; 166 using DSRDocumentTree::gotoFirst; 167 using DSRDocumentTree::gotoLast; 168 using DSRDocumentTree::gotoPrevious; 169 using DSRDocumentTree::gotoNext; 170 using DSRDocumentTree::gotoParent; 171 using DSRDocumentTree::gotoChild; 172 using DSRDocumentTree::gotoNamedNode; 173 using DSRDocumentTree::gotoNextNamedNode; 174 using DSRDocumentTree::gotoAnnotatedNode; 175 using DSRDocumentTree::gotoNextAnnotatedNode; 176 using DSRDocumentTree::getCurrentContentItem; 177 using DSRDocumentTree::updateByReferenceRelationships; 178 179 180 protected: 181 182 /** read SR document tree from DICOM dataset 183 ** @param dataset dummy parameter 184 * @param documentType dummy parameter 185 * @param flags dummy parameter 186 ** @return always returns EC_IllegalCall since this method is not yet implemented and 187 * should, therefore, never be called for this class 188 */ 189 virtual OFCondition read(DcmItem &dataset, 190 const E_DocumentType documentType, 191 const size_t flags = 0); 192 193 /** read XML document tree 194 ** @param doc dummy parameter 195 * @param cursor dummy parameter 196 * @param flags dummy parameter 197 ** @return always returns EC_IllegalCall since this method is not yet implemented and 198 * should, therefore, never be called for this class 199 */ 200 virtual OFCondition readXML(const DSRXMLDocument &doc, 201 DSRXMLCursor cursor, 202 const size_t flags); 203 204 /** update the tree for subsequent output, e.g.\ for being printed or added to an SR 205 * document. This function is called automatically by the affected output methods. 206 */ 207 virtual void updateTreeForOutput(); 208 209 210 private: 211 212 // --- declaration of default constructor and assignment operator 213 214 DSRRootTemplate(); 215 DSRRootTemplate &operator=(const DSRRootTemplate &); 216 }; 217 218 219 #endif 220