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 DCMTAGKEY_H
00030 #define DCMTAGKEY_H 1
00031
00032 #include "dcmtk/config/osconfig.h"
00033
00034 #include "dcmtk/ofstd/ofstream.h"
00035 #include "dcmtk/ofstd/ofstring.h"
00036
00037
00038
00039
00040
00042 #define DCM_UndefinedTagKey DcmTagKey(0xffff, 0xffff)
00043
00046 class DcmTagKey
00047 {
00048 public:
00049
00052 DcmTagKey();
00053
00057 DcmTagKey(const DcmTagKey& key);
00058
00063 DcmTagKey(Uint16 g, Uint16 e);
00064
00067 virtual ~DcmTagKey();
00068
00072 void set(const DcmTagKey& key);
00073
00078 void set(Uint16 g, Uint16 e);
00079
00083 void setGroup(Uint16 g);
00084
00088 void setElement(Uint16 e);
00089
00093 Uint16 getGroup() const;
00094
00098 Uint16 getElement() const;
00099
00104 OFBool isGroupLength() const;
00105
00110 OFBool isPrivate() const;
00111
00117 OFBool isPrivateReservation() const;
00118
00123 OFBool hasValidGroup() const;
00124
00129 Uint32 hash() const;
00130
00136 DcmTagKey& operator = (const DcmTagKey& key);
00137
00143 int operator == (const DcmTagKey& key) const;
00144
00150 int operator != (const DcmTagKey& key) const;
00151
00157 int operator < (const DcmTagKey& key) const;
00158
00164 int operator > (const DcmTagKey& key) const;
00165
00171 int operator <= (const DcmTagKey& key) const;
00172
00178 int operator >= (const DcmTagKey& key) const;
00179
00180 friend STD_NAMESPACE ostream& operator<<(STD_NAMESPACE ostream& s, const DcmTagKey& k);
00181
00185 OFString toString() const;
00186
00191 OFBool isSignableTag() const;
00192
00193 protected:
00194
00196 int groupLT(const DcmTagKey& key) const;
00197
00199 int groupGT(const DcmTagKey& key) const;
00200
00202 int groupEQ(const DcmTagKey& key) const;
00203
00205 int elementLT(const DcmTagKey& key) const;
00206
00208 int elementGT(const DcmTagKey& key) const;
00209
00211 int elementEQ(const DcmTagKey& key) const;
00212
00213 private:
00214
00216 Uint16 group;
00218 Uint16 element;
00219
00220 };
00221
00227 STD_NAMESPACE ostream& operator<<(STD_NAMESPACE ostream& s, const DcmTagKey& k);
00228
00229
00230
00231
00232
00233
00234
00235 inline
00236 DcmTagKey::DcmTagKey()
00237 : group(0xffff),
00238 element(0xffff)
00239 {
00240 }
00241
00242 inline
00243 DcmTagKey::DcmTagKey(const DcmTagKey& key)
00244 : group(key.group),
00245 element(key.element)
00246 {
00247 }
00248
00249 inline
00250 DcmTagKey::DcmTagKey(Uint16 g, Uint16 e)
00251 : group(g),
00252 element(e)
00253 {
00254 }
00255
00256 inline
00257 DcmTagKey::~DcmTagKey()
00258 {
00259 }
00260
00261
00262
00263 inline void
00264 DcmTagKey::set(const DcmTagKey& key)
00265 {
00266 group = key.group;
00267 element = key.element;
00268 }
00269
00270 inline void
00271 DcmTagKey::set(Uint16 g, Uint16 e)
00272 {
00273 group = g;
00274 element = e;
00275 }
00276
00277 inline void
00278 DcmTagKey::setGroup(Uint16 g)
00279 {
00280 group = g;
00281 }
00282
00283 inline void
00284 DcmTagKey::setElement(Uint16 e)
00285 {
00286 element = e;
00287 }
00288
00289 inline Uint16
00290 DcmTagKey::getGroup() const
00291 {
00292 return group;
00293 }
00294
00295 inline Uint16
00296 DcmTagKey::getElement() const
00297 {
00298 return element;
00299 }
00300
00301 inline OFBool
00302 DcmTagKey::isGroupLength() const
00303 {
00304 return (element == 0) && hasValidGroup();
00305 }
00306
00307 inline OFBool
00308 DcmTagKey::isPrivate() const
00309 {
00310 return ((group & 1) != 0 ) && hasValidGroup();
00311 }
00312
00313 inline OFBool
00314 DcmTagKey::isPrivateReservation() const
00315 {
00316
00317 return isPrivate() && (element >= 0x10) && (element <= 0xFF);
00318 }
00319
00320 inline OFBool
00321 DcmTagKey::hasValidGroup() const
00322 {
00323
00324 if (((group & 1) != 0) && ((group <= 7) || (group == 0xFFFF)))
00325 return OFFalse;
00326 else
00327 return OFTrue;
00328 }
00329
00330 inline DcmTagKey&
00331 DcmTagKey::operator=(const DcmTagKey& key)
00332 {
00333 set(key);
00334 return *this;
00335 }
00336
00337
00338
00339 inline Uint32
00340 DcmTagKey::hash() const
00341 {
00342
00343 return (((getGroup() << 16) & 0xffff0000) | (getElement() & 0xffff));
00344 }
00345
00346
00347
00348 inline int
00349 DcmTagKey::groupLT(const DcmTagKey& key) const
00350 {
00351 return (getGroup() < key.getGroup());
00352 }
00353
00354 inline int
00355 DcmTagKey::groupGT(const DcmTagKey& key) const
00356 {
00357 return (getGroup() > key.getGroup());
00358 }
00359
00360 inline int
00361 DcmTagKey::groupEQ(const DcmTagKey& key) const
00362 {
00363 return getGroup() == key.getGroup();
00364 }
00365
00366 inline int
00367 DcmTagKey::elementLT(const DcmTagKey& key) const
00368 {
00369 return (getElement() < key.getElement());
00370 }
00371
00372 inline int
00373 DcmTagKey::elementGT(const DcmTagKey& key) const
00374 {
00375 return (getElement() > key.getElement());
00376 }
00377
00378 inline int
00379 DcmTagKey::elementEQ(const DcmTagKey& key) const
00380 {
00381 return getElement() == key.getElement();
00382 }
00383
00384 inline int
00385 DcmTagKey::operator == (const DcmTagKey& key) const
00386 {
00387 return ( groupEQ(key) && elementEQ(key) );
00388 }
00389
00390 inline int
00391 DcmTagKey::operator != (const DcmTagKey& key) const
00392 {
00393 return !(*this == key);
00394 }
00395
00396 inline int
00397 DcmTagKey::operator < (const DcmTagKey& key) const
00398 {
00399 return (groupLT(key) || (groupEQ(key) && elementLT(key)));
00400 }
00401
00402 inline int
00403 DcmTagKey::operator > (const DcmTagKey& key) const
00404 {
00405 return (groupGT(key) || (groupEQ(key) && elementGT(key)));
00406 }
00407
00408 inline int
00409 DcmTagKey::operator <= (const DcmTagKey& key) const
00410 {
00411 return (*this < key) || (*this == key);
00412 }
00413
00414 inline int
00415 DcmTagKey::operator >= (const DcmTagKey& key) const
00416 {
00417 return (*this > key) || (*this == key);
00418 }
00419
00420 #endif
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
00500
00501
00502
00503
00504