]> Creatis software - gdcm.git/blob - src/gdcmDictSet.h
ENH: Minor patch, cosmetic -again-. Remove all this->. I might have discover the...
[gdcm.git] / src / gdcmDictSet.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDictSet.h,v $
5   Language:  C++
6   Date:      $Date: 2004/08/01 00:59:21 $
7   Version:   $Revision: 1.22 $
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 GDCMDICTSET_H
20 #define GDCMDICTSET_H
21
22 #include "gdcmDict.h"
23 #include <map>
24 #include <list>
25
26 typedef std::string DictKey;
27 typedef std::map<DictKey, gdcmDict*> DictSetHT;
28
29 //-----------------------------------------------------------------------------
30 /*
31  * \defgroup gdcmDictSet
32  * \brief  Container for managing a set of loaded dictionaries.
33  * \note   Hopefully, sharing dictionaries should avoid
34  * \par    reloading an already loaded dictionary (saving time)
35  * \par    having many in memory representations of the same dictionary
36  *        (saving memory).
37  */
38 class GDCM_EXPORT gdcmDictSet
39 {
40 public:
41    // TODO Swig int LoadDictFromFile(std::string filename);
42    // QUESTION: the following function might not be thread safe !? Maybe
43    //           we need some mutex here, to avoid concurent creation of
44    //           the same dictionary !?!?!
45    // TODO Swig int LoadDictFromName(std::string filename);
46    // TODO Swig int LoadAllDictFromDirectory(std::string DirectoryName);
47    // TODO Swig std::string* GetAllDictNames();
48    gdcmDictSet();
49    ~gdcmDictSet();
50
51    void Print(std::ostream& os);
52
53    std::list<std::string> *GetPubDictEntryNames();
54    std::map<std::string, std::list<std::string> > *
55        GetPubDictEntryNamesByCategory();
56
57    gdcmDict *LoadDictFromFile(std::string FileName, DictKey Name);
58
59    gdcmDict *GetDict(DictKey DictName);
60    gdcmDict *GetDefaultPubDict();
61
62    gdcmDictEntry *NewVirtualDictEntry(uint16_t group, uint16_t element,
63                                       std::string vr     = "Unknown",
64                                       std::string fourth = "Unknown",
65                                       std::string name   = "Unknown");
66
67    static std::string BuildDictPath();
68
69 protected:
70    bool AppendDict(gdcmDict *NewDict,DictKey Name);
71
72 private:
73    /// Hash table of all dictionaries contained in this gdcmDictSet
74    DictSetHT Dicts;
75    /// Directory path to dictionaries
76    std::string DictPath;
77    /// H table for the on the fly created gdcmDictEntries  
78    std::map<std::string,gdcmDictEntry *> virtualEntry;
79 };
80
81 //-----------------------------------------------------------------------------
82 #endif