This file is indexed.

/usr/include/dcmtk/dcmsr/dsrnumvl.h is in libdcmtk-dev 3.6.1~20150924-5.

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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
/*
 *
 *  Copyright (C) 2000-2015, OFFIS e.V.
 *  All rights reserved.  See COPYRIGHT file for details.
 *
 *  This software and supporting documentation were developed by
 *
 *    OFFIS e.V.
 *    R&D Division Health
 *    Escherweg 2
 *    D-26121 Oldenburg, Germany
 *
 *
 *  Module: dcmsr
 *
 *  Author: Joerg Riesmeier
 *
 *  Purpose:
 *    classes: DSRNumericMeasurementValue
 *
 */


#ifndef DSRNUMVL_H
#define DSRNUMVL_H

#include "dcmtk/config/osconfig.h"   /* make sure OS specific configuration is included first */

#include "dcmtk/dcmsr/dsrcodvl.h"

#include "dcmtk/ofstd/ofstring.h"


/*---------------------*
 *  class declaration  *
 *---------------------*/

/** Class for numeric measurement values
 */
class DCMTK_DCMSR_EXPORT DSRNumericMeasurementValue
{
    // allow access to getValuePtr()
    friend class DSRContentItem;

  public:

    /** default constructor
     */
    DSRNumericMeasurementValue();

    /** constructor
     ** @param  numericValue     numeric measurement 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.
     */
    DSRNumericMeasurementValue(const OFString &numericValue,
                               const DSRCodedEntryValue &measurementUnit,
                               const OFBool check = OFTrue);

    /** constructor
     ** @param  numericValue     numeric measurement 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.
     */
    DSRNumericMeasurementValue(const OFString &numericValue,
                               const DSRCodedEntryValue &measurementUnit,
                               const DSRCodedEntryValue &valueQualifier,
                               const OFBool check = OFTrue);

    /** copy constructor
     ** @param  numericMeasurement  numeric measurement value to be copied (not checked !)
     */
    DSRNumericMeasurementValue(const DSRNumericMeasurementValue &numericMeasurement);

    /** destructor
     */
    virtual ~DSRNumericMeasurementValue();

    /** assignment operator
     ** @param  numericMeasurement  numeric measurement value to be copied (not checked !)
     ** @return reference to this numeric value after 'numericMeasurement' has been copied
     */
    DSRNumericMeasurementValue &operator=(const DSRNumericMeasurementValue &numericMeasurement);

    /** clear all internal variables.
     *  Use this method to create an empty numeric measurement value.
     */
    virtual void clear();

    /** check whether the current numeric measurement value is valid.
     *  The value is valid if isEmpty() is true or both the numeric value and the measurement
     *  unit contain a valid value, and the value qualifier is valid (see checkXXX() methods).
     *  The possibly available additional representations of the numeric value are never
     *  checked.
     ** @return OFTrue if value is valid, OFFalse otherwise
     */
    virtual OFBool isValid() const;

    /** check whether the current numeric measurement value is empty.
     *  Checks whether both the numeric value and the measurement are empty.  The optional
     *  value qualifier is not checked since it might contain the reason for the absence of
     *  the measured value sequence.
     ** @return OFTrue if value is empty, OFFalse otherwise
     */
    virtual OFBool isEmpty() const;

