dcdicent.h

00001 /*
00002  *
00003  *  Copyright (C) 1994-2005, OFFIS
00004  *
00005  *  This software and supporting documentation were developed by
00006  *
00007  *    Kuratorium OFFIS e.V.
00008  *    Healthcare Information and Communication Systems
00009  *    Escherweg 2
00010  *    D-26121 Oldenburg, Germany
00011  *
00012  *  THIS SOFTWARE IS MADE AVAILABLE,  AS IS,  AND OFFIS MAKES NO  WARRANTY
00013  *  REGARDING  THE  SOFTWARE,  ITS  PERFORMANCE,  ITS  MERCHANTABILITY  OR
00014  *  FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES  OR
00015  *  ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
00016  *  PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
00017  *
00018  *  Module:  dcmdata
00019  *
00020  *  Author:  Andrew Hewett
00021  *
00022  *  Purpose: Interface for a dictionary entry in the loadable DICOM data dictionary
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:28:08 $
00026  *  Source File:      $Source: /share/dicom/cvs-depot/dcmtk/dcmdata/include/dcmtk/dcmdata/dcdicent.h,v $
00027  *  CVS/RCS Revision: $Revision: 1.20 $
00028  *  Status:           $State: Exp $
00029  *
00030  *  CVS/RCS Log at end of file
00031  *
00032  */
00033 
00034 #ifndef DCDICENT_H
00035 #define DCDICENT_H
00036 
00037 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00038 #include "dcmtk/dcmdata/dctagkey.h"
00039 #include "dcmtk/dcmdata/dcvr.h"
00040 
00041 #define INCLUDE_CSTRING
00042 #include "dcmtk/ofstd/ofstdinc.h"
00043 
00045 #define DcmVariableVM   -1
00046 
00047 #define DCM_INRANGE(x,a,b) (((x) >= (a)) && ((x) <= (b)))
00048 #define DCM_IS_ODD(x) (((x) % 2) == 1)
00049 #define DCM_IS_EVEN(x) (((x) % 2) == 0)
00050 
00051 
00054 enum DcmDictRangeRestriction
00055 {
00057     DcmDictRange_Unspecified,
00058 
00060     DcmDictRange_Odd,
00061 
00063     DcmDictRange_Even
00064 };
00065 
00066 
00070 class DcmDictEntry: public DcmTagKey
00071 {
00072 public:
00073 
00085     DcmDictEntry(Uint16 g, Uint16 e, DcmVR vr,
00086         const char* nam, int vmMin, int vmMax,
00087         const char* vers, OFBool doCopyStrings,
00088         const char* pcreator);
00089 
00103     DcmDictEntry(Uint16 g, Uint16 e, Uint16 ug, Uint16 ue, DcmVR vr,
00104         const char* nam, int vmMin, int vmMax,
00105         const char* vers, OFBool doCopyStrings,
00106         const char* pcreator);
00107 
00109     DcmDictEntry(const DcmDictEntry& e);
00110 
00112     ~DcmDictEntry();
00113 
00114     /* access methods */
00115 
00117     DcmVR getVR() const
00118     {
00119         return valueRepresentation;
00120     }
00121 
00123     DcmEVR getEVR() const
00124     {
00125         return valueRepresentation.getEVR();
00126     }
00127 
00129     const char* getStandardVersion() const
00130     {
00131         return standardVersion;
00132     }
00133 
00135     const char* getTagName() const
00136     {
00137         return tagName;
00138     }
00139 
00141     const char* getPrivateCreator() const
00142     {
00143         return privateCreator;
00144     }
00145 
00150     int privateCreatorMatch(const char *c) const
00151     {
00152       return
00153       (
00154         ((privateCreator == NULL) && (c == NULL)) ||
00155         (privateCreator && c && (0 == strcmp(privateCreator, c)))
00156       );
00157     }
00158 
00164     int privateCreatorMatch(const DcmDictEntry& arg) const
00165     {
00166       return privateCreatorMatch(arg.privateCreator);
00167     }
00168 
00170     int getVMMin() const
00171     {
00172         return valueMultiplicityMin;
00173     }
00174 
00176     int getVMMax() const
00177     {
00178         return valueMultiplicityMax;
00179     }
00180 
00182     OFBool isFixedSingleVM() const
00183     {
00184         return ((valueMultiplicityMin != DcmVariableVM) &&
00185                       (valueMultiplicityMin == valueMultiplicityMax));
00186     }
00187 
00189     OFBool isFixedRangeVM() const
00190     {
00191         return ((valueMultiplicityMin != DcmVariableVM) &&
00192                       (valueMultiplicityMax != DcmVariableVM));
00193     }
00194 
00196     OFBool isVariableRangeVM() const
00197     {
00198         return ((valueMultiplicityMin != DcmVariableVM) &&
00199                       (valueMultiplicityMax == DcmVariableVM));
00200     }
00201 
00206     void setUpper(const DcmTagKey& key)
00207     {
00208         upperKey = key;
00209     }
00210 
00215     void setUpperGroup(Uint16 ug)
00216     {
00217         upperKey.setGroup(ug);
00218     }
00219 
00224     void setUpperElement(Uint16 ue)
00225     {
00226         upperKey.setElement(ue);
00227     }
00228 
00230     Uint16 getUpperGroup() const
00231     {
00232         return upperKey.getGroup();
00233     }
00234 
00236     Uint16 getUpperElement() const
00237     {
00238         return upperKey.getElement();
00239     }
00240 
00242     DcmTagKey getKey() const
00243     {
00244         return * OFstatic_cast(const DcmTagKey *, this);
00245     }
00246 
00248     DcmTagKey getUpperKey() const
00249     {
00250         return upperKey;
00251     }
00252 
00254     int isRepeatingGroup() const
00255     {
00256         return (getGroup() != getUpperGroup());
00257     }
00258 
00260     int isRepeatingElement() const
00261     {
00262         return (getElement() != getUpperElement());
00263     }
00264 
00266     int isRepeating() const
00267     {
00268         return (isRepeatingGroup() || isRepeatingElement());
00269     }
00270 
00272     DcmDictRangeRestriction getGroupRangeRestriction() const
00273     {
00274         return groupRangeRestriction;
00275     }
00276 
00278     void setGroupRangeRestriction(DcmDictRangeRestriction rr)
00279     {
00280         groupRangeRestriction = rr;
00281     }
00282 
00284     DcmDictRangeRestriction getElementRangeRestriction() const
00285     {
00286         return elementRangeRestriction;
00287     }
00288 
00290     void setElementRangeRestriction(DcmDictRangeRestriction rr)
00291     {
00292         elementRangeRestriction = rr;
00293     }
00294 
00295     /* containment */
00296 
00303     int contains(const DcmTagKey& key, const char *privCreator) const /* this contains key */
00304     {
00305         if ((getGroupRangeRestriction() == DcmDictRange_Even) &&
00306             DCM_IS_ODD(key.getGroup()))
00307             return OFFalse;
00308         else if ((getGroupRangeRestriction() == DcmDictRange_Odd) &&
00309             DCM_IS_EVEN(key.getGroup()))
00310             return OFFalse;
00311         else if ((getElementRangeRestriction() == DcmDictRange_Even) &&
00312             DCM_IS_ODD(key.getElement()))
00313             return OFFalse;
00314         else if ((getElementRangeRestriction() == DcmDictRange_Odd) &&
00315             DCM_IS_EVEN(key.getElement()))
00316             return OFFalse;
00317         else if (! privateCreatorMatch(privCreator))
00318             return OFFalse;
00319         else
00320         {
00321             return
00322                 DCM_INRANGE(key.getGroup(), getGroup(), getUpperGroup()) &&
00323                 DCM_INRANGE(key.getElement(), getElement(), getUpperElement());
00324         }
00325     }
00326 
00331     int contains(const char *name) const /* this contains named key */
00332     {
00333         return !strcmp( tagName, name );
00334     }
00335 
00336     /* set relations */
00337 
00343     int subset(const DcmDictEntry& e) const /* this is a subset of key */
00344     {
00345         return ( (getGroup() >= e.getGroup()) &&
00346                  (getUpperGroup() <= e.getUpperGroup()) &&
00347                  (getElement() >= e.getElement()) &&
00348                  (getUpperElement() <= e.getUpperElement()) &&
00349                  privateCreatorMatch(e.privateCreator)
00350             );
00351     }
00352 
00357     int setEQ(const DcmDictEntry& e) const /* this is set equal to key */
00358     {
00359         return ( (getGroup() == e.getGroup()) &&
00360                  (getUpperGroup() == e.getUpperGroup()) &&
00361                  (getElement() == e.getElement()) &&
00362                  (getUpperElement() == e.getUpperElement()) &&
00363                  (getGroupRangeRestriction() == e.getGroupRangeRestriction()) &&
00364                  (getElementRangeRestriction() == e.getElementRangeRestriction()) &&
00365                  privateCreatorMatch(e.privateCreator)
00366             );
00367     }
00368 
00370     friend ostream& operator<<(ostream& s, const DcmDictEntry& e);
00371 
00372 private:
00373 
00375     DcmDictEntry &operator=(const DcmDictEntry &);
00376 
00380     DcmTagKey upperKey;
00381 
00383     DcmVR valueRepresentation;
00384 
00386     const char *tagName;
00387 
00389     int valueMultiplicityMin;
00390 
00392     int valueMultiplicityMax;
00393 
00395     const char *standardVersion;
00396 
00398     OFBool stringsAreCopies;
00399 
00401     DcmDictRangeRestriction groupRangeRestriction;
00402 
00404     DcmDictRangeRestriction elementRangeRestriction;
00405 
00407     const char *privateCreator;
00408 };
00409 
00410 #endif /* !DCDICENT_H */
00411 
00412 
00413 /*
00414 ** CVS/RCS Log:
00415 ** $Log: dcdicent.h,v $
00416 ** Revision 1.20  2005/12/08 16:28:08  meichel
00417 ** Changed include path schema for all DCMTK header files
00418 **
00419 ** Revision 1.19  2004/01/16 14:07:03  joergr
00420 ** Removed acknowledgements with e-mail addresses from CVS log.
00421 **
00422 ** Revision 1.18  2003/08/14 09:00:56  meichel
00423 ** Adapted type casts to new-style typecast operators defined in ofcast.h
00424 **
00425 ** Revision 1.17  2002/11/27 12:07:21  meichel
00426 ** Adapted module dcmdata to use of new header file ofstdinc.h
00427 **
00428 ** Revision 1.16  2002/07/23 14:21:25  meichel
00429 ** Added support for private tag data dictionaries to dcmdata
00430 **
00431 ** Revision 1.15  2002/04/16 13:41:44  joergr
00432 ** Added configurable support for C++ ANSI standard includes (e.g. streams).
00433 **
00434 ** Revision 1.14  2001/06/01 15:48:36  meichel
00435 ** Updated copyright header
00436 **
00437 ** Revision 1.13  2000/03/08 16:26:13  meichel
00438 ** Updated copyright header.
00439 **
00440 ** Revision 1.12  1999/03/31 09:24:35  meichel
00441 ** Updated copyright header in module dcmdata
00442 **
00443 ** Revision 1.11  1998/07/15 15:48:45  joergr
00444 ** Removed several compiler warnings reported by gcc 2.8.1 with
00445 ** additional options, e.g. missing copy constructors and assignment
00446 ** operators, initialization of member variables in the body of a
00447 ** constructor instead of the member initialization list, hiding of
00448 ** methods by use of identical names, uninitialized member variables,
00449 ** missing const declaration of char pointers. Replaced tabs by spaces.
00450 **
00451 ** Revision 1.10  1997/08/26 13:44:59  hewett
00452 ** Modified constructors to take const parameters.
00453 **
00454 ** Revision 1.9  1997/07/31 14:40:35  meichel
00455 ** Created copy constructor for class DcmDictEntry, required by dcmcheck.
00456 **
00457 ** Revision 1.8  1997/07/21 08:25:07  andreas
00458 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
00459 **   with one unique boolean type OFBool.
00460 **
00461 ** Revision 1.7  1997/04/18 08:04:39  andreas
00462 ** - Minor corrections: correct some warnings of the SUN-C++ Compiler
00463 **   concerning the assignments of wrong types and inline compiler
00464 **   errors
00465 **
00466 ** Revision 1.6  1997/04/15 16:25:05  hewett
00467 ** Corrected data dictionary bug whereby the even/odd range restrictions
00468 ** were not being taken into consideration when searching the dictionary.
00469 **
00470 ** Revision 1.5  1996/09/24 16:24:58  hewett
00471 ** Added preliminary support for the Macintosh environment (GUSI library).
00472 **
00473 ** Revision 1.4  1996/09/18 16:37:09  hewett
00474 ** Added capability to search data dictionary by tag name.
00475 **
00476 ** Revision 1.3  1996/03/20 16:43:49  hewett
00477 ** Updated for revised data dictionary.  Repeating tags are now handled better.
00478 ** A linear list of repeating tags has been introduced with a subset ordering
00479 ** mechanism to ensure that dictionary searches locate the most precise
00480 ** dictionary entry.
00481 **
00482 */


Generated on 20 Dec 2005 for OFFIS DCMTK Version 3.5.4 by Doxygen 1.4.5