]> Creatis software - gdcm.git/blob - src/gdcmDict.h
ENH: Adding 'gdcm' namespace. Be nice with me this was a ~13000 lines patch. Also...
[gdcm.git] / src / gdcmDict.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDict.h,v $
5   Language:  C++
6   Date:      $Date: 2004/10/12 04:35:45 $
7   Version:   $Revision: 1.19 $
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 "gdcmCommon.h"
23 #include "gdcmDictEntry.h"
24
25 #include <iostream>
26 #include <list>
27 #include <map>
28 namespace gdcm 
29 {
30
31 //-----------------------------------------------------------------------------
32 typedef std::map<TagKey, DictEntry*> TagKeyHT;
33 typedef std::map<TagName, DictEntry*> TagNameHT;
34
35 //-----------------------------------------------------------------------------
36 /*
37  * \defgroup Dict
38  * \brief    Dict acts a memory representation of a dicom dictionary i.e.
39  *           it is a container for a collection of dictionary entries. The
40  *           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
47 {
48 public:
49    Dict(std::string const & FileName);
50    ~Dict();
51
52 // Print
53    void Print(std::ostream &os = std::cout);
54    void PrintByKey(std::ostream &os = std::cout);
55    void PrintByName(std::ostream &os = std::cout);
56
57 // Entries
58    bool AddNewEntry (DictEntry *NewEntry);
59    bool ReplaceEntry(DictEntry *NewEntry);
60    bool RemoveEntry (TagKey key);
61    bool RemoveEntry (uint16_t group, uint16_t element);
62    
63 // Tag
64    DictEntry *GetDictEntryByName(TagName name);
65    DictEntry *GetDictEntryByNumber(uint16_t group, uint16_t element);
66
67    std::list<std::string> *GetDictEntryNames();
68    std::map<std::string, std::list<std::string> > *
69         GetDictEntryNamesByCategory();
70
71    /// \brief  Returns a ref to the Dicom Dictionary H table (map)
72    /// @return the Dicom Dictionary H table
73    TagKeyHT & GetEntriesByKey()  { return KeyHt; }
74
75    /// \brief  Returns a ref to the Dicom Dictionary H table (map)
76    /// @return the Dicom Dictionary H table
77    TagNameHT & GetEntriesByName()  { return NameHt; }
78  
79 private:
80    /// ASCII file holding the Dictionnary
81    std::string Filename;
82    /// Access through TagKey (see alternate access with NameHt)
83    TagKeyHT  KeyHt;
84    /// Access through TagName (see alternate access with KeyHt)
85    TagNameHT NameHt;
86 };
87 } // end namespace gdcm
88
89 //-----------------------------------------------------------------------------
90 #endif