/usr/include/dcmtk/dcmsr/cmr/srnumvlu.h is in libdcmtk-dev 3.6.2-3build3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | /*
*
* Copyright (C) 2016, J. Riesmeier, Oldenburg, Germany
* All rights reserved. See COPYRIGHT file for details.
*
* Header file for class CMR_SRNumericMeasurementValueWithUnits
*
* Author: Joerg Riesmeier
*
*/
#ifndef CMR_SRNUMVLU_H
#define CMR_SRNUMVLU_H
#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
#include "dcmtk/dcmsr/cmr/srnumvl.h"
/*---------------------*
* class declaration *
*---------------------*/
/** Class for SR numeric values and measurements
* (extended version with additional support of the DICOM Content Mapping Resource).
* This class checks whether the optional value qualifier uses a coded entry from the
* Defined Context Group 42 (Numeric Value Qualifier), see DICOM PS 3.3 Table C.18.1-1.
* It also provides a means of specifying the Context Group for the measurement unit
* as a C++ template type parameter. Both Baseline (BCID) and Defined Context Groups
* (DCID) are supported.
** @tparam T_Units template type used for the measurement units (context group)
* @tparam T_DefinedGroup flag indicating whether 'T_Units' is used as a baseline
* (default) or defined context group
*/
template <typename T_Units, OFBool T_DefinedGroup = OFFalse>
class CMR_SRNumericMeasurementValueWithUnits
: public CMR_SRNumericMeasurementValue
{
public:
/** default constructor
*/
CMR_SRNumericMeasurementValueWithUnits();
/** constructor
** @param numericValue numeric value (VR=DS, mandatory)
* @param measurementUnit code representing the units of measurement (mandatory)
* @param check if enabled, check 'numericValue' and 'measurementUnit' for
* validity before setting them. See corresponding setValue()
* method for details.
*/
CMR_SRNumericMeasurementValueWithUnits(const OFString &numericValue,
const T_Units &measurementUnit,
const OFBool check = OFTrue);
/** constructor
** @param valueQualifier code representing the numeric value qualifier. Used to
* specify the reason for the absence of the measured value
* sequence, i.e. why the numeric value and measurement unit
* are empty.
* @param check if enabled, check value for validity before setting it.
* See corresponding setValue() method for details.
*/
CMR_SRNumericMeasurementValueWithUnits(const CID42_NumericValueQualifier &valueQualifier,
const OFBool check = OFTrue);
/** constructor
** @param numericValue numeric value (VR=DS, mandatory)
* @param measurementUnit code representing the units of measurement (mandatory)
* @param valueQualifier code representing the numeric value qualifier (optional).
* Can also be used to specify the reason for the absence of
* the measured value sequence (where 'numericValue' and
* 'measurementUnit' are stored).
* @param check if enabled, check values for validity before setting them.
* See corresponding setValue() method for details.
*/
CMR_SRNumericMeasurementValueWithUnits(const OFString &numericValue,
const T_Units &measurementUnit,
const CID42_NumericValueQualifier &valueQualifier,
const OFBool check = OFTrue);
/** copy constructor
** @param numericMeasurement numeric measurement value to be copied (not checked !)
*/
CMR_SRNumericMeasurementValueWithUnits(const CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup> &numericMeasurement);
/** copy constructor
** @param numericMeasurement numeric measurement value to be copied (not checked !)
*/
CMR_SRNumericMeasurementValueWithUnits(const CMR_SRNumericMeasurementValue &numericMeasurement);
/** destructor
*/
virtual ~CMR_SRNumericMeasurementValueWithUnits();
/** assignment operator
** @param numericMeasurement numeric measurement value to be copied (not checked !)
** @return reference to this numeric value after 'numericMeasurement' has been copied
*/
CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup> &operator=(const CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup> &numericMeasurement);
/** set numeric value and measurement unit.
* Before setting the values, they are usually checked. Please note that both values
* (i.e. 'numericValue' and 'measurementUnit') either have to be empty or non-empty.
* If the value pair is invalid, the current value pair is not replaced and remains
* unchanged. If the value pair is replaced, the optional floating point and rational
* representations are cleared, i.e. they have to be set manually if needed.
** @param numericValue numeric value to be set (VR=DS, mandatory)
* @param measurementUnit measurement unit to be set (mandatory)
* @param check if enabled, check values for validity before setting them.
* See checkXXX() methods for details.
** @return status, EC_Normal if successful, an error code otherwise
*/
OFCondition setValue(const OFString &numericValue,
const T_Units &measurementUnit,
const OFBool check = OFTrue);
/** set numeric value, measurement unit and numeric value qualifier.
* Before setting the values, they are usually checked. Please note that both
* 'numericValue' and 'measurementUnit' either have to be empty or non-empty.
* If one of the three values is invalid, the current numeric measurement value is not
* replaced and remains unchanged. If the values are replaced, the optional floating
* point and rational representations are cleared, i.e. they have to be set manually if
* needed.
** @param numericValue numeric value to be set (VR=DS, mandatory)
* @param measurementUnit measurement unit to be set (mandatory)
* @param valueQualifier numeric value qualifier to be set (optional). Can also be
* used to specify the reason for the absence of the measured
* value sequence (where 'numericValue' and 'measurementUnit'
* are stored). Use an empty code to remove the current value.
* @param check if enabled, check values for validity before setting them.
* See checkXXX() methods for details.
** @return status, EC_Normal if successful, an error code otherwise
*/
OFCondition setValue(const OFString &numericValue,
const T_Units &measurementUnit,
const CID42_NumericValueQualifier &valueQualifier,
const OFBool check = OFTrue);
/** set measurement unit.
* Before setting the code, it is usually checked. If the code is invalid the current
* code is not replaced and remains unchanged.
** @param measurementUnit measurement unit to be set (mandatory)
* @param check if enabled, check value for validity before setting it.
* See checkMeasurementUnit() method for details. An empty
* value is never accepted, use the clear() method instead.
** @return status, EC_Normal if successful, an error code otherwise
*/
OFCondition setMeasurementUnit(const T_Units &measurementUnit,
const OFBool check = OFTrue);
protected:
/** check the specified measurement unit for validity.
* First, the inherited method CMR_SRNumericMeasurementValue::checkMeasurementUnit()
* is called. Then, conformance with any Defined Context Group (T_Units) is checked.
** @param measurementUnit measurement unit to be checked
** @return status, EC_Normal if measurement unit is valid, an error code otherwise
*/
virtual OFCondition checkMeasurementUnit(const DSRCodedEntryValue &measurementUnit) const;
/** check the specified measurement unit for validity.
* This method also checks conformance with any Defined Context Group (T_Units).
** @param measurementUnit measurement unit to be checked
** @return status, EC_Normal if measurement unit is valid, an error code otherwise
*/
virtual OFCondition checkMeasurementUnit(const T_Units &measurementUnit) const;
};
/*------------------*
* implementation *
*------------------*/
template <typename T_Units, OFBool T_DefinedGroup>
CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::CMR_SRNumericMeasurementValueWithUnits()
: CMR_SRNumericMeasurementValue()
{
}
template <typename T_Units, OFBool T_DefinedGroup>
CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::CMR_SRNumericMeasurementValueWithUnits(const OFString &numericValue,
const T_Units &measurementUnit,
const OFBool check)
: CMR_SRNumericMeasurementValue()
{
/* use this method in order to pass T_Units parameter */
setValue(numericValue, measurementUnit, check);
}
template <typename T_Units, OFBool T_DefinedGroup>
CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::CMR_SRNumericMeasurementValueWithUnits(const CID42_NumericValueQualifier &valueQualifier,
const OFBool check)
: CMR_SRNumericMeasurementValue(valueQualifier, check)
{
}
template <typename T_Units, OFBool T_DefinedGroup>
CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::CMR_SRNumericMeasurementValueWithUnits(const OFString &numericValue,
const T_Units &measurementUnit,
const CID42_NumericValueQualifier &valueQualifier,
const OFBool check)
: CMR_SRNumericMeasurementValue()
{
/* use this method in order to pass T_Units parameter */
setValue(numericValue, measurementUnit, valueQualifier, check);
}
template <typename T_Units, OFBool T_DefinedGroup>
CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::CMR_SRNumericMeasurementValueWithUnits(const CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup> &numericMeasurement)
: CMR_SRNumericMeasurementValue(numericMeasurement)
{
}
template <typename T_Units, OFBool T_DefinedGroup>
CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::CMR_SRNumericMeasurementValueWithUnits(const CMR_SRNumericMeasurementValue &numericMeasurement)
: CMR_SRNumericMeasurementValue(numericMeasurement)
{
}
template <typename T_Units, OFBool T_DefinedGroup>
CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::~CMR_SRNumericMeasurementValueWithUnits()
{
}
template <typename T_Units, OFBool T_DefinedGroup>
CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup> &CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::operator=(const CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup> &numericMeasurement)
{
CMR_SRNumericMeasurementValue::operator=(numericMeasurement);
return *this;
}
template <typename T_Units, OFBool T_DefinedGroup>
OFCondition CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::setValue(const OFString &numericValue,
const T_Units &measurementUnit,
const OFBool check)
{
const DSRCodedEntryValue valueQualifier;
/* call the function doing the real work */
return CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::setValue(numericValue, measurementUnit, valueQualifier, check);
}
template <typename T_Units, OFBool T_DefinedGroup>
OFCondition CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::setValue(const OFString &numericValue,
const T_Units &measurementUnit,
const CID42_NumericValueQualifier &valueQualifier,
const OFBool check)
{
OFCondition result = EC_Normal;
if (check)
{
/* only check if at least one of the two values is non-empty */
if (!numericValue.empty() || !measurementUnit.hasSelectedValue())
{
/* check whether the passed values are valid */
result = checkNumericValue(numericValue);
if (result.good())
result = checkMeasurementUnit(measurementUnit);
}
if (result.good())
result = checkNumericValueQualifier(valueQualifier);
}
/* set the value (without checking all the details again) */
if (result.good())
result = CMR_SRNumericMeasurementValue::setValue(numericValue, measurementUnit, valueQualifier, OFFalse /*check*/);
return result;
}
template <typename T_Units, OFBool T_DefinedGroup>
OFCondition CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::setMeasurementUnit(const T_Units &measurementUnit,
const OFBool check)
{
/* first, check given measurement unit for validity (if not disabled) */
OFCondition result = (check) ? checkMeasurementUnit(measurementUnit) : EC_Normal;
/* then, set the measurement unit (without checking the coded entry again) */
if (result.good())
result = CMR_SRNumericMeasurementValue::setMeasurementUnit(measurementUnit, OFFalse /*check*/);
return result;
}
template <typename T_Units, OFBool T_DefinedGroup>
OFCondition CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::checkMeasurementUnit(const DSRCodedEntryValue &measurementUnit) const
{
/* first, check coded entry for basic validity */
OFCondition result = CMR_SRNumericMeasurementValue::checkMeasurementUnit(measurementUnit);
/* then, check whether coded entry is allowed (if defined context group) */
if (result.good() && T_DefinedGroup)
{
const T_Units contextGroup;
if (!contextGroup.hasCodedEntry(measurementUnit))
result = SR_EC_CodedEntryNotInContextGroup;
}
return result;
}
template <typename T_Units, OFBool T_DefinedGroup>
OFCondition CMR_SRNumericMeasurementValueWithUnits<T_Units, T_DefinedGroup>::checkMeasurementUnit(const T_Units &measurementUnit) const
{
/* measurement unit should never be empty */
return measurementUnit.hasSelectedValue() ? measurementUnit.checkSelectedValue(T_DefinedGroup)
: SR_EC_InvalidValue;
}
#endif
|