]> Creatis software - gdcm.git/blob - src/gdcmDict.h
Fix mistypings
[gdcm.git] / src / gdcmDict.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDict.h,v $
5   Language:  C++
6   Date:      $Date: 2007/08/22 16:14:03 $
7   Version:   $Revision: 1.51 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 #ifndef _GDCMDICT_H_
20 #define _GDCMDICT_H_
21
22 #include "gdcmRefCounter.h"
23 #include "gdcmDictEntry.h"
24
25 #include <iostream>
26 #include <fstream> // for ifstream
27 #include <list>
28 #include <map>
29
30 namespace GDCM_NAME_SPACE 
31 {
32
33 //-----------------------------------------------------------------------------
34 typedef std::string DictKey;
35 typedef std::map<TagKey, DictEntry *>  TagKeyHT;
36
37 //-----------------------------------------------------------------------------
38 /**
39  * \brief    Dict acts a memory representation of a dicom dictionary i.e.
40  *           it is a container for a collection of dictionary entries.
41  *           The dictionary is loaded from in an ascii file.
42  *           There should be a single public dictionary (THE dictionary of
43  *           the actual DICOM v3) but as many shadow dictionaries as imagers 
44  *           combined with all software versions...
45  * \see DictSet
46  */
47 class GDCM_EXPORT Dict : public RefCounter
48 {
49    gdcmTypeMacro(Dict);
50
51 public:
52 /// \brief Contructs an empty Dict with a RefCounter
53    static Dict *New() {return new Dict();}
54 /// \brief Contructs a Dict with a RefCounter
55    static Dict *New(std::string const &filename) {return new Dict(filename);}
56
57    bool AddDict(std::string const &filename);
58    bool RemoveDict(std::string const &filename);
59 // Print
60    void Print(std::ostream &os = std::cout, std::string const &indent = "");
61
62 // Entries
63    bool AddEntry(DictEntry *newEntry);
64   // bool ReplaceEntry(DictEntry *newEntry); // useless ?
65    bool RemoveEntry (TagKey const &key);
66    bool RemoveEntry (uint16_t group, uint16_t elem);
67    void ClearEntry();
68    
69 // Tag
70    DictEntry *GetEntry(uint16_t group, uint16_t elem);
71    DictEntry *GetEntry(TagKey const &key);
72
73    DictEntry *GetFirstEntry();
74    DictEntry *GetNextEntry();
75
76 protected:
77    Dict();
78    Dict(std::string const &filename);
79    ~Dict();
80
81 private:
82    void DoTheLoadingJob(std::ifstream &ifs);
83
84    /// ASCII file holding the Dictionnary
85    std::string Filename;
86
87    /// Access through TagKey
88    TagKeyHT KeyHt;
89    /// Iterator for the entries
90    TagKeyHT::iterator ItKeyHt;
91 };
92 } // end namespace gdcm
93
94 //-----------------------------------------------------------------------------
95 #endif