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"
20 #define PUB_DICT_NAME "DicomV3Dict"
22 # define PUB_DICT_PATH "../Dicts/"
24 #define PUB_DICT_FILENAME "dicomV3.dic"
27 * \ingroup gdcmDictSet
28 * \brief Consider all the entries of the public dicom dictionnary.
29 * Build all list of all the tag names of all those entries.
30 * \sa gdcmDictSet::GetPubDictTagNamesByCategory
31 * @return A list of all entries of the public dicom dictionnary.
33 list<string> * gdcmDictSet::GetPubDictTagNames(void) {
34 list<string> * Result = new list<string>;
35 TagKeyHT entries = GetDefaultPubDict()->GetEntries();
37 for (TagKeyHT::iterator tag = entries.begin(); tag != entries.end(); ++tag){
38 Result->push_back( tag->second->GetName() );
44 * \ingroup gdcmDictSet
45 * \brief Consider all the entries of the public dicom dictionnary.
46 * Build an hashtable whose keys are the names of the groups
47 * (fourth field in each line of dictionary) and whose corresponding
48 * values are lists of all the dictionnary entries among that
49 * group. Note that apparently the Dicom standard doesn't explicitely
50 * define a name (as a string) for each group.
51 * A typical usage of this method would be to enable a dynamic
52 * configuration of a Dicom file browser: the admin/user can
53 * select in the interface which Dicom tags should be displayed.
54 * @return An hashtable: whose keys are the names of the groups and whose
55 * corresponding values are lists of all the dictionnary entries
58 map<string, list<string> > * gdcmDictSet::GetPubDictTagNamesByCategory(void) {
59 map<string, list<string> > * Result = new map<string, list<string> >;
60 TagKeyHT entries = GetDefaultPubDict()->GetEntries();
62 for (TagKeyHT::iterator tag = entries.begin(); tag != entries.end(); ++tag){
63 (*Result)[tag->second->GetFourth()].push_back(tag->second->GetName());
69 * \ingroup gdcmDictSet
70 * \brief Obtain from the GDCM_DICT_PATH environnement variable the
71 * path to directory containing the dictionnaries. When
72 * the environnement variable is absent the path is defaulted
75 string gdcmDictSet::BuildDictPath(void) {
77 const char* EnvPath = (char*)0;
78 EnvPath = getenv("GDCM_DICT_PATH");
79 if (EnvPath && (strlen(EnvPath) != 0)) {
81 if (ResultPath[ResultPath.length() -1] != '/' )
83 dbg.Verbose(1, "gdcmDictSet::BuildDictPath:",
84 "Dictionary path set from environnement");
86 ResultPath = PUB_DICT_PATH;
91 * \ingroup gdcmDictSet
92 * \brief The Dictionnary Set obtained with this constructor simply
93 * contains the Default Public dictionnary.
95 gdcmDictSet::gdcmDictSet(void) {
96 DictPath = BuildDictPath();
97 string PubDictFile = DictPath + PUB_DICT_FILENAME;
98 Dicts[PUB_DICT_NAME] = new gdcmDict(PubDictFile);
101 gdcmDictSet::~gdcmDictSet() {
102 for (DictSetHT::iterator tag = Dicts.begin(); tag != Dicts.end(); ++tag) {
103 gdcmDict* EntryToDelete = tag->second;
105 delete EntryToDelete;
111 * \ingroup gdcmDictSet
112 * \brief Loads a dictionary from a specified file, and add it
113 * to already the existing ones contained in this gdcmDictSet.
114 * @param FileName Absolute or relative filename containing the
115 * dictionary to load.
116 * @param Name Symbolic name that be used as identifier of the newly
117 * created dictionary.
119 void gdcmDictSet::LoadDictFromFile(string FileName, DictKey Name) {
120 gdcmDict *NewDict = new gdcmDict(FileName);
121 Dicts[Name] = NewDict;
125 * \ingroup gdcmDictSet
126 * \brief Print, in an informal fashion, the list of all the dictionaries
127 * contained is this gdcmDictSet, along with their respective content.
128 * @param os Output stream used for printing.
130 void gdcmDictSet::Print(ostream& os) {
131 for (DictSetHT::iterator dict = Dicts.begin(); dict != Dicts.end(); ++dict){
132 os << "Printing dictionary " << dict->first << " \n";
133 dict->second->Print(os);
138 * \ingroup gdcmDictSet
139 * \brief Retrieve the specified dictionary (when existing) from this
141 * @param DictName The synbolic name of the searched dictionary.
142 * \result The retrieved dictionary.
144 gdcmDict * gdcmDictSet::GetDict(DictKey DictName) {
145 DictSetHT::iterator dict = Dicts.find(DictName);
150 * \ingroup gdcmDictSet
151 * \brief Retrieve the default reference DICOM V3 public dictionary.
152 * \result The retrieved default dictionary.
154 gdcmDict * gdcmDictSet::GetDefaultPubDict() {
155 return GetDict(PUB_DICT_NAME);