]> Creatis software - gdcm.git/blob - src/gdcmDict.h
961d245f53b87835a1651bebb70788fb8166e290
[gdcm.git] / src / gdcmDict.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDict.h,v $
5   Language:  C++
6   Date:      $Date: 2004/09/27 08:39:06 $
7   Version:   $Revision: 1.18 $
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
29 //-----------------------------------------------------------------------------
30 typedef std::map<gdcmTagKey, gdcmDictEntry*> TagKeyHT;
31 typedef std::map<TagName, gdcmDictEntry*> TagNameHT;
32
33 //-----------------------------------------------------------------------------
34 /*
35  * \defgroup gdcmDict
36  * \brief    gdcmDict acts a memory representation of a dicom dictionary i.e.
37  *           it is a container for a collection of dictionary entries. The
38  *           dictionary is loaded from in an ascii file.
39  *           There should be a single public dictionary (THE dictionary of
40  *           the actual DICOM v3) but as many shadow dictionaries as imagers 
41  *           combined with all software versions...
42  * \see gdcmDictSet
43  */
44 class GDCM_EXPORT gdcmDict
45 {
46 public:
47    gdcmDict(std::string const & FileName);
48    ~gdcmDict();
49
50 // Print
51    void Print(std::ostream &os = std::cout);
52    void PrintByKey(std::ostream &os = std::cout);
53    void PrintByName(std::ostream &os = std::cout);
54
55 // Entries
56    bool AddNewEntry (gdcmDictEntry *NewEntry);
57    bool ReplaceEntry(gdcmDictEntry *NewEntry);
58    bool RemoveEntry (gdcmTagKey key);
59    bool RemoveEntry (uint16_t group, uint16_t element);
60    
61 // Tag
62    gdcmDictEntry *GetDictEntryByName(TagName name);
63    gdcmDictEntry *GetDictEntryByNumber(uint16_t group, uint16_t element);
64
65    std::list<std::string> *GetDictEntryNames();
66    std::map<std::string, std::list<std::string> > *
67         GetDictEntryNamesByCategory();
68
69    /// \brief  Returns a ref to the Dicom Dictionary H table (map)
70    /// @return the Dicom Dictionary H table
71    TagKeyHT & GetEntriesByKey()  { return KeyHt; }
72
73    /// \brief  Returns a ref to the Dicom Dictionary H table (map)
74    /// @return the Dicom Dictionary H table
75    TagNameHT & GetEntriesByName()  { return NameHt; }
76  
77 private:
78    /// ASCII file holding the Dictionnary
79    std::string Filename;
80    /// Access through gdcmTagKey (see alternate access with NameHt)
81    TagKeyHT  KeyHt;
82    /// Access through TagName (see alternate access with KeyHt)
83    TagNameHT NameHt;
84 };
85
86 //-----------------------------------------------------------------------------
87 #endif