    /** print numeric measurement value.
     *  The output of a typical numeric measurement value looks like this:
     *  "3.5" (cm,UCUM[1.4],"centimeter").  If the value is empty the text "empty" is printed
     *  instead.  The numeric value qualifier as well as the possibly available additional
     *  floating point and rational representations of the numeric value are never printed.
     ** @param  stream  output stream to which the numeric measurement value should be printed
     *  @param  flags   flag used to customize the output (not used)
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    virtual OFCondition print(STD_NAMESPACE ostream &stream,
                              const size_t flags) const;

    /** read numeric measurement value from XML document
     ** @param  doc     document containing the XML file content
     *  @param  cursor  cursor pointing to the starting node
     *  @param  flags   flag used to customize the reading process (see DSRTypes::XF_xxx)
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    virtual OFCondition readXML(const DSRXMLDocument &doc,
                                DSRXMLCursor cursor,
                                const size_t flags);

    /** write numeric measurement value in XML format
     ** @param  stream  output stream to which the XML document is written
     *  @param  flags   flag used to customize the output (see DSRTypes::XF_xxx)
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    virtual OFCondition writeXML(STD_NAMESPACE ostream &stream,
                                 const size_t flags) const;

    /** read measured value sequence and numeric value qualifier code sequence from dataset.
     *  The number of items within the sequences is checked.  If error/warning output are
     *  enabled, a warning message is printed if a sequence is absent or contains more than
     *  one item.
     ** @param  dataset  DICOM dataset from which the sequences should be read
     *  @param  flags    flag used to customize the reading process (see DSRTypes::RF_xxx)
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    virtual OFCondition readSequence(DcmItem &dataset,
                                     const size_t flags);

    /** write measured value sequence and numeric value qualifier code sequence to dataset.
     *  The measured value sequence is always written (might be empty, though).  The numeric
     *  value qualifier code sequence is optional and, therefore, only written if non-empty.
     ** @param  dataset  DICOM dataset to which the sequences should be written
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    virtual OFCondition writeSequence(DcmItem &dataset) const;

    /** render numeric measurement value in HTML/XHTML format
     ** @param  docStream    output stream to which the main HTML/XHTML document is written
     *  @param  annexStream  output stream to which the HTML/XHTML document annex is written
     *  @param  annexNumber  reference to the variable where the current annex number is stored.
     *                       Value is increased automatically by 1 after a new entry has been added.
     *  @param  flags        flag used to customize the output (see DSRTypes::HF_xxx)
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    virtual OFCondition renderHTML(STD_NAMESPACE ostream &docStream,
                                   STD_NAMESPACE ostream &annexStream,
                                   size_t &annexNumber,
                                   const size_t flags) const;

    /** get reference to numeric measurement value
     ** @return reference to numeric measurement value
     */
    inline const DSRNumericMeasurementValue &getValue() const
    {
        return *this;
    }

    /** get copy of numeric measurement value
     ** @param  numericMeasurement  reference to variable in which the value should be stored
     ** @return always returns EC_Normal
     */
    OFCondition getValue(DSRNumericMeasurementValue &numericMeasurement) const;

    /** get numeric value
     ** @return current numeric value (might be invalid or an empty string)
     */
    inline const OFString &getNumericValue() const
    {
        return NumericValue;
    }

    /** get measurement unit
     ** @return reference to current measurement unit code (might be invalid or empty)
     */
    inline const DSRCodedEntryValue &getMeasurementUnit() const
    {
        return MeasurementUnit;
    }

    /** get numeric value qualifier (optional)
     ** @return reference to current numeric value qualifier code (might be invalid or empty)
     */
    inline const DSRCodedEntryValue &getNumericValueQualifier() const
    {
        return ValueQualifier;
    }

    /** get copy of measurement unit
     ** @param  measurementUnit  reference to variable in which the code should be stored
     ** @return always returns EC_Normal
     */
    OFCondition getMeasurementUnit(DSRCodedEntryValue &measurementUnit) const;

    /** get copy of numeric value qualifier (optional).
     *  Can be used to specify the reason for the absence of the measured value sequence.
     ** @param  valueQualifier  reference to variable in which the code should be stored
     ** @return always returns EC_Normal
     */
    OFCondition getNumericValueQualifier(DSRCodedEntryValue &valueQualifier) const;

    /** get floating point representation of the numeric value (optional)
     ** @param  floatingPoint  reference to variable in which the floating point representation
     *                         should be stored
     ** @return status, EC_Normal if successful, an error code otherwise.  Returns
     *    SR_EC_RepresentationNotAvailable if floating point representation is not available.
     */
    OFCondition getFloatingPointRepresentation(Float64 &floatingPoint) const;

    /** get rational representation of the numeric value (optional)
     ** @param  rationalNumerator    reference to variable in which the integer numerator of
     *                               the rational representation should be stored
     ** @param  rationalDenominator  reference to variable in which the integer denominator of
     *                               the rational representation should be stored
     ** @return status, EC_Normal if successful, an error code otherwise.  Returns
     *    SR_EC_RepresentationNotAvailable if rational representation is not available.
     */
    OFCondition getRationalRepresentation(Sint32 &rationalNumerator,
                                          Uint32 &rationalDenominator) const;

