4 //'identifier' : decorated name length exceeded, name was truncated
5 //#pragma warning ( disable : 4503 )
6 // 'identifier' : class 'type' needs to have dll-interface to be used by
7 // clients of class 'type2'
8 #pragma warning ( disable : 4251 )
9 // 'identifier' : identifier was truncated to 'number' characters in the
11 #pragma warning ( disable : 4786 )
15 #include <stdlib.h> // For getenv
17 #include "gdcmDictSet.h"
19 #define PUB_DICT_NAME "DicomV3Dict"
21 # define PUB_DICT_PATH "../Dicts/"
23 #define PUB_DICT_FILENAME "dicomV3.dic"
26 * \ingroup gdcmDictSet
27 * \brief Consider all the entries of the public dicom dictionnary.
28 * Build all list of all the tag names of all those entries.
29 * \sa gdcmDictSet::GetPubDictTagNamesByCategory
30 * @return A list of all entries of the public dicom dictionnary.
32 std::list<std::string> * gdcmDictSet::GetPubDictTagNames(void) {
33 std::list<std::string> * Result = new std::list<std::string>;
34 TagKeyHT entries = GetDefaultPubDict()->GetEntries();
36 for (TagKeyHT::iterator tag = entries.begin(); tag != entries.end(); ++tag){
37 Result->push_back( tag->second->GetName() );
43 * \ingroup gdcmDictSet
44 * \brief Consider all the entries of the public dicom dictionnary.
45 * Build an hashtable whose keys are the names of the groups
46 * (fourth field in each line of dictionary) and whose corresponding
47 * values are lists of all the dictionnary entries among that
48 * group. Note that apparently the Dicom standard doesn't explicitely
49 * define a name (as a string) for each group.
50 * A typical usage of this method would be to enable a dynamic
51 * configuration of a Dicom file browser: the admin/user can
52 * select in the interface which Dicom tags should be displayed.
53 * @return An hashtable: whose keys are the names of the groups and whose
54 * corresponding values are lists of all the dictionnary entries
57 std::map<std::string, std::list<std::string> > * gdcmDictSet::GetPubDictTagNamesByCategory(void) {
58 std::map<std::string, std::list<std::string> > * Result = new map<std::string, std::list<std::string> >;
59 TagKeyHT entries = GetDefaultPubDict()->GetEntries();
61 for (TagKeyHT::iterator tag = entries.begin(); tag != entries.end(); ++tag){
62 (*Result)[tag->second->GetFourth()].push_back(tag->second->GetName());
68 * \ingroup gdcmDictSet
69 * \brief Obtain from the GDCM_DICT_PATH environnement variable the
70 * path to directory containing the dictionnaries. When
71 * the environnement variable is absent the path is defaulted
74 std::string gdcmDictSet::BuildDictPath(void) {
75 std::string ResultPath;
76 const char* EnvPath = (char*)0;
77 EnvPath = getenv("GDCM_DICT_PATH");
78 if (EnvPath && (strlen(EnvPath) != 0)) {
80 if (ResultPath[ResultPath.length() -1] != '/' )
82 dbg.Verbose(1, "gdcmDictSet::BuildDictPath:",
83 "Dictionary path set from environnement");
85 ResultPath = PUB_DICT_PATH;
90 * \ingroup gdcmDictSet
91 * \brief The Dictionnary Set obtained with this constructor simply
92 * contains the Default Public dictionnary.
94 gdcmDictSet::gdcmDictSet(void) {
95 DictPath = BuildDictPath();
96 std::string PubDictFile = DictPath + PUB_DICT_FILENAME;
97 Dicts[PUB_DICT_NAME] = new gdcmDict(PubDictFile);
100 gdcmDictSet::~gdcmDictSet() {
101 for (DictSetHT::iterator tag = Dicts.begin(); tag != Dicts.end(); ++tag) {
102 gdcmDict* EntryToDelete = tag->second;
104 delete EntryToDelete;
110 * \ingroup gdcmDictSet
111 * \brief Loads a dictionary from a specified file, and add it
112 * to already the existing ones contained in this gdcmDictSet.
113 * @param FileName Absolute or relative filename containing the
114 * dictionary to load.
115 * @param Name Symbolic name that be used as identifier of the newly
116 * created dictionary.
118 void gdcmDictSet::LoadDictFromFile(std::string FileName, DictKey Name) {
119 gdcmDict *NewDict = new gdcmDict(FileName);
120 Dicts[Name] = NewDict;
124 * \ingroup gdcmDictSet
125 * \brief Print, in an informal fashion, the list of all the dictionaries
126 * contained is this gdcmDictSet, along with their respective content.
127 * @param os Output stream used for printing.
129 void gdcmDictSet::Print(ostream& os) {
130 for (DictSetHT::iterator dict = Dicts.begin(); dict != Dicts.end(); ++dict){
131 os << "Printing dictionary " << dict->first << " \n";
132 dict->second->Print(os);
137 * \ingroup gdcmDictSet
138 * \brief Retrieve the specified dictionary (when existing) from this
140 * @param DictName The synbolic name of the searched dictionary.
141 * \result The retrieved dictionary.
143 gdcmDict * gdcmDictSet::GetDict(DictKey DictName) {
144 DictSetHT::iterator dict = Dicts.find(DictName);
149 * \ingroup gdcmDictSet
150 * \brief Retrieve the default reference DICOM V3 public dictionary.
151 * \result The retrieved default dictionary.
153 gdcmDict * gdcmDictSet::GetDefaultPubDict() {
154 return GetDict(PUB_DICT_NAME);