]> Creatis software - gdcm.git/blob - src/gdcmDict.h
EMH: *Add PrintAllDocument, dog slow right now
[gdcm.git] / src / gdcmDict.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDict.h,v $
5   Language:  C++
6   Date:      $Date: 2004/06/20 18:08:47 $
7   Version:   $Revision: 1.15 $
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.htm 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<TagKey,  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 public:
46    gdcmDict(std::string & FileName);
47    ~gdcmDict();
48
49 // Print
50    void Print(std::ostream &os = std::cout);
51    void PrintByKey(std::ostream &os = std::cout);
52    void PrintByName(std::ostream &os = std::cout);
53
54 // Entries
55    bool AddNewEntry (gdcmDictEntry *NewEntry);
56    bool ReplaceEntry(gdcmDictEntry *NewEntry);
57    bool RemoveEntry (TagKey key);
58    bool RemoveEntry (guint16 group, guint16 element);
59    
60 // Tag
61    gdcmDictEntry *GetDictEntryByName(TagName name);
62    gdcmDictEntry *GetDictEntryByNumber(guint16 group, guint16 element);
63
64    std::list<std::string> *GetDictEntryNames(void);
65    std::map<std::string, std::list<std::string> > *
66         GetDictEntryNamesByCategory(void);
67
68    /**
69     * \ingroup gdcmDict
70     * \brief   returns a ref to the Dicom Dictionary H table (map)
71     * return the Dicom Dictionary H table
72     */
73    inline TagKeyHT & GetEntriesByKey(void)  { return KeyHt; }
74
75    /**
76     * \ingroup gdcmDict
77     * \brief   returns a ref to the Dicom Dictionary H table (map)
78     * return the Dicom Dictionary H table
79     */
80    inline TagNameHT & GetEntriesByName(void)  { return NameHt; }
81  
82 private:
83    /// ASCII file holding the Dictionnary
84    std::string filename;
85    /// Access through TagKey (see alternate access with NameHt)
86    TagKeyHT  KeyHt;
87    /// Access through TagName (see alternate access with KeyHt)
88    TagNameHT NameHt;
89 };
90
91 //-----------------------------------------------------------------------------
92 #endif