dctagkey.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: Basis class for dicom tags.
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:28:45 $
00026  *  CVS/RCS Revision: $Revision: 1.16 $
00027  *  Status:           $State: Exp $
00028  *
00029  *  CVS/RCS Log at end of file
00030  *
00031  */
00032 
00033 #ifndef DCMTAGKEY_H
00034 #define DCMTAGKEY_H 1
00035 
00036 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00037 
00038 #include "dcmtk/ofstd/ofstream.h"
00039 #include "dcmtk/dcmdata/dctypes.h"
00040 #include "dcmtk/ofstd/ofstring.h"
00041 
00042 /*
00043 ** Defines
00044 */
00045 
00046 #define DCM_UndefinedTagKey     DcmTagKey(0xffff, 0xffff)
00047 
00048 
00049 /*
00050  * Unique key generation for DICOM tags
00051  */
00052 
00053 class DcmTagKey {
00054 private:
00055     Uint16 group;
00056     Uint16 element;
00057 
00058 protected:
00059     int groupLT(const DcmTagKey& key) const;
00060     int groupGT(const DcmTagKey& key) const;
00061     int groupEQ(const DcmTagKey& key) const;
00062     int elementLT(const DcmTagKey& key) const;
00063     int elementGT(const DcmTagKey& key) const;
00064     int elementEQ(const DcmTagKey& key) const;
00065 
00066 public:
00067     DcmTagKey();
00068     DcmTagKey(const DcmTagKey& key);
00069     DcmTagKey(Uint16 g, Uint16 e);
00070 
00071     void set(const DcmTagKey& key);
00072     void set(Uint16 g, Uint16 e);
00073     void setGroup(Uint16 g);
00074     void setElement(Uint16 e);
00075     Uint16 getGroup() const;
00076     Uint16 getElement() const;
00077 
00078     Uint32 hash() const; // generate simple hash code
00079 
00080     DcmTagKey& operator = (const DcmTagKey& key);
00081     int operator == (const DcmTagKey& key) const;
00082     int operator != (const DcmTagKey& key) const;
00083     int operator < (const DcmTagKey& key) const;
00084     int operator > (const DcmTagKey& key) const;
00085     int operator <= (const DcmTagKey& key) const;
00086     int operator >= (const DcmTagKey& key) const;
00087 
00088     friend ostream& operator<<(ostream& s, const DcmTagKey& k);
00089 
00090     OFString toString() const;
00091 
00096     OFBool isSignableTag() const;
00097 };
00098 
00104 ostream& operator<<(ostream& s, const DcmTagKey& k);
00105 
00106 /*
00107 ** inline versions of functions
00108 */
00109 
00110 /* Constructors */
00111 
00112 inline
00113 DcmTagKey::DcmTagKey()
00114   : group(0xffff),
00115     element(0xffff)
00116 {
00117 }
00118 
00119 inline
00120 DcmTagKey::DcmTagKey(const DcmTagKey& key)
00121   : group(key.group),
00122     element(key.element)
00123 {
00124 }
00125 
00126 inline
00127 DcmTagKey::DcmTagKey(Uint16 g, Uint16 e)
00128   : group(g),
00129     element(e)
00130 {
00131 }
00132 
00133 /* access methods */
00134 
00135 inline void
00136 DcmTagKey::set(const DcmTagKey& key)
00137 {
00138     group = key.group;
00139     element = key.element;
00140 }
00141 
00142 inline void
00143 DcmTagKey::set(Uint16 g, Uint16 e)
00144 {
00145     group = g;
00146     element = e;
00147 }
00148 
00149 inline void
00150 DcmTagKey::setGroup(Uint16 g)
00151 {
00152     group = g;
00153 }
00154 
00155 inline void
00156 DcmTagKey::setElement(Uint16 e)
00157 {
00158     element = e;
00159 }
00160 
00161 inline Uint16
00162 DcmTagKey::getGroup() const
00163 {
00164     return group;
00165 }
00166 
00167 inline Uint16
00168 DcmTagKey::getElement() const
00169 {
00170     return element;
00171 }
00172 
00173 inline DcmTagKey&
00174 DcmTagKey::operator=(const DcmTagKey& key)
00175 {
00176     set(key);
00177     return *this;
00178 }
00179 
00180 /* Simple Hash Function */
00181 
00182 inline Uint32
00183 DcmTagKey::hash() const
00184 {
00185     // generate simple hash code
00186     return (((getGroup() << 16) & 0xffff0000) | (getElement() & 0xffff));
00187 }
00188 
00189 /* Comparisons */
00190 
00191 inline int
00192 DcmTagKey::groupLT(const DcmTagKey& key) const
00193 {
00194     return (getGroup() < key.getGroup());
00195 }
00196 
00197 inline int
00198 DcmTagKey::groupGT(const DcmTagKey& key) const
00199 {
00200     return (getGroup() > key.getGroup());
00201 }
00202 
00203 inline int
00204 DcmTagKey::groupEQ(const DcmTagKey& key) const
00205 {
00206     return getGroup() == key.getGroup();
00207 }
00208 
00209 inline int
00210 DcmTagKey::elementLT(const DcmTagKey& key) const
00211 {
00212     return (getElement() < key.getElement());
00213 }
00214 
00215 inline int
00216 DcmTagKey::elementGT(const DcmTagKey& key) const
00217 {
00218     return (getElement() > key.getElement());
00219 }
00220 
00221 inline int
00222 DcmTagKey::elementEQ(const DcmTagKey& key) const
00223 {
00224     return getElement() == key.getElement();
00225 }
00226 
00227 inline int
00228 DcmTagKey::operator == (const DcmTagKey& key) const
00229 {
00230     return ( groupEQ(key) && elementEQ(key) );
00231 }
00232 
00233 inline int
00234 DcmTagKey::operator != (const DcmTagKey& key) const
00235 {
00236     return !(*this == key);
00237 }
00238 
00239 inline int
00240 DcmTagKey::operator < (const DcmTagKey& key) const
00241 {
00242     return (groupLT(key) || (groupEQ(key) && elementLT(key)));
00243 }
00244 
00245 inline int
00246 DcmTagKey::operator > (const DcmTagKey& key) const
00247 {
00248     return (groupGT(key) || (groupEQ(key) && elementGT(key)));
00249 }
00250 
00251 inline int
00252 DcmTagKey::operator <= (const DcmTagKey& key) const
00253 {
00254     return (*this < key) || (*this == key);
00255 }
00256 
00257 inline int
00258 DcmTagKey::operator >= (const DcmTagKey& key) const
00259 {
00260     return (*this > key) || (*this == key);
00261 }
00262 
00263 #endif
00264 
00265 
00266 /*
00267 ** CVS/RCS Log:
00268 ** $Log: dctagkey.h,v $
00269 ** Revision 1.16  2005/12/08 16:28:45  meichel
00270 ** Changed include path schema for all DCMTK header files
00271 **
00272 ** Revision 1.15  2004/01/16 14:08:00  joergr
00273 ** Removed acknowledgements with e-mail addresses from CVS log.
00274 **
00275 ** Revision 1.14  2003/11/13 14:06:36  meichel
00276 ** Fixed definition of DCM_UndefinedTagKey
00277 **
00278 ** Revision 1.13  2003/11/05 15:56:31  meichel
00279 ** Added declaration of operator<< for DcmTagKeys.
00280 **   Fixes compilation issue on Visual C++ 6.0 SP 0.
00281 **
00282 ** Revision 1.12  2002/04/16 13:41:44  joergr
00283 ** Added configurable support for C++ ANSI standard includes (e.g. streams).
00284 **
00285 ** Revision 1.11  2001/11/19 15:23:11  meichel
00286 ** Cleaned up signature code to avoid some gcc warnings.
00287 **
00288 ** Revision 1.10  2001/11/16 15:54:40  meichel
00289 ** Adapted digital signature code to final text of supplement 41.
00290 **
00291 ** Revision 1.9  2001/06/01 15:48:45  meichel
00292 ** Updated copyright header
00293 **
00294 ** Revision 1.8  2000/11/07 16:56:10  meichel
00295 ** Initial release of dcmsign module for DICOM Digital Signatures
00296 **
00297 ** Revision 1.7  2000/03/08 16:26:19  meichel
00298 ** Updated copyright header.
00299 **
00300 ** Revision 1.6  2000/02/07 14:45:16  meichel
00301 ** Removed const qualifier from DcmTagKey::toString(), avoids warning on Irix.
00302 **
00303 ** Revision 1.5  1999/03/31 09:24:49  meichel
00304 ** Updated copyright header in module dcmdata
00305 **
00306 ** Revision 1.4  1999/03/17 11:08:54  meichel
00307 ** added method DcmTagKey::toString()
00308 **
00309 ** Revision 1.3  1998/07/15 15:48:54  joergr
00310 ** Removed several compiler warnings reported by gcc 2.8.1 with
00311 ** additional options, e.g. missing copy constructors and assignment
00312 ** operators, initialization of member variables in the body of a
00313 ** constructor instead of the member initialization list, hiding of
00314 ** methods by use of identical names, uninitialized member variables,
00315 ** missing const declaration of char pointers. Replaced tabs by spaces.
00316 **
00317 ** Revision 1.2  1997/08/26 13:45:54  hewett
00318 ** Added simple hash function method.
00319 **
00320 ** Revision 1.1  1995/11/23 16:38:04  hewett
00321 ** Updated for loadable data dictionary + some cleanup (more to do).
00322 **
00323 */


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