OFFIS DCMTK  Version 3.6.0
dchashdi.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: Hash table interface for DICOM data dictionary
19  *
20  * Last Update: $Author: uli $
21  * Update Date: $Date: 2010-11-10 12:04:06 $
22  * CVS/RCS Revision: $Revision: 1.22 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 #ifndef DCHASHDI_H
30 #define DCHASHDI_H
31 
32 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */
33 #include "dcmtk/ofstd/oflist.h"
34 #include "dcmtk/ofstd/ofstream.h"
35 
36 class DcmDictEntry;
37 class DcmTagKey;
38 class DcmHashDict;
39 
41 const int DCMHASHDICT_DEFAULT_HASHSIZE = 2047;
42 
44 typedef OFListIterator(DcmDictEntry *) OFListIteratorPDcmDictEntry;
45 typedef OFListConstIterator(DcmDictEntry *) OFListConstIteratorPDcmDictEntry;
46 
47 
50 class DcmDictEntryListIterator: public OFListIteratorPDcmDictEntry
51 {
52 public:
53 
56 
60  DcmDictEntryListIterator(const OFListIterator(DcmDictEntry*)& iter)
61  : OFListIterator(DcmDictEntry*)(iter) {}
62 
65  {
66  OFListIteratorPDcmDictEntry::operator=(i);
67  return *this;
68  }
69 };
70 
73 class DcmDictEntryListConstIterator: public OFListConstIteratorPDcmDictEntry
74 {
75 public:
76 
79 
83  DcmDictEntryListConstIterator(const OFListConstIterator(DcmDictEntry*)& iter)
84  : OFListConstIterator(DcmDictEntry*)(iter) {}
85 
88  {
89  OFListConstIteratorPDcmDictEntry::operator=(i);
90  return *this;
91  }
92 };
93 
94 
97 class DcmDictEntryList : public OFList<DcmDictEntry *>
98 {
99 public:
100 
103 
106 
108  void clear();
109 
115 
116  /* find an entry in the set */
117  DcmDictEntry *find(const DcmTagKey& k, const char *privCreator);
118 
119 private:
120 
123 
126 };
127 
128 
132 {
133 public:
134 
137  : dict(NULL), hindex(0), iterating(OFFalse), iter()
138  { init(NULL); }
139 
145  DcmHashDictIterator(const DcmHashDict* d, OFBool atEnd = OFFalse)
146  : dict(NULL), hindex(0), iterating(OFFalse), iter()
147  { init(d, atEnd); }
148 
151  : dict(i.dict), hindex(i.hindex), iterating(i.iterating), iter(i.iter)
152  { }
153 
156  { dict = i.dict; hindex = i.hindex;
157  iterating = i.iterating; iter = i.iter; return *this; }
158 
160  OFBool operator==(const DcmHashDictIterator& x) const
161  { return (hindex == x.hindex) && (iter == x.iter); }
162 
164  OFBool operator!=(const DcmHashDictIterator& x) const
165  { return !(*this == x); }
166 
168  const DcmDictEntry* operator*() const
169  { return (*iter); }
170 
173  { stepUp(); return *this; }
174 
177  { DcmHashDictIterator tmp(*this); stepUp(); return tmp; }
178 
179 private:
180 
186  void init(const DcmHashDict *d, OFBool atEnd = OFFalse);
187 
190  void stepUp();
191 
194 
196  int hindex;
197 
199  OFBool iterating;
200 
203 };
204 
205 
209 {
210 
211 public:
215  DcmHashDict(int hashTabLen = DCMHASHDICT_DEFAULT_HASHSIZE)
217  { _init(hashTabLen); }
218 
220  ~DcmHashDict();
221 
223  int size() const { return entryCount; }
224 
226  void clear();
227 
231  void put(DcmDictEntry* e);
232 
237  const DcmDictEntry* get(const DcmTagKey& key, const char *privCreator) const;
238 
243  void del(const DcmTagKey& k, const char *privCreator);
244 
245  // iterator over the contents of the hash table
246  friend class DcmHashDictIterator;
247 
250  { DcmHashDictIterator iter(this); return iter; }
251 
254  { DcmHashDictIterator iter(this, OFTrue); return iter; }
255 
257  STD_NAMESPACE ostream& loadSummary(STD_NAMESPACE ostream& out);
258 
259 private:
260 
262  DcmHashDict(const DcmHashDict &);
263 
266 
268  void _init(int hashSize);
269 
274  int hash(const DcmTagKey* k) const;
275 
282 
289  DcmDictEntry* removeInList(DcmDictEntryList& lst, const DcmTagKey& k, const char *privCreator);
290 
297  DcmDictEntry* findInList(DcmDictEntryList& lst, const DcmTagKey& k, const char *privCreator) const;
298 
303 
306 
309 
312 
315 
316 };
317 
318 #endif /* DCHASHDI_H */
319 
320 
321 /*
322 ** CVS/RCS Log:
323 ** $Log: dchashdi.h,v $
324 ** Revision 1.22 2010-11-10 12:04:06 uli
325 ** Corrected DcmHashDictIterator::operator!=. Previously it ignored hindex.
326 **
327 ** Revision 1.21 2010-10-14 13:15:41 joergr
328 ** Updated copyright header. Added reference to COPYRIGHT file.
329 **
330 ** Revision 1.20 2009-01-05 14:14:14 joergr
331 ** Fixed bug in DcmHashDictIterator::operator!=() introduced with last commit.
332 ** Reverted to old implementation.
333 **
334 ** Revision 1.19 2008-12-19 14:57:59 joergr
335 ** Fixed bug in DcmHashDictIterator::operator!=() - wrong comparison operand.
336 **
337 ** Revision 1.18 2006/08/15 15:49:56 meichel
338 ** Updated all code in module dcmdata to correctly compile when
339 ** all standard C++ classes remain in namespace std.
340 **
341 ** Revision 1.17 2005/12/08 16:28:14 meichel
342 ** Changed include path schema for all DCMTK header files
343 **
344 ** Revision 1.16 2003/07/03 15:38:10 meichel
345 ** Introduced DcmDictEntryListConstIterator, needed for compiling with HAVE_STL.
346 **
347 ** Revision 1.15 2003/06/12 13:35:04 joergr
348 ** Fixed inconsistent API documentation reported by Doxygen.
349 **
350 ** Revision 1.14 2003/06/03 10:26:17 meichel
351 ** Renamed local variables to avoid name clashes with STL
352 **
353 ** Revision 1.13 2003/06/02 17:03:58 meichel
354 ** Added typedef needed by MSVC5 when compiling with STL support
355 **
356 ** Revision 1.12 2003/03/21 13:06:46 meichel
357 ** Minor code purifications for warnings reported by MSVC in Level 4
358 **
359 ** Revision 1.11 2002/07/23 14:21:26 meichel
360 ** Added support for private tag data dictionaries to dcmdata
361 **
362 ** Revision 1.10 2001/06/01 15:48:40 meichel
363 ** Updated copyright header
364 **
365 ** Revision 1.9 2000/05/03 14:19:08 meichel
366 ** Added new class GlobalDcmDataDictionary which implements read/write lock
367 ** semantics for safe access to the DICOM dictionary from multiple threads
368 ** in parallel. The global dcmDataDict now uses this class.
369 **
370 ** Revision 1.8 2000/03/08 16:26:15 meichel
371 ** Updated copyright header.
372 **
373 ** Revision 1.7 1999/03/31 09:24:39 meichel
374 ** Updated copyright header in module dcmdata
375 **
376 ** Revision 1.6 1998/07/15 15:48:48 joergr
377 ** Removed several compiler warnings reported by gcc 2.8.1 with
378 ** additional options, e.g. missing copy constructors and assignment
379 ** operators, initialization of member variables in the body of a
380 ** constructor instead of the member initialization list, hiding of
381 ** methods by use of identical names, uninitialized member variables,
382 ** missing const declaration of char pointers. Replaced tabs by spaces.
383 **
384 ** Revision 1.5 1997/09/18 11:41:13 meichel
385 ** Corrected forward and friend declarations (needed for DEC cxx).
386 **
387 ** Revision 1.4 1997/09/18 07:24:07 meichel
388 ** Missing operator= added to class DcmDictEntryListIterator
389 **
390 ** Revision 1.3 1997/08/29 13:11:09 andreas
391 ** Corrected copy constructor for DcmHashDictIterator
392 **
393 ** Revision 1.2 1997/08/26 13:41:11 hewett
394 ** Corrected a couple of minor spelling errors.
395 **
396 ** Revision 1.1 1997/08/26 13:30:29 hewett
397 ** Initial Version - Interface for hash table data structure for data dictionary.
398 **
399 */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2