]> Creatis software - gdcm.git/blob - src/gdcmDict.h
316f7ccdea9867e8fe03e9f616a5a53cf847d5c3
[gdcm.git] / src / gdcmDict.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDict.h,v $
5   Language:  C++
6   Date:      $Date: 2005/09/03 18:24:10 $
7   Version:   $Revision: 1.41 $
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 "gdcmBase.h"
23 #include "gdcmDictEntry.h"
24
25 #include <iostream>
26 #include <fstream> // for ifstream
27 #include <list>
28 #include <map>
29
30 namespace gdcm 
31 {
32
33 //-----------------------------------------------------------------------------
34 typedef std::string DictKey;
35 typedef std::map<TagKey, DictEntry>  TagKeyHT;
36 //-----------------------------------------------------------------------------
37 /**
38  * \brief    Dict acts a memory representation of a dicom dictionary i.e.
39  *           it is a container for a collection of dictionary entries.
40  *           The dictionary is loaded from in an ascii file.
41  *           There should be a single public dictionary (THE dictionary of
42  *           the actual DICOM v3) but as many shadow dictionaries as imagers 
43  *           combined with all software versions...
44  * \see DictSet
45  */
46 class GDCM_EXPORT Dict : public Base
47 {
48 public:
49    Dict();
50    Dict(std::string const &filename);
51    ~Dict();
52
53    bool AddDict(std::string const &filename);
54    bool RemoveDict(std::string const &filename);
55 // Print
56    void Print(std::ostream &os = std::cout, std::string const &indent = "");
57
58 // Entries
59    bool AddEntry(DictEntry const &newEntry);
60    bool ReplaceEntry(DictEntry const &newEntry);
61    bool RemoveEntry (TagKey const &key);
62    bool RemoveEntry (uint16_t group, uint16_t elem);
63    void ClearEntry();
64    
65 // Tag
66    DictEntry *GetEntry(uint16_t group, uint16_t elem);
67    DictEntry *GetEntry(TagKey const &key);
68
69    DictEntry *GetFirstEntry();
70    DictEntry *GetNextEntry();
71
72 private:
73    void DoTheLoadingJob(std::ifstream &ifs);
74
75    /// ASCII file holding the Dictionnary
76    std::string Filename;
77
78    /// Access through TagKey
79    TagKeyHT KeyHt;
80    TagKeyHT::iterator ItKeyHt;
81 };
82 } // end namespace gdcm
83
84 //-----------------------------------------------------------------------------
85 #endif