dcdict.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 loadable DICOM data dictionary
00023  *
00024  *  Last Update:      $Author: meichel $
00025  *  Update Date:      $Date: 2005/12/08 16:28:09 $
00026  *  CVS/RCS Revision: $Revision: 1.20 $
00027  *  Status:           $State: Exp $
00028  *
00029  *  CVS/RCS Log at end of file
00030  *
00031  */
00032 
00033 #ifndef DCMDICT_H
00034 #define DCMDICT_H
00035 
00036 #include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */
00037 #include "dcmtk/dcmdata/dchashdi.h"
00038 #include "dcmtk/ofstd/ofthread.h"
00039 
00041 #define DCM_MAXDICTLINESIZE     2048
00042 
00044 #define DCM_MAXDICTFIELDS       6
00045 
00047 #define DCM_DICT_ENVIRONMENT_VARIABLE   "DCMDICTPATH"
00048 
00049 #ifndef DCM_DICT_DEFAULT_PATH
00050 /*
00051 ** The default dictionary path is system dependent.  It should
00052 ** be defined in a configuration file included from "osconfig.h"
00053 */
00054 #error "DCM_DICT_DEFAULT_PATH is not defined via osconfig.h"
00055 #endif /* !DCM_DICT_DEFAULT_PATH */
00056 
00057 #ifndef ENVIRONMENT_PATH_SEPARATOR
00058 #define ENVIRONMENT_PATH_SEPARATOR '\n' /* at least define something unlikely */
00059 #endif
00060 
00061 
00064 class DcmDataDictionary
00065 {
00066 public:
00067 
00074     DcmDataDictionary(OFBool loadBuiltin, OFBool loadExternal);
00075 
00077     ~DcmDataDictionary();
00078 
00082     OFBool isDictionaryLoaded() const { return dictionaryLoaded; }
00083 
00085     int numberOfNormalTagEntries() const { return hashDict.size(); }
00086 
00088     int numberOfRepeatingTagEntries() const { return repDict.size(); }
00089 
00093     int numberOfEntries() const
00094         { return numberOfNormalTagEntries()
00095               + numberOfRepeatingTagEntries() - skeletonCount; }
00096 
00102     int numberOfSkeletonEntries() const { return skeletonCount; }
00103 
00111     OFBool loadDictionary(const char* fileName, OFBool errorIfAbsent=OFTrue);
00112 
00119     const DcmDictEntry* findEntry(const DcmTagKey& key, const char *privCreator) const;
00120 
00127     const DcmDictEntry* findEntry(const char *name) const;
00128 
00130     void clear();
00131 
00139     void addEntry(DcmDictEntry* entry);
00140 
00141     /* Iterators to access the normal and the repeating entries */
00142 
00144     DcmHashDictIterator normalBegin() { return hashDict.begin(); }
00145 
00147     DcmHashDictIterator normalEnd() { return hashDict.end(); }
00148 
00150     DcmDictEntryListIterator repeatingBegin() { return repDict.begin(); }
00151 
00153     DcmDictEntryListIterator repeatingEnd() { return repDict.end(); }
00154 
00155 private:
00156 
00159     DcmDataDictionary &operator=(const DcmDataDictionary &);
00160 
00163     DcmDataDictionary(const DcmDataDictionary &);
00164 
00168     OFBool loadExternalDictionaries();
00169 
00174     void loadBuiltinDictionary();
00175 
00179     OFBool loadSkeletonDictionary();
00180 
00184     const DcmDictEntry* findEntry(const DcmDictEntry& entry) const;
00185 
00188     void deleteEntry(const DcmDictEntry& entry);
00189 
00190 
00193     DcmHashDict hashDict;
00194 
00197     DcmDictEntryList repDict;
00198 
00201     int skeletonCount;
00202 
00205     OFBool dictionaryLoaded;
00206 
00207 };
00208 
00209 
00216 class GlobalDcmDataDictionary
00217 {
00218 public:
00223   GlobalDcmDataDictionary(OFBool loadBuiltin, OFBool loadExternal);
00224 
00227   ~GlobalDcmDataDictionary();
00228 
00233   const DcmDataDictionary& rdlock();
00234 
00239   DcmDataDictionary& wrlock();
00240 
00243   void unlock();
00244 
00250   OFBool isDictionaryLoaded();
00251 
00257   void clear();
00258 
00259 private:
00262   GlobalDcmDataDictionary &operator=(const GlobalDcmDataDictionary &);
00263 
00266   GlobalDcmDataDictionary(const GlobalDcmDataDictionary &);
00267 
00270   DcmDataDictionary dataDict;
00271 
00272 #ifdef _REENTRANT
00273 
00275   OFReadWriteLock dataDictLock;
00276 #endif
00277 };
00278 
00279 
00291 extern GlobalDcmDataDictionary dcmDataDict;
00292 
00293 #endif
00294 
00295 
00296 /*
00297 ** CVS/RCS Log:
00298 ** $Log: dcdict.h,v $
00299 ** Revision 1.20  2005/12/08 16:28:09  meichel
00300 ** Changed include path schema for all DCMTK header files
00301 **
00302 ** Revision 1.19  2004/01/16 14:07:27  joergr
00303 ** Removed acknowledgements with e-mail addresses from CVS log.
00304 **
00305 ** Revision 1.18  2002/07/23 14:21:25  meichel
00306 ** Added support for private tag data dictionaries to dcmdata
00307 **
00308 ** Revision 1.17  2002/02/27 14:21:20  meichel
00309 ** Declare dcmdata read/write locks only when compiled in multi-thread mode
00310 **
00311 ** Revision 1.16  2001/06/01 15:48:38  meichel
00312 ** Updated copyright header
00313 **
00314 ** Revision 1.15  2000/05/03 14:19:08  meichel
00315 ** Added new class GlobalDcmDataDictionary which implements read/write lock
00316 **   semantics for safe access to the DICOM dictionary from multiple threads
00317 **   in parallel. The global dcmDataDict now uses this class.
00318 **
00319 ** Revision 1.14  2000/03/08 16:26:13  meichel
00320 ** Updated copyright header.
00321 **
00322 ** Revision 1.13  1999/03/31 09:24:35  meichel
00323 ** Updated copyright header in module dcmdata
00324 **
00325 ** Revision 1.12  1998/07/15 15:48:45  joergr
00326 ** Removed several compiler warnings reported by gcc 2.8.1 with
00327 ** additional options, e.g. missing copy constructors and assignment
00328 ** operators, initialization of member variables in the body of a
00329 ** constructor instead of the member initialization list, hiding of
00330 ** methods by use of identical names, uninitialized member variables,
00331 ** missing const declaration of char pointers. Replaced tabs by spaces.
00332 **
00333 ** Revision 1.11  1997/08/26 14:02:56  hewett
00334 ** New data structures for data-dictionary.  The main part of the
00335 ** data-dictionary is now stored in an hash table using an optimized
00336 ** hash function.  This new data structure reduces data-dictionary
00337 ** load times by a factor of 4!  he data-dictionary specific linked-list
00338 ** has been replaced by a linked list derived from OFList class
00339 ** (see ofstd/include/oflist.h).
00340 ** The only interface modifications are related to iterating over the entire
00341 ** data dictionary which should not be needed by "normal" applications.
00342 **
00343 ** Revision 1.10  1997/07/21 08:25:07  andreas
00344 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
00345 **   with one unique boolean type OFBool.
00346 **
00347 ** Revision 1.9  1997/05/22 13:15:54  hewett
00348 ** Added method DcmDataDictionary::isDictionaryLoaded() to ask if a full
00349 ** data dictionary has been loaded.  This method should be used in tests
00350 ** rather that querying the number of entries (a sekelton dictionary is
00351 ** now always present).
00352 **
00353 ** Revision 1.8  1997/05/13 13:58:41  hewett
00354 ** Added member function (loadSkeletomDictionary) to preload of a few
00355 ** essential attribute descriptions into the data dictionary (e.g. Item
00356 ** and ItemDelimitation tags).
00357 **
00358 ** Revision 1.7  1996/09/18 16:37:10  hewett
00359 ** Added capability to search data dictionary by tag name.
00360 **
00361 ** Revision 1.6  1996/03/22 13:09:12  hewett
00362 ** Moved the definition of DCM_DICT_DEFAULT_PATH to the system
00363 ** dependent configuration files included via "osconfig.h".
00364 **
00365 ** Revision 1.5  1996/03/21 09:50:38  hewett
00366 ** Added a  method numberOfEntries() to return the total number of
00367 ** dictionary entries.
00368 **
00369 ** Revision 1.4  1996/03/20 16:43:49  hewett
00370 ** Updated for revised data dictionary.  Repeating tags are now handled better.
00371 ** A linear list of repeating tags has been introduced with a subset ordering
00372 ** mechanism to ensure that dictionary searches locate the most precise
00373 ** dictionary entry.
00374 **
00375 */
00376 


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