00001 /* 00002 * 00003 * Copyright (C) 1994-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmdata 00015 * 00016 * Author: Andrew Hewett 00017 * 00018 * Purpose: Interface for a dictionary entry in the loadable DICOM data dictionary 00019 * 00020 * Last Update: $Author: meichel $ 00021 * Update Date: $Date: 2010-11-17 15:17:51 $ 00022 * CVS/RCS Revision: $Revision: 1.26 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 #ifndef DCDICENT_H 00030 #define DCDICENT_H 00031 00032 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 00033 #include "dcmtk/dcmdata/dctagkey.h" 00034 #include "dcmtk/dcmdata/dcvr.h" 00035 00036 #define INCLUDE_CSTRING /* for strcmp() */ 00037 #include "dcmtk/ofstd/ofstdinc.h" 00038 00040 #define DcmVariableVM -1 00041 00042 #define DCM_INRANGE(x,a,b) (((x) >= (a)) && ((x) <= (b))) 00043 #define DCM_IS_ODD(x) (((x) % 2) == 1) 00044 #define DCM_IS_EVEN(x) (((x) % 2) == 0) 00045 00046 00049 enum DcmDictRangeRestriction 00050 { 00052 DcmDictRange_Unspecified, 00053 00055 DcmDictRange_Odd, 00056 00058 DcmDictRange_Even 00059 }; 00060 00061 00065 class DcmDictEntry: public DcmTagKey 00066 { 00067 public: 00068 00080 DcmDictEntry(Uint16 g, Uint16 e, DcmVR vr, 00081 const char* nam, int vmMin, int vmMax, 00082 const char* vers, OFBool doCopyStrings, 00083 const char* pcreator); 00084 00098 DcmDictEntry(Uint16 g, Uint16 e, Uint16 ug, Uint16 ue, DcmVR vr, 00099 const char* nam, int vmMin, int vmMax, 00100 const char* vers, OFBool doCopyStrings, 00101 const char* pcreator); 00102 00104 DcmDictEntry(const DcmDictEntry& e); 00105 00107 ~DcmDictEntry(); 00108 00109 /* access methods */ 00110 00112 DcmVR getVR() const 00113 { 00114 return valueRepresentation; 00115 } 00116 00118 DcmEVR getEVR() const 00119 { 00120 return valueRepresentation.getEVR(); 00121 } 00122 00124 const char* getStandardVersion() const 00125 { 00126 return standardVersion; 00127 } 00128 00130 const char* getTagName() const 00131 { 00132 return tagName; 00133 } 00134 00136 const char* getPrivateCreator() const 00137 { 00138 return privateCreator; 00139 } 00140 00145 int privateCreatorMatch(const char *c) const 00146 { 00147 return 00148 ( 00149 ((privateCreator == NULL) && (c == NULL)) || 00150 (privateCreator && c && (0 == strcmp(privateCreator, c))) 00151 ); 00152 } 00153 00159 int privateCreatorMatch(const DcmDictEntry& arg) const 00160 { 00161 return privateCreatorMatch(arg.privateCreator); 00162 } 00163 00165 int getVMMin() const 00166 { 00167 return valueMultiplicityMin; 00168 } 00169 00171 int getVMMax() const 00172 { 00173 return valueMultiplicityMax; 00174 } 00175 00177 OFBool isFixedSingleVM() const 00178 { 00179 return ((valueMultiplicityMin != DcmVariableVM) && 00180 (valueMultiplicityMin == valueMultiplicityMax)); 00181 } 00182 00184 OFBool isFixedRangeVM() const 00185 { 00186 return ((valueMultiplicityMin != DcmVariableVM) && 00187 (valueMultiplicityMax != DcmVariableVM)); 00188 } 00189 00191 OFBool isVariableRangeVM() const 00192 { 00193 return ((valueMultiplicityMin != DcmVariableVM) && 00194 (valueMultiplicityMax == DcmVariableVM)); 00195 } 00196 00201 void setUpper(const DcmTagKey& key) 00202 { 00203 upperKey = key; 00204 } 00205 00210 void setUpperGroup(Uint16 ug) 00211 { 00212 upperKey.setGroup(ug); 00213 } 00214 00219 void setUpperElement(Uint16 ue) 00220 { 00221 upperKey.setElement(ue); 00222 } 00223 00225 Uint16 getUpperGroup() const 00226 { 00227 return upperKey.getGroup(); 00228 } 00229 00231 Uint16 getUpperElement() const 00232 { 00233 return upperKey.getElement(); 00234 } 00235 00237 DcmTagKey getKey() const 00238 { 00239 return * OFstatic_cast(const DcmTagKey *, this); 00240 } 00241 00243 DcmTagKey getUpperKey() const 00244 { 00245 return upperKey; 00246 } 00247 00249 int isRepeatingGroup() const 00250 { 00251 return (getGroup() != getUpperGroup()); 00252 } 00253 00255 int isRepeatingElement() const 00256 { 00257 return (getElement() != getUpperElement()); 00258 } 00259 00261 int isRepeating() const 00262 { 00263 return (isRepeatingGroup() || isRepeatingElement()); 00264 } 00265 00267 DcmDictRangeRestriction getGroupRangeRestriction() const 00268 { 00269 return groupRangeRestriction; 00270 } 00271 00273 void setGroupRangeRestriction(DcmDictRangeRestriction rr) 00274 { 00275 groupRangeRestriction = rr; 00276 } 00277 00279 DcmDictRangeRestriction getElementRangeRestriction() const 00280 { 00281 return elementRangeRestriction; 00282 } 00283 00285 void setElementRangeRestriction(DcmDictRangeRestriction rr) 00286 { 00287 elementRangeRestriction = rr; 00288 } 00289 00290 /* containment */ 00291 00298 int contains(const DcmTagKey& key, const char *privCreator) const /* this contains key */ 00299 { 00300 if ((getGroupRangeRestriction() == DcmDictRange_Even) && 00301 DCM_IS_ODD(key.getGroup())) 00302 return OFFalse; 00303 else if ((getGroupRangeRestriction() == DcmDictRange_Odd) && 00304 DCM_IS_EVEN(key.getGroup())) 00305 return OFFalse; 00306 else if ((getElementRangeRestriction() == DcmDictRange_Even) && 00307 DCM_IS_ODD(key.getElement())) 00308 return OFFalse; 00309 else if ((getElementRangeRestriction() == DcmDictRange_Odd) && 00310 DCM_IS_EVEN(key.getElement())) 00311 return OFFalse; 00312 else if (! privateCreatorMatch(privCreator)) 00313 return OFFalse; 00314 else 00315 { 00316 const OFBool groupMatches=DCM_INRANGE(key.getGroup(), getGroup(), getUpperGroup()); 00317 OFBool found=groupMatches && DCM_INRANGE(key.getElement(), getElement(), getUpperElement()); 00318 if (!found && groupMatches && privCreator) 00319 found=DCM_INRANGE(key.getElement() & 0xFF, getElement(), getUpperElement()); 00320 return found; 00321 } 00322 } 00323 00328 int contains(const char *name) const /* this contains named key */ 00329 { 00330 return !strcmp( tagName, name ); 00331 } 00332 00333 /* set relations */ 00334 00340 int subset(const DcmDictEntry& e) const /* this is a subset of key */ 00341 { 00342 return ( (getGroup() >= e.getGroup()) && 00343 (getUpperGroup() <= e.getUpperGroup()) && 00344 (getElement() >= e.getElement()) && 00345 (getUpperElement() <= e.getUpperElement()) && 00346 privateCreatorMatch(e.privateCreator) 00347 ); 00348 } 00349 00354 int setEQ(const DcmDictEntry& e) const /* this is set equal to key */ 00355 { 00356 return ( (getGroup() == e.getGroup()) && 00357 (getUpperGroup() == e.getUpperGroup()) && 00358 (getElement() == e.getElement()) && 00359 (getUpperElement() == e.getUpperElement()) && 00360 (getGroupRangeRestriction() == e.getGroupRangeRestriction()) && 00361 (getElementRangeRestriction() == e.getElementRangeRestriction()) && 00362 privateCreatorMatch(e.privateCreator) 00363 ); 00364 } 00365 00367 friend STD_NAMESPACE ostream& operator<<(STD_NAMESPACE ostream& s, const DcmDictEntry& e); 00368 00369 private: 00370 00372 DcmDictEntry &operator=(const DcmDictEntry &); 00373 00377 DcmTagKey upperKey; 00378 00380 DcmVR valueRepresentation; 00381 00383 const char *tagName; 00384 00386 int valueMultiplicityMin; 00387 00389 int valueMultiplicityMax; 00390 00392 const char *standardVersion; 00393 00395 OFBool stringsAreCopies; 00396 00398 DcmDictRangeRestriction groupRangeRestriction; 00399 00401 DcmDictRangeRestriction elementRangeRestriction; 00402 00404 const char *privateCreator; 00405 }; 00406 00407 #endif /* !DCDICENT_H */ 00408 00409 00410 /* 00411 ** CVS/RCS Log: 00412 ** $Log: dcdicent.h,v $ 00413 ** Revision 1.26 2010-11-17 15:17:51 meichel 00414 ** Fixed issue with data dictionary causing private tags with group number 00415 ** range and flexible element number not to be found in the dictionary. 00416 ** 00417 ** Revision 1.25 2010-10-14 13:15:40 joergr 00418 ** Updated copyright header. Added reference to COPYRIGHT file. 00419 ** 00420 ** Revision 1.24 2010-06-25 09:15:19 uli 00421 ** Fixed issues with compiling with HAVE_STD_STRING. 00422 ** 00423 ** Revision 1.23 2010-03-01 09:08:44 uli 00424 ** Removed some unnecessary include directives in the headers. 00425 ** 00426 ** Revision 1.22 2009-11-04 09:58:07 uli 00427 ** Switched to logging mechanism provided by the "new" oflog module 00428 ** 00429 ** Revision 1.21 2006-08-15 15:49:56 meichel 00430 ** Updated all code in module dcmdata to correctly compile when 00431 ** all standard C++ classes remain in namespace std. 00432 ** 00433 ** Revision 1.20 2005/12/08 16:28:08 meichel 00434 ** Changed include path schema for all DCMTK header files 00435 ** 00436 ** Revision 1.19 2004/01/16 14:07:03 joergr 00437 ** Removed acknowledgements with e-mail addresses from CVS log. 00438 ** 00439 ** Revision 1.18 2003/08/14 09:00:56 meichel 00440 ** Adapted type casts to new-style typecast operators defined in ofcast.h 00441 ** 00442 ** Revision 1.17 2002/11/27 12:07:21 meichel 00443 ** Adapted module dcmdata to use of new header file ofstdinc.h 00444 ** 00445 ** Revision 1.16 2002/07/23 14:21:25 meichel 00446 ** Added support for private tag data dictionaries to dcmdata 00447 ** 00448 ** Revision 1.15 2002/04/16 13:41:44 joergr 00449 ** Added configurable support for C++ ANSI standard includes (e.g. streams). 00450 ** 00451 ** Revision 1.14 2001/06/01 15:48:36 meichel 00452 ** Updated copyright header 00453 ** 00454 ** Revision 1.13 2000/03/08 16:26:13 meichel 00455 ** Updated copyright header. 00456 ** 00457 ** Revision 1.12 1999/03/31 09:24:35 meichel 00458 ** Updated copyright header in module dcmdata 00459 ** 00460 ** Revision 1.11 1998/07/15 15:48:45 joergr 00461 ** Removed several compiler warnings reported by gcc 2.8.1 with 00462 ** additional options, e.g. missing copy constructors and assignment 00463 ** operators, initialization of member variables in the body of a 00464 ** constructor instead of the member initialization list, hiding of 00465 ** methods by use of identical names, uninitialized member variables, 00466 ** missing const declaration of char pointers. Replaced tabs by spaces. 00467 ** 00468 ** Revision 1.10 1997/08/26 13:44:59 hewett 00469 ** Modified constructors to take const parameters. 00470 ** 00471 ** Revision 1.9 1997/07/31 14:40:35 meichel 00472 ** Created copy constructor for class DcmDictEntry, required by dcmcheck. 00473 ** 00474 ** Revision 1.8 1997/07/21 08:25:07 andreas 00475 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL) 00476 ** with one unique boolean type OFBool. 00477 ** 00478 ** Revision 1.7 1997/04/18 08:04:39 andreas 00479 ** - Minor corrections: correct some warnings of the SUN-C++ Compiler 00480 ** concerning the assignments of wrong types and inline compiler 00481 ** errors 00482 ** 00483 ** Revision 1.6 1997/04/15 16:25:05 hewett 00484 ** Corrected data dictionary bug whereby the even/odd range restrictions 00485 ** were not being taken into consideration when searching the dictionary. 00486 ** 00487 ** Revision 1.5 1996/09/24 16:24:58 hewett 00488 ** Added preliminary support for the Macintosh environment (GUSI library). 00489 ** 00490 ** Revision 1.4 1996/09/18 16:37:09 hewett 00491 ** Added capability to search data dictionary by tag name. 00492 ** 00493 ** Revision 1.3 1996/03/20 16:43:49 hewett 00494 ** Updated for revised data dictionary. Repeating tags are now handled better. 00495 ** A linear list of repeating tags has been introduced with a subset ordering 00496 ** mechanism to ensure that dictionary searches locate the most precise 00497 ** dictionary entry. 00498 ** 00499 */