1 /* 2 * 3 * Copyright (c) 2008-2012, OFFIS e.V. and ICSMED AG, Oldenburg, Germany 4 * Copyright (C) 2013-2016, J. Riesmeier, Oldenburg, Germany 5 * All rights reserved. See COPYRIGHT file for details. 6 * 7 * Header file for class DRTTypes 8 * 9 * Generated manually based on dsrtypes.h 10 * File created on 2008-12-05 11 * Last modified on 2016-02-12 by Riesmeier 12 * 13 */ 14 15 16 #ifndef DRTTYPES_H 17 #define DRTTYPES_H 18 19 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 20 21 #include "dcmtk/ofstd/oftypes.h" 22 #include "dcmtk/ofstd/ofcond.h" 23 #include "dcmtk/ofstd/ofvector.h" 24 #include "dcmtk/oflog/oflog.h" 25 26 #include "dcmtk/dcmdata/dctk.h" 27 28 #include "dcmtk/ofstd/ofdefine.h" 29 30 31 #ifdef dcmrt_EXPORTS 32 #define DCMTK_DCMRT_EXPORT DCMTK_DECL_EXPORT 33 #else 34 #define DCMTK_DCMRT_EXPORT DCMTK_DECL_IMPORT 35 #endif 36 37 38 // include this file in doxygen documentation 39 40 /** @file drttypes.h 41 * @brief type definitions, constants and helper functions for the dcmrt module 42 */ 43 44 45 /*-----------------------* 46 * contant definitions * 47 *-----------------------*/ 48 49 /** @name specific error conditions for module dcmrt. 50 * These error codes can be used in addition to the general purpose 51 * codes defined in module dcmdata. 52 */ 53 //@{ 54 55 /// error: a value is invalid according to the standard 56 extern DCMTK_DCMRT_EXPORT const OFConditionConst RT_EC_InvalidValue; 57 58 /// error: a value is not supported by this implementation 59 extern DCMTK_DCMRT_EXPORT const OFConditionConst RT_EC_UnsupportedValue; 60 61 /// error: the object is invalid, see isValid() method in IOD class 62 extern DCMTK_DCMRT_EXPORT const OFConditionConst RT_EC_InvalidObject; 63 64 //@} 65 66 67 // global definitions for logging mechanism provided by the oflog module 68 69 extern DCMTK_DCMRT_EXPORT OFLogger DCM_dcmrtLogger; 70 71 #define DCMRT_TRACE(msg) OFLOG_TRACE(DCM_dcmrtLogger, msg) 72 #define DCMRT_DEBUG(msg) OFLOG_DEBUG(DCM_dcmrtLogger, msg) 73 #define DCMRT_INFO(msg) OFLOG_INFO(DCM_dcmrtLogger, msg) 74 #define DCMRT_WARN(msg) OFLOG_WARN(DCM_dcmrtLogger, msg) 75 #define DCMRT_ERROR(msg) OFLOG_ERROR(DCM_dcmrtLogger, msg) 76 #define DCMRT_FATAL(msg) OFLOG_FATAL(DCM_dcmrtLogger, msg) 77 78 79 /*---------------------* 80 * class declaration * 81 *---------------------*/ 82 83 /** General purpose class hiding global functions, constants and types from the 84 * global namespace. Some of them might be moved to 'ofstd' or 'dcmdata' later on. 85 * All functions and constants are static and can, therefore, be accessed without 86 * creating an instance of this class. 87 */ 88 class DCMTK_DCMRT_EXPORT DRTTypes 89 { 90 91 public: 92 93 // --- destructor --- 94 95 /** destructor. (only needed to avoid compiler warnings) 96 */ 97 virtual ~DRTTypes(); 98 99 100 // --- DICOM data structure access functions --- 101 102 /** add given element to the dataset. 103 * The element is only added if 'result' is EC_Normal and the 'element' pointer is not NULL. 104 * @param result reference to status variable (checked before adding and updated afterwards!) 105 * @param dataset reference to DICOM dataset to which the element should be added 106 * @param element pointer to DICOM element which should be added. deleted if not inserted. 107 * @param vm value multiplicity (according to the data dictionary) to be checked for. 108 * (See DcmElement::checkVM() for a list of valid values.) 109 * Interpreted as cardinality (number of items) for sequence attributes. 110 * @param type value type (valid value: "1", "2" or something else which is not checked) 111 * @param moduleName optional module name to be printed (default: "RT object" if NULL) 112 * @return current value of 'result', EC_Normal if successful, an error code otherwise 113 */ 114 static OFCondition addElementToDataset(OFCondition &result, 115 DcmItem &dataset, 116 DcmElement *element, 117 const OFString &vm, 118 const OFString &type, 119 const char *moduleName = NULL); 120 121 /** get element from dataset 122 * @param dataset reference to DICOM dataset from which the element should be retrieved. 123 * (Would be 'const' if the methods from 'dcmdata' would also be 'const'.) 124 * @param element reference to DICOM element which should be retrieved. The return value 125 * is also stored in this parameter. 126 * @return status, EC_Normal if successful, an error code otherwise 127 */ 128 static OFCondition getElementFromDataset(DcmItem &dataset, 129 DcmElement &element); 130 131 /** get string value from element 132 * @param element reference to DICOM element from which the string value should be retrieved 133 * @param stringValue reference to character string where the result should be stored 134 * @param pos index of the value to get (0..vm-1), -1 for all components 135 * @return reference character string if successful, empty string otherwise 136 */ 137 static OFCondition getStringValueFromElement(const DcmElement &element, 138 OFString &stringValue, 139 const signed long pos = 0); 140 141 /** get string value from dataset 142 * @param dataset reference to DICOM dataset from which the string should be retrieved. 143 * (Would be 'const' if the methods from 'dcmdata' would also be 'const'.) 144 * @param tagKey DICOM tag specifying the attribute from which the string should be retrieved 145 * @param stringValue reference to character string in which the result should be stored. 146 * (This parameter is automatically cleared if the tag could not be found.) 147 * @return status, EC_Normal if successful, an error code otherwise 148 */ 149 static OFCondition getStringValueFromDataset(DcmItem &dataset, 150 const DcmTagKey &tagKey, 151 OFString &stringValue); 152 153 /** put string value to dataset 154 * @param dataset reference to DICOM dataset to which the string should be put. 155 * @param tag DICOM tag specifying the attribute to which the string should be put 156 * @param stringValue character string specifying the value to be set 157 * @param allowEmpty allow empty element to be inserted if OFTrue. 158 * Do not insert empty element otherwise. 159 * @return status, EC_Normal if successful, an error code otherwise 160 */ 161 static OFCondition putStringValueToDataset(DcmItem &dataset, 162 const DcmTag &tag, 163 const OFString &stringValue, 164 const OFBool allowEmpty = OFTrue); 165 166 /** check element value for correct value multiplicity and type 167 * @param element DICOM element to be checked 168 * @param vm value multiplicity (according to the data dictionary) to be checked for. 169 * (See DcmElement::checkVM() for a list of valid values.) 170 * Interpreted as cardinality (number of items) for sequence attributes. 171 * @param type value type (valid value: "1", "1C", "2" or something else which is not checked) 172 * @param searchCond optional flag indicating the status of a previous 'search' function call 173 * @param moduleName optional module name to be printed (default: "RT object" if NULL) 174 * @return OFTrue if element value is correct, OFFalse otherwise 175 */ 176 static OFBool checkElementValue(DcmElement &element, 177 const OFString &vm, 178 const OFString &type, 179 const OFCondition &searchCond = EC_Normal, 180 const char *moduleName = NULL); 181 182 /** get element from dataset and check it for correct value multiplicity and type. 183 * This functions calls the above one to check the element value. 184 * @param dataset reference to DICOM dataset from which the element should be retrieved. 185 * (Would be 'const' if the methods from 'dcmdata' would also be 'const'.) 186 * @param element DICOM element used to store the value 187 * @param vm value multiplicity (according to the data dictionary) to be checked for. 188 * (See DcmElement::checkVM() for a list of valid values.) 189 * Interpreted as cardinality (number of items) for sequence attributes. 190 * @param type value type (valid value: "1", "1C", "2" or something else which is not checked) 191 * @param moduleName optional module name to be printed (default: "RT object" if NULL) 192 * @return status, EC_Normal if element could be retrieved and value is correct, an error code otherwise 193 */ 194 static OFCondition getAndCheckElementFromDataset(DcmItem &dataset, 195 DcmElement &element, 196 const OFString &vm, 197 const OFString &type, 198 const char *moduleName = NULL); 199 200 /** get string value from dataset and check it for correct value multiplicity and type. 201 * This functions calls the above one to check the element value. 202 * @param dataset reference to DICOM dataset from which the element should be retrieved. 203 * (Would be 'const' if the methods from 'dcmdata' would also be 'const'.) 204 * @param tagKey DICOM tag specifying the attribute from which the string should be retrieved 205 * @param stringValue reference to character string in which the result should be stored. 206 * (This parameter is automatically cleared if the tag could not be found.) 207 * @param vm value multiplicity (according to the data dictionary) to be checked for. 208 * (See DcmElement::checkVM() for a list of valid values.) 209 * Interpreted as cardinality (number of items) for sequence attributes. 210 * @param type value type (valid value: "1", "1C", "2" or something else which is not checked) 211 * @param moduleName optional module name to be printed (default: "RT object" if NULL) 212 * @return status, EC_Normal if element could be retrieved and value is correct, an error code otherwise 213 */ 214 static OFCondition getAndCheckStringValueFromDataset(DcmItem &dataset, 215 const DcmTagKey &tagKey, 216 OFString &stringValue, 217 const OFString &vm, 218 const OFString &type, 219 const char *moduleName = NULL); 220 }; 221 222 223 #endif 224