]> Creatis software - gdcm.git/blob - src/gdcmDictSet.h
c05e1b5c7a31d4de53a14029f7d03eb8ed43df5f
[gdcm.git] / src / gdcmDictSet.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDictSet.h,v $
5   Language:  C++
6   Date:      $Date: 2005/10/18 12:58:28 $
7   Version:   $Revision: 1.46 $
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 GDCMDICTSET_H
20 #define GDCMDICTSET_H
21
22 #include "gdcmBase.h"
23 #include "gdcmDict.h"
24
25 #include <map>
26 #include <list>
27
28 namespace gdcm 
29 {
30 typedef std::map<DictKey, Dict*> DictSetHT;
31 typedef std::string ExtendedTagKey;
32 typedef std::map<ExtendedTagKey, DictEntry>  ExtendedTagKeyHT;
33
34 //-----------------------------------------------------------------------------
35 /**
36  * \brief  Container for managing a set of loaded dictionaries (Dict).
37  * \note   Hopefully, sharing dictionaries should avoid
38  * \par    reloading an already loaded dictionary (saving time)
39  * \par    having many in memory representations of the same dictionary
40  *        (saving memory).
41  */
42 class GDCM_EXPORT DictSet : public Base
43 {
44 public:
45    DictSet();
46    ~DictSet();
47
48    void Print(std::ostream &os = std::cout, std::string const &indent = "" );
49
50    // Probabely useless !
51    //EntryNamesList *GetPubDictEntryNames();
52    //EntryNamesByCatMap *GetPubDictEntryNamesByCategory();
53
54    Dict *LoadDictFromFile( std::string const &fileName,
55                            DictKey const &name );
56
57    Dict *GetDict( DictKey const &DictName );
58
59    /// \brief   Returns the default reference DICOM V3 public dictionary.
60    Dict* GetDefaultPubDict() { return GetDict(PUB_DICT_NAME); }
61
62    // \ brief   Returns the virtual references DICOM dictionary.
63    // \ warning : not end user intended
64    // Dict *GetVirtualDict() { return &VirtualEntries; }
65
66    DictEntry *NewVirtualDictEntry(uint16_t group, uint16_t elem,
67                                   const VRKey &vr     = GDCM_VRUNKNOWN,
68                                   const TagName &vm   = GDCM_UNKNOWN,
69                                   const TagName &name = GDCM_UNKNOWN);
70
71    Dict *GetFirstEntry();
72    Dict *GetNextEntry();
73
74    static std::string BuildDictPath();
75
76 protected:
77    bool AppendDict(Dict *NewDict, DictKey const &name);
78
79 private:
80    /// Hash table of all dictionaries contained in this DictSet
81    DictSetHT Dicts;
82    DictSetHT::iterator ItDictHt;
83
84    /// Directory path to dictionaries
85    std::string DictPath;
86
87    /// H table for the on the fly created DictEntries  
88    ExtendedTagKeyHT VirtualEntries; 
89 };
90 } // end namespace gdcm
91
92 //-----------------------------------------------------------------------------
93 #endif