OFFIS DCMTK  Version 3.6.0
dcdict.h
1 /*
2  *
3  * Copyright (C) 1994-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmdata
15  *
16  * Author: Andrew Hewett
17  *
18  * Purpose: Interface for loadable DICOM data dictionary
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:15:40 $
22  * CVS/RCS Revision: $Revision: 1.24 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DCMDICT_H
31 #define DCMDICT_H
32 
33 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
34 
35 #include "dcmtk/ofstd/ofthread.h"
36 #include "dcmtk/dcmdata/dchashdi.h"
37 
39 #define DCM_MAXDICTLINESIZE 2048
40 
42 #define DCM_MAXDICTFIELDS 6
43 
45 #define DCM_DICT_ENVIRONMENT_VARIABLE "DCMDICTPATH"
46 
47 #ifndef DCM_DICT_DEFAULT_PATH
48 /*
49 ** The default dictionary path is system dependent. It should
50 ** be defined in a configuration file included from "osconfig.h"
51 */
52 #error "DCM_DICT_DEFAULT_PATH is not defined via osconfig.h"
53 #endif /* !DCM_DICT_DEFAULT_PATH */
54 
55 #ifndef ENVIRONMENT_PATH_SEPARATOR
56 #define ENVIRONMENT_PATH_SEPARATOR '\n' /* at least define something unlikely */
57 #endif
58 
59 
63 {
64 public:
65 
72  DcmDataDictionary(OFBool loadBuiltin, OFBool loadExternal);
73 
76 
80  OFBool isDictionaryLoaded() const { return dictionaryLoaded; }
81 
83  int numberOfNormalTagEntries() const { return hashDict.size(); }
84 
86  int numberOfRepeatingTagEntries() const { return OFstatic_cast(int, repDict.size()); }
87 
91  int numberOfEntries() const
92  { return numberOfNormalTagEntries()
94 
100  int numberOfSkeletonEntries() const { return skeletonCount; }
101 
109  OFBool reloadDictionaries(OFBool loadBuiltin, OFBool loadExternal);
110 
118  OFBool loadDictionary(const char* fileName, OFBool errorIfAbsent = OFTrue);
119 
126  const DcmDictEntry* findEntry(const DcmTagKey& key, const char *privCreator) const;
127 
134  const DcmDictEntry* findEntry(const char *name) const;
135 
137  void clear();
138 
146  void addEntry(DcmDictEntry* entry);
147 
148  /* Iterators to access the normal and the repeating entries */
149 
152 
155 
158 
161 
162 private:
163 
167 
171 
175  OFBool loadExternalDictionaries();
176 
181  void loadBuiltinDictionary();
182 
186  OFBool loadSkeletonDictionary();
187 
191  const DcmDictEntry* findEntry(const DcmDictEntry& entry) const;
192 
195  void deleteEntry(const DcmDictEntry& entry);
196 
197 
201 
205 
209 
213 
214 };
215 
216 
224 {
225 public:
230  GlobalDcmDataDictionary(OFBool loadBuiltin, OFBool loadExternal);
231 
235 
240  const DcmDataDictionary& rdlock();
241 
247 
250  void unlock();
251 
257  OFBool isDictionaryLoaded();
258 
264  void clear();
265 
266 private:
270 
274 
278 
279 #ifdef WITH_THREADS
280 
282  OFReadWriteLock dataDictLock;
283 #endif
284 };
285 
286 
298 extern GlobalDcmDataDictionary dcmDataDict;
299 
300 #endif
301 
302 
303 /*
304 ** CVS/RCS Log:
305 ** $Log: dcdict.h,v $
306 ** Revision 1.24 2010-10-14 13:15:40 joergr
307 ** Updated copyright header. Added reference to COPYRIGHT file.
308 **
309 ** Revision 1.23 2010-10-04 14:44:39 joergr
310 ** Replaced "#ifdef _REENTRANT" by "#ifdef WITH_THREADS" where appropriate (i.e.
311 ** in all cases where OFMutex, OFReadWriteLock, etc. are used).
312 **
313 ** Revision 1.22 2009-02-05 13:13:51 joergr
314 ** Added reload method to data dictionary class.
315 **
316 ** Revision 1.21 2008-08-15 09:27:14 meichel
317 ** Added type cast to fix a warning
318 **
319 ** Revision 1.20 2005/12/08 16:28:09 meichel
320 ** Changed include path schema for all DCMTK header files
321 **
322 ** Revision 1.19 2004/01/16 14:07:27 joergr
323 ** Removed acknowledgements with e-mail addresses from CVS log.
324 **
325 ** Revision 1.18 2002/07/23 14:21:25 meichel
326 ** Added support for private tag data dictionaries to dcmdata
327 **
328 ** Revision 1.17 2002/02/27 14:21:20 meichel
329 ** Declare dcmdata read/write locks only when compiled in multi-thread mode
330 **
331 ** Revision 1.16 2001/06/01 15:48:38 meichel
332 ** Updated copyright header
333 **
334 ** Revision 1.15 2000/05/03 14:19:08 meichel
335 ** Added new class GlobalDcmDataDictionary which implements read/write lock
336 ** semantics for safe access to the DICOM dictionary from multiple threads
337 ** in parallel. The global dcmDataDict now uses this class.
338 **
339 ** Revision 1.14 2000/03/08 16:26:13 meichel
340 ** Updated copyright header.
341 **
342 ** Revision 1.13 1999/03/31 09:24:35 meichel
343 ** Updated copyright header in module dcmdata
344 **
345 ** Revision 1.12 1998/07/15 15:48:45 joergr
346 ** Removed several compiler warnings reported by gcc 2.8.1 with
347 ** additional options, e.g. missing copy constructors and assignment
348 ** operators, initialization of member variables in the body of a
349 ** constructor instead of the member initialization list, hiding of
350 ** methods by use of identical names, uninitialized member variables,
351 ** missing const declaration of char pointers. Replaced tabs by spaces.
352 **
353 ** Revision 1.11 1997/08/26 14:02:56 hewett
354 ** New data structures for data-dictionary. The main part of the
355 ** data-dictionary is now stored in an hash table using an optimized
356 ** hash function. This new data structure reduces data-dictionary
357 ** load times by a factor of 4! he data-dictionary specific linked-list
358 ** has been replaced by a linked list derived from OFList class
359 ** (see ofstd/include/oflist.h).
360 ** The only interface modifications are related to iterating over the entire
361 ** data dictionary which should not be needed by "normal" applications.
362 **
363 ** Revision 1.10 1997/07/21 08:25:07 andreas
364 ** - Replace all boolean types (BOOLEAN, CTNBOOLEAN, DICOM_BOOL, BOOL)
365 ** with one unique boolean type OFBool.
366 **
367 ** Revision 1.9 1997/05/22 13:15:54 hewett
368 ** Added method DcmDataDictionary::isDictionaryLoaded() to ask if a full
369 ** data dictionary has been loaded. This method should be used in tests
370 ** rather that querying the number of entries (a sekelton dictionary is
371 ** now always present).
372 **
373 ** Revision 1.8 1997/05/13 13:58:41 hewett
374 ** Added member function (loadSkeletomDictionary) to preload of a few
375 ** essential attribute descriptions into the data dictionary (e.g. Item
376 ** and ItemDelimitation tags).
377 **
378 ** Revision 1.7 1996/09/18 16:37:10 hewett
379 ** Added capability to search data dictionary by tag name.
380 **
381 ** Revision 1.6 1996/03/22 13:09:12 hewett
382 ** Moved the definition of DCM_DICT_DEFAULT_PATH to the system
383 ** dependent configuration files included via "osconfig.h".
384 **
385 ** Revision 1.5 1996/03/21 09:50:38 hewett
386 ** Added a method numberOfEntries() to return the total number of
387 ** dictionary entries.
388 **
389 ** Revision 1.4 1996/03/20 16:43:49 hewett
390 ** Updated for revised data dictionary. Repeating tags are now handled better.
391 ** A linear list of repeating tags has been introduced with a subset ordering
392 ** mechanism to ensure that dictionary searches locate the most precise
393 ** dictionary entry.
394 **
395 */
encapsulates a data dictionary with access methods which allow safe read and write access from multip...
Definition: dcdict.h:223
class maintaining a attribute tag (group and element number)
Definition: dctagkey.h:46
OFBool loadDictionary(const char *fileName, OFBool errorIfAbsent=OFTrue)
load a particular dictionary from file.
OFBool dictionaryLoaded
is a dictionary loaded (more than skeleton)
Definition: dcdict.h:212
iterator class for traversing a DcmHashDict
Definition: dchashdi.h:131
an ordered list of pointers to DcmDictEntry objects
Definition: dchashdi.h:97
this class implements a loadable DICOM Data Dictionary
Definition: dcdict.h:62
DcmDataDictionary dataDict
the data dictionary managed by this class
Definition: dcdict.h:277
each object of this class manages one entry of the global DICOM data dictionary.
Definition: dcdicent.h:65
GlobalDcmDataDictionary(OFBool loadBuiltin, OFBool loadExternal)
constructor.
GlobalDcmDataDictionary & operator=(const GlobalDcmDataDictionary &)
private undefined assignment operator
const DcmDataDictionary & rdlock()
acquires a read lock and returns a const reference to the dictionary.
int skeletonCount
the number of skeleton entries
Definition: dcdict.h:208
const DcmDictEntry * findEntry(const DcmTagKey &key, const char *privCreator) const
dictionary lookup for the given tag key and private creator name.
int numberOfRepeatingTagEntries() const
returns the number of repeating tag entries
Definition: dcdict.h:86
void deleteEntry(const DcmDictEntry &entry)
deletes the given entry from either dictionary
~DcmDataDictionary()
destructor
a hash table of pointers to DcmDictEntry objects
Definition: dchashdi.h:208
DcmHashDictIterator end() const
returns iterator to end of hash table
Definition: dchashdi.h:253
OFBool isDictionaryLoaded() const
checks if a data dictionary is loaded (excluding the skeleton dictionary)
Definition: dcdict.h:80
int size() const
counts total number of entries
Definition: dchashdi.h:223
void unlock()
unlocks the read or write lock which must have been acquired previously.
void addEntry(DcmDictEntry *entry)
adds an entry to the dictionary.
OFBool loadSkeletonDictionary()
loads the skeleton dictionary (the bare minimum needed to run)
int numberOfEntries() const
returns the number of dictionary entries that were loaded either from file or from a built-in diction...
Definition: dcdict.h:91
DcmHashDictIterator begin() const
returns iterator to start of hash table
Definition: dchashdi.h:249
iterator class for traversing a DcmDictEntryList
Definition: dchashdi.h:50
DcmHashDictIterator normalBegin()
returns an iterator to the start of the normal (non-repeating) dictionary
Definition: dcdict.h:151
DcmHashDictIterator normalEnd()
returns an iterator to the end of the normal (non-repeating) dictionary
Definition: dcdict.h:154
void clear()
deletes all dictionary entries
DcmDataDictionary & operator=(const DcmDataDictionary &)
private undefined assignment operator
DcmHashDict hashDict
dictionary of normal tags
Definition: dcdict.h:200
OFBool reloadDictionaries(OFBool loadBuiltin, OFBool loadExternal)
reload data dictionaries.
OFBool loadExternalDictionaries()
loads external dictionaries defined via environment variables
OFBool isDictionaryLoaded()
checks if a data dictionary has been loaded.
DcmDataDictionary & wrlock()
acquires a write lock and returns a non-const reference to the dictionary.
void clear()
erases the contents of the dictionary.
DcmDictEntryList repDict
dictionary of repeating tags
Definition: dcdict.h:204
DcmDictEntryListIterator repeatingEnd()
returns an iterator to the end of the repeating tag dictionary
Definition: dcdict.h:160
OFIterator< T > begin() const
returns an iterator referencing the first element in the list.
Definition: oflist.h:342
size_t size() const
returns number of elements in the list.
Definition: oflist.h:358
void loadBuiltinDictionary()
loads a builtin (compiled) data dictionary.
int numberOfSkeletonEntries() const
returns the number of skeleton entries.
Definition: dcdict.h:100
provides an operating system independent abstraction for read/write locks.
Definition: ofthread.h:427
OFIterator< T > end() const
returns an iterator which points to the past-to-end element of the list.
Definition: oflist.h:348
int numberOfNormalTagEntries() const
returns the number of normal (non-repeating) tag entries
Definition: dcdict.h:83
DcmDataDictionary(OFBool loadBuiltin, OFBool loadExternal)
constructor
DcmDictEntryListIterator repeatingBegin()
returns an iterator to the start of the repeating tag dictionary
Definition: dcdict.h:157
~GlobalDcmDataDictionary()
destructor


Generated on Wed Jan 4 2017 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.6