OFFIS DCMTK  Version 3.6.0
dcdicent.h
1 /*
2  *
3  * Copyright (C) 1994-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmdata
15  *
16  * Author: Andrew Hewett
17  *
18  * Purpose: Interface for a dictionary entry in the loadable DICOM data dictionary
19  *
20  * Last Update: $Author: meichel $
21  * Update Date: $Date: 2010-11-17 15:17:51 $
22  * CVS/RCS Revision: $Revision: 1.26 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 #ifndef DCDICENT_H
30 #define DCDICENT_H
31 
32 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
33 #include "dcmtk/dcmdata/dctagkey.h"
34 #include "dcmtk/dcmdata/dcvr.h"
35 
36 #define INCLUDE_CSTRING /* for strcmp() */
37 #include "dcmtk/ofstd/ofstdinc.h"
38 
40 #define DcmVariableVM -1
41 
42 #define DCM_INRANGE(x,a,b) (((x) >= (a)) && ((x) <= (b)))
43 #define DCM_IS_ODD(x) (((x) % 2) == 1)
44 #define DCM_IS_EVEN(x) (((x) % 2) == 0)
45 
46 
49 enum DcmDictRangeRestriction
50 {
52  DcmDictRange_Unspecified,
53 
55  DcmDictRange_Odd,
56 
58  DcmDictRange_Even
59 };
60 
61 
65 class DcmDictEntry: public DcmTagKey
66 {
67 public:
68 
80  DcmDictEntry(Uint16 g, Uint16 e, DcmVR vr,
81  const char* nam, int vmMin, int vmMax,
82  const char* vers, OFBool doCopyStrings,
83  const char* pcreator);
84 
98  DcmDictEntry(Uint16 g, Uint16 e, Uint16 ug, Uint16 ue, DcmVR vr,
99  const char* nam, int vmMin, int vmMax,
100  const char* vers, OFBool doCopyStrings,
101  const char* pcreator);
102 
104  DcmDictEntry(const DcmDictEntry& e);
105 
107  ~DcmDictEntry();
108 
109  /* access methods */
110 
112  DcmVR getVR() const
113  {
114  return valueRepresentation;
115  }
116 
118  DcmEVR getEVR() const
119  {
120  return valueRepresentation.getEVR();
121  }
122 
124  const char* getStandardVersion() const
125  {
126  return standardVersion;
127  }
128 
130  const char* getTagName() const
131  {
132  return tagName;
133  }
134 
136  const char* getPrivateCreator() const
137  {
138  return privateCreator;
139  }
140 
145  int privateCreatorMatch(const char *c) const
146  {
147  return
148  (
149  ((privateCreator == NULL) && (c == NULL)) ||
150  (privateCreator && c && (0 == strcmp(privateCreator, c)))
151  );
152  }
153 
159  int privateCreatorMatch(const DcmDictEntry& arg) const
160  {
162  }
163 
165  int getVMMin() const
166  {
167  return valueMultiplicityMin;
168  }
169 
171  int getVMMax() const
172  {
173  return valueMultiplicityMax;
174  }
175 
177  OFBool isFixedSingleVM() const
178  {
179  return ((valueMultiplicityMin != DcmVariableVM) &&
181  }
182 
184  OFBool isFixedRangeVM() const
185  {
186  return ((valueMultiplicityMin != DcmVariableVM) &&
187  (valueMultiplicityMax != DcmVariableVM));
188  }
189 
191  OFBool isVariableRangeVM() const
192  {
193  return ((valueMultiplicityMin != DcmVariableVM) &&
194  (valueMultiplicityMax == DcmVariableVM));
195  }
196 
201  void setUpper(const DcmTagKey& key)
202  {
203  upperKey = key;
204  }
205 
210  void setUpperGroup(Uint16 ug)
211  {
212  upperKey.setGroup(ug);
213  }
214 
219  void setUpperElement(Uint16 ue)
220  {
221  upperKey.setElement(ue);
222  }
223 
225  Uint16 getUpperGroup() const
226  {
227  return upperKey.getGroup();
228  }
229 
231  Uint16 getUpperElement() const
232  {
233  return upperKey.getElement();
234  }
235 
238  {
239  return * OFstatic_cast(const DcmTagKey *, this);
240  }
241 
244  {
245  return upperKey;
246  }
247 
249  int isRepeatingGroup() const
250  {
251  return (getGroup() != getUpperGroup());
252  }
253 
255  int isRepeatingElement() const
256  {
257  return (getElement() != getUpperElement());
258  }
259 
261  int isRepeating() const
262  {
263  return (isRepeatingGroup() || isRepeatingElement());
264  }
265 
267  DcmDictRangeRestriction getGroupRangeRestriction() const
268  {
269  return groupRangeRestriction;
270  }
271 
273  void setGroupRangeRestriction(DcmDictRangeRestriction rr)
274  {
276  }
277 
279  DcmDictRangeRestriction getElementRangeRestriction() const
280  {
282  }
283 
285  void setElementRangeRestriction(DcmDictRangeRestriction rr)
286  {
288  }
289 
290  /* containment */
291 
298  int contains(const DcmTagKey& key, const char *privCreator) const /* this contains key */
299  {
300  if ((getGroupRangeRestriction() == DcmDictRange_Even) &&
301  DCM_IS_ODD(key.getGroup()))
302  return OFFalse;
303  else if ((getGroupRangeRestriction() == DcmDictRange_Odd) &&
304  DCM_IS_EVEN(key.getGroup()))
305  return OFFalse;
306  else if ((getElementRangeRestriction() == DcmDictRange_Even) &&
307  DCM_IS_ODD(key.getElement()))
308  return OFFalse;
309  else if ((getElementRangeRestriction() == DcmDictRange_Odd) &&
310  DCM_IS_EVEN(key.getElement()))
311  return OFFalse;
312  else if (! privateCreatorMatch(privCreator))
313  return OFFalse;
314  else
315  {
316  const OFBool groupMatches=DCM_INRANGE(key.getGroup(), getGroup(), getUpperGroup());
317  OFBool found=groupMatches && DCM_INRANGE(key.getElement(), getElement(), getUpperElement());
318  if (!found && groupMatches && privCreator)
319  found=DCM_INRANGE(key.getElement() & 0xFF, getElement(), getUpperElement());
320  return found;
321  }
322  }
323 
328  int contains(const char *name) const /* this contains named key */
329  {
330  return !strcmp( tagName, name );
331  }
332 
333  /* set relations */
334 
340  int subset(const DcmDictEntry& e) const /* this is a subset of key */
341  {
342  return ( (getGroup() >= e.getGroup()) &&
343  (getUpperGroup() <= e.getUpperGroup()) &&
344  (getElement() >= e.getElement()) &&
345  (getUpperElement() <= e.getUpperElement()) &&
347  );
348  }
349 
354  int setEQ(const DcmDictEntry& e) const /* this is set equal to key */
355  {
356  return ( (getGroup() == e.getGroup()) &&
357  (getUpperGroup() == e.getUpperGroup()) &&
358  (getElement() == e.getElement()) &&
359  (getUpperElement() == e.getUpperElement()) &&
363  );
364  }
365 
367  friend STD_NAMESPACE ostream& operator<<(STD_NAMESPACE ostream& s, const DcmDictEntry& e);
368 
369 private:
370 
373 
378 
381 
383  const char *tagName;
384 
387 
390 
392  const char *standardVersion;
393 
396 
398  DcmDictRangeRestriction groupRangeRestriction;
399 
401  DcmDictRangeRestriction elementRangeRestriction;
402 
404  const char *privateCreator;
405 };
406 
407 #endif /* !DCDICENT_H */
408 
409 
410 /*
411 ** CVS/RCS Log:
412 ** $Log: dcdicent.h,v $
413 ** Revision 1.26 2010-11-17 15:17:51 meichel
414 ** Fixed issue with data dictionary causing private tags with group number
415 ** range and flexible element number not to be found in the dictionary.
416 **
417 ** Revision 1.25 2010-10-14 13:15:40 joergr
418 ** Updated copyright header. Added reference to COPYRIGHT file.
419 **
420 ** Revision 1.24 2010-06-25 09:15:19 uli
421 ** Fixed issues with compiling with HAVE_STD_STRING.
422 **
423 ** Revision 1.23 2010-03-01 09:08:44 uli
424 ** Removed some unnecessary include directives in the headers.
425 **
426 ** Revision 1.22 2009-11-04 09:58:07 uli
427 ** Switched to logging mechanism provided by the "new" oflog module
428 **
429 ** Revision 1.21 2006-08-15 15:49:56 meichel
430 ** Updated all code in module dcmdata to correctly compile when
431 ** all standard C++ classes remain in namespace std.
432 **
433 ** Revision 1.20 2005/12/08 16:28:08 meichel
434 ** Changed include path schema for all DCMTK header files
435 **
436 ** Revision 1.19 2004/01/16 14:07:03 joergr
437 ** Removed acknowledgements with e-mail addresses from CVS log.
438 **
439 ** Revision 1.18 2003/08/14 09:00:56 meichel
440 ** Adapted type casts to new-style typecast operators defined in ofcast.h
441 **
442 ** Revision 1.17 2002/11/27 12:07:21 meichel
443 ** Adapted module dcmdata to use of new header file ofstdinc.h
444 **
445 ** Revision 1.16 2002/07/23 14:21:25 meichel
446 ** Added support for private tag data dictionaries to dcmdata
447 **
448 ** Revision 1.15 2002/04/16 13:41:44 joergr
449 ** Added configurable support for C++ ANSI standard includes (e.g. streams).
450 **
451 ** Revision 1.14 2001/06/01 15:48:36 meichel
452 ** Updated copyright header
453 **
454 ** Revision 1.13 2000/03/08 16:26:13 meichel
455 ** Updated copyright header.
456 **
457 ** Revision 1.12 1999/03/31 09:24:35 meichel
458 ** Updated copyright header in module dcmdata
459 **
460 ** Revision 1.11 1998/07/15 15:48:45 joergr
461 ** Removed several compiler warnings reported by gcc 2.8.1 with
462 ** additional options, e.g. missing copy constructors and assignment
463 ** operators, initialization of member variables in the body of a
464 ** constructor instead of the member initialization list, hiding of
465 ** methods by use of identical names, uninitialized member variables,
466 ** missing const declaration of char pointers. Replaced tabs by spaces.
467 **
468 ** Revision 1.10 1997/08/26 13:44:59 hewett
469 ** Modified constructors to take const parameters.
470 **
471 ** Revision 1.9 1997/07/31 14:40:35 meichel
472 ** Created copy constructor for class DcmDictEntry, required by dcmcheck.
473 **
474 ** Revision 1.8 1997/07/21 08:25:07 andreas
475 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
476 ** with one unique boolean type OFBool.
477 **
478 ** Revision 1.7 1997/04/18 08:04:39 andreas
479 ** - Minor corrections: correct some warnings of the SUN-C++ Compiler
480 ** concerning the assignments of wrong types and inline compiler
481 ** errors
482 **
483 ** Revision 1.6 1997/04/15 16:25:05 hewett
484 ** Corrected data dictionary bug whereby the even/odd range restrictions
485 ** were not being taken into consideration when searching the dictionary.
486 **
487 ** Revision 1.5 1996/09/24 16:24:58 hewett
488 ** Added preliminary support for the Macintosh environment (GUSI library).
489 **
490 ** Revision 1.4 1996/09/18 16:37:09 hewett
491 ** Added capability to search data dictionary by tag name.
492 **
493 ** Revision 1.3 1996/03/20 16:43:49 hewett
494 ** Updated for revised data dictionary. Repeating tags are now handled better.
495 ** A linear list of repeating tags has been introduced with a subset ordering
496 ** mechanism to ensure that dictionary searches locate the most precise
497 ** dictionary entry.
498 **
499 */
Uint16 getUpperGroup() const
returns upper limit for tag group
Definition: dcdicent.h:225
Uint16 getElement() const
returns element number
Definition: dctagkey.h:296
class maintaining a attribute tag (group and element number)
Definition: dctagkey.h:46
OFBool isFixedRangeVM() const
returns true if element has a fixed VM range
Definition: dcdicent.h:184
OFBool isFixedSingleVM() const
returns true if element has a single valid VM value
Definition: dcdicent.h:177
int privateCreatorMatch(const char *c) const
checks if the private creator code equals the given string
Definition: dcdicent.h:145
DcmDictRangeRestriction groupRangeRestriction
restriction (even, odd, unrestricted) for group range
Definition: dcdicent.h:398
DcmVR getVR() const
returns VR object by value
Definition: dcdicent.h:112
OFBool stringsAreCopies
true if strings are copies (i.e. should be deleted upon destruction)
Definition: dcdicent.h:395
int getVMMin() const
returns lower limit for VM (value multiplicity)
Definition: dcdicent.h:165
DcmTagKey upperKey
upper limit of repeating group and element (lower limit is inherited from DcmTagKey) ...
Definition: dcdicent.h:377
void setUpper(const DcmTagKey &key)
converts entry into repeating tag entry by defining an upper limit for group and element, taken from the given tag key.
Definition: dcdicent.h:201
each object of this class manages one entry of the global DICOM data dictionary.
Definition: dcdicent.h:65
Uint16 getGroup() const
returns group number
Definition: dctagkey.h:290
~DcmDictEntry()
destructor
int subset(const DcmDictEntry &e) const
checks if this entry describes a true subset of tag range described by the given entry.
Definition: dcdicent.h:340
int privateCreatorMatch(const DcmDictEntry &arg) const
checks if the private creator code of this object matches the one of the given object.
Definition: dcdicent.h:159
DcmVR valueRepresentation
value representation
Definition: dcdicent.h:380
DcmDictEntry(Uint16 g, Uint16 e, DcmVR vr, const char *nam, int vmMin, int vmMax, const char *vers, OFBool doCopyStrings, const char *pcreator)
constructor
DcmDictEntry & operator=(const DcmDictEntry &)
private undefined copy assignment operator
friend STD_NAMESPACE ostream & operator<<(STD_NAMESPACE ostream &s, const DcmDictEntry &e)
friend operator<<
const char * tagName
attribute name
Definition: dcdicent.h:383
DcmTagKey getKey() const
returns attribute tag as DcmTagKey object by value
Definition: dcdicent.h:237
a class representing a DICOM Value Representation
Definition: dcvr.h:193
int isRepeatingGroup() const
returns true if entry is has a repeating group
Definition: dcdicent.h:249
DcmEVR getEVR() const
returns VR code
Definition: dcdicent.h:118
int valueMultiplicityMax
upper limit for VM
Definition: dcdicent.h:389
int isRepeatingElement() const
returns true if entry is has a repeating element
Definition: dcdicent.h:255
DcmDictRangeRestriction elementRangeRestriction
restriction (even, odd, unrestricted) for element range
Definition: dcdicent.h:401
void setGroup(Uint16 g)
set group to given number
Definition: dctagkey.h:278
const char * getPrivateCreator() const
returns private creator code, may be NULL
Definition: dcdicent.h:136
const char * getStandardVersion() const
returns standard version string, may be NULL
Definition: dcdicent.h:124
Uint16 getUpperElement() const
returns upper limit for tag element
Definition: dcdicent.h:231
void setUpperElement(Uint16 ue)
converts entry into repeating tag entry by defining an upper limit for tag element ...
Definition: dcdicent.h:219
int isRepeating() const
returns true if entry is repeating (group or element)
Definition: dcdicent.h:261
int setEQ(const DcmDictEntry &e) const
checks if this entry describes the same tag range as the given entry.
Definition: dcdicent.h:354
DcmDictRangeRestriction getElementRangeRestriction() const
returns element range restriction
Definition: dcdicent.h:279
int valueMultiplicityMin
lower limit for VM
Definition: dcdicent.h:386
void setElement(Uint16 e)
set element to given number
Definition: dctagkey.h:284
const char * standardVersion
standard version name, may be NULL
Definition: dcdicent.h:392
int getVMMax() const
returns upper limit for VM (value multiplicity), DcmVariableVM for unlimited
Definition: dcdicent.h:171
const char * getTagName() const
returns tag name
Definition: dcdicent.h:130
DcmEVR getEVR() const
get enumerated VR managed by this object
Definition: dcvr.h:257
int contains(const DcmTagKey &key, const char *privCreator) const
checks if the given tag key and private creator code are covered by this object.
Definition: dcdicent.h:298
const char * privateCreator
private creator name, may be NULL
Definition: dcdicent.h:404
DcmTagKey getUpperKey() const
returns upper limits for attribute tag as DcmTagKey object by value
Definition: dcdicent.h:243
void setGroupRangeRestriction(DcmDictRangeRestriction rr)
sets group range restriction
Definition: dcdicent.h:273
OFBool isVariableRangeVM() const
returns true if element has a variable VM range (no upper limit)
Definition: dcdicent.h:191
void setUpperGroup(Uint16 ug)
converts entry into repeating tag entry by defining an upper limit for tag group
Definition: dcdicent.h:210
DcmDictRangeRestriction getGroupRangeRestriction() const
returns group range restriction
Definition: dcdicent.h:267
void setElementRangeRestriction(DcmDictRangeRestriction rr)
sets element range restriction
Definition: dcdicent.h:285
int contains(const char *name) const
checks if this entry contains the given name
Definition: dcdicent.h:328


Generated on Wed Jan 4 2017 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.6