00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef DCDICENT_H
00030 #define DCDICENT_H
00031
00032 #include "dcmtk/config/osconfig.h"
00033 #include "dcmtk/dcmdata/dctagkey.h"
00034 #include "dcmtk/dcmdata/dcvr.h"
00035
00036 #define INCLUDE_CSTRING
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
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
00291
00298 int contains(const DcmTagKey& key, const char *privCreator) const
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
00329 {
00330 return !strcmp( tagName, name );
00331 }
00332
00333
00334
00340 int subset(const DcmDictEntry& e) const
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
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
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499