    /** set numeric measurement value.
     *  Before setting the value, it is usually checked.  If the value is invalid, the current
     *  value is not replaced and remains unchanged.
     ** @param  numericMeasurement  value to be set
     *  @param  check               if enabled, check value for validity before setting it.
     *                              See checkXXX() methods for details.  Empty values are only
     *                              accepted for non-mandatory attributes.
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    OFCondition setValue(const DSRNumericMeasurementValue &numericMeasurement,
                         const OFBool check = OFTrue);

    /** 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 DSRCodedEntryValue &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 DSRCodedEntryValue &measurementUnit,
                         const DSRCodedEntryValue &valueQualifier,
                         const OFBool check = OFTrue);

    /** set numeric value.
     *  Before setting the value, it is usually checked.  If the value is invalid, the current
     *  value is not replaced and remains unchanged.  If the value 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  check         if enabled, check value for validity before setting it.
     *                        See checkNumericValue() 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 setNumericValue(const OFString &numericValue,
                                const OFBool check = OFTrue);

    /** set numeric value from element.
     *  Before setting the value, it is usually checked.  If the value is invalid, the current
     *  value is not replaced and remains unchanged.  If the value is replaced, the optional
     *  floating point and rational representations are cleared, i.e. they have to be set
     *  manually if needed.
     ** @param  delem  DICOM element from which the numeric value should be retrieved
     *  @param  pos    index of the value in case of multi-valued elements (0..vm-1)
     *  @param  check  if enabled, check numeric value for validity before setting it.  See
     *                 checkNumericValue() method for details.  An empty value is never
     *                 accepted.
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    OFCondition setNumericValue(const DcmElement &delem,
                                const unsigned long pos = 0,
                                const OFBool check = OFTrue);

    /** set numeric value from dataset.
     *  Before setting the value, it is usually checked.  If the value is invalid, the current
     *  value is not replaced and remains unchanged.  If the value is replaced, the optional
     *  floating point and rational representations are cleared, i.e. they have to be set
     *  manually if needed.
     ** @param  dataset  DICOM dataset from which the numeric value should be retrieved
     *  @param  tagKey   DICOM tag specifying the attribute from which the value should be
     *                   retrieved.  The search is limited to the top-level of the dataset.
     *  @param  pos      index of the value in case of multi-valued elements (0..vm-1)
     *  @param  check    if enabled, check numeric value for validity before setting it.
     *                   See checkNumericValue() method for details.  An empty value is
     *                   never accepted.
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    OFCondition setNumericValue(DcmItem &dataset,
                                const DcmTagKey &tagKey,
                                const unsigned long pos = 0,
                                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 DSRCodedEntryValue &measurementUnit,
                                   const OFBool check = OFTrue);

    /** set numeric value qualifier.
     *  This optional code specifies the qualification of the Numeric Value in the Measured
     *  Value Sequence, or the reason for the absence of the Measured Value Sequence Item.
     *  Before setting the code, it is usually checked.  If the code is invalid the current
     *  code is not replaced and remains unchanged.
     ** @param  valueQualifier  numeric value qualifier to be set (optional).  Use an empty
     *                          code to remove the current value.
     *  @param  check           if enabled, check value for validity before setting it.
     *                          See checkNumericValueQualifier() method for details.
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    OFCondition setNumericValueQualifier(const DSRCodedEntryValue &valueQualifier,
                                         const OFBool check = OFTrue);

    /** set floating point representation of the numeric value.
     *  According to the DICOM standard, this value is "required if the numeric value has
     *  insufficient precision to represent the value as a string.  May be present otherwise."
     *  Please note that it is not checked whether this representation is consistent with the
     *  numeric value stored as a string.
     ** @param  floatingPoint  floating point representation of the numeric value
     *  @param  check          dummy parameter (currently not used)
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    OFCondition setFloatingPointRepresentation(const Float64 floatingPoint,
                                               const OFBool check = OFTrue);

    /** set rational representation of the numeric value.
     *  According to the DICOM standard, this value is "required if the numeric value has
     *  insufficient precision to represent a rational value as a string.  May be present
     *  otherwise."  Please note that it is not checked whether this representation is
     *  consistent with the numeric value stored as a string.
     ** @param  rationalNumerator    integer numerator of a rational representation of the
     *                               numeric value (encoded as a signed integer value)
     *  @param  rationalDenominator  integer denominator of a rational representation of the
     *                               numeric value (encoded as a non-zero unsigned integer
     *                               value)
     *  @param  check                if enabled, check values for validity before setting them.
     *                               See checkRationalRepresentation() method for details.
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    OFCondition setRationalRepresentation(const Sint32 rationalNumerator,
                                          const Uint32 rationalDenominator,
                                          const OFBool check = OFTrue);

    /** remove floating point representation of the numeric value (if any).
     *  Internally, all elements that belong to this representation are cleared.
     */
    void removeFloatingPointRepresentation();

    /** remove rational representation of the numeric value (if any).
     *  Internally, all elements that belong to this representation are cleared.
     */
    void removeRationalRepresentation();


  protected:

    /** get pointer to numeric measurement value
     ** @return pointer to numeric measurement value (never NULL)
     */
    inline DSRNumericMeasurementValue *getValuePtr()
    {
        return this;
    }

    /** read numeric measurement value from dataset
     ** @param  dataset  DICOM dataset from which the value should be read
     *  @param  flags    flag used to customize the reading process (see DSRTypes::RF_xxx)
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    virtual OFCondition readItem(DcmItem &dataset,
                                 const size_t flags);

    /** write numeric measurement value to dataset
     ** @param  dataset  DICOM dataset to which the value should be written
     ** @return status, EC_Normal if successful, an error code otherwise
     */
    virtual OFCondition writeItem(DcmItem &dataset) const;

    /** check the specified numeric value for validity.
     *  Currently, the only checks performed are that the string is non-empty and that the
     *  given value conforms to the corresponding VR (DS) and VM (1).
     ** @param  numericValue  numeric value to be checked
     ** @return status, EC_Normal if numeric value is valid, an error code otherwise
     */
    virtual OFCondition checkNumericValue(const OFString &numericValue) const;

    /** check the specified measurement unit for validity.
     *  Internally, the methods DSRCodedEntryValue::isEmpty() and
     *  DSRCodedEntryValue::checkCurrentValue() are used for this purpose.  Conformance
     *  with the Context Group 82 (as defined in the DICOM standard) is not yet 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 numeric value qualifier for validity.
     *  Internally, DSRCodedEntryValue::isEmpty() and DSRCodedEntryValue::checkCurrentValue()
     *  are used for this purpose.  Conformance with the Context Group 42 (as defined in the
     *  DICOM standard) is not checked; see class CMR_SRNumericMeasurementValue if needed,
     *  which supports such additional checks.
     ** @param  valueQualifier  numeric value qualifier to be checked
     ** @return status, EC_Normal if value qualifier is valid, an error code otherwise
     */
    virtual OFCondition checkNumericValueQualifier(const DSRCodedEntryValue &valueQualifier) const;

    /** check the specified rational representation for validity.
     *  The only check that is performed is that the 'rationalDenominator' is not zero, i.e.
     *  it is not checked whether this representation is consistent with the numeric value
     *  stored as a string.
     ** @param  rationalNumerator    numerator of the rational representation to be checked
     *  @param  rationalDenominator  denominator of a rational representation to be checked
     ** @return status, EC_Normal if rational representation is valid, an error code otherwise
     */
    virtual OFCondition checkRationalRepresentation(const Sint32 rationalNumerator,
                                                    const Uint32 rationalDenominator) const;

    /** check the currently stored numeric measurement value for validity.
     *  See above checkXXX() methods for details.
     ** @return status, EC_Normal if current value is valid, an error code otherwise
     */
    virtual OFCondition checkCurrentValue() const;


  private:

    /// Numeric Value (VR=DS, type 1 within a type 2 sequence)
    OFString               NumericValue;
    /// Measurement Unit (type 1 within a type 2 sequence)
    DSRCodedEntryValue     MeasurementUnit;
    /// Numeric Value Qualifier (type 3)
    DSRCodedEntryValue     ValueQualifier;
    /// Floating Point Value (VR=FD, type 1C)
    DcmFloatingPointDouble FloatingPointValue;
    /// Rational Numerator Value (VR=SL, type 1C)
    DcmSignedLong          RationalNumeratorValue;
    /// Rational Denominator Value (VR=UL, type 1C)
    DcmUnsignedLong        RationalDenominatorValue;
};


#endif