#include <gdcmDict.h>
Public Member Functions | |
gdcmDict (std::string &FileName) | |
Construtor. | |
~gdcmDict () | |
Destructor. | |
void | Print (std::ostream &os=std::cout) |
Print all the dictionary entries contained in this dictionary. Entries will be sorted by tag i.e. the couple (group, element). | |
void | PrintByKey (std::ostream &os=std::cout) |
Print all the dictionary entries contained in this dictionary. Entries will be sorted by tag i.e. the couple (group, element). | |
void | PrintByName (std::ostream &os=std::cout) |
Print all the dictionary entries contained in this dictionary. Entries will be sorted by the name of the dictionary entries. | |
bool | AddNewEntry (gdcmDictEntry *NewEntry) |
adds a new Dicom Dictionary Entry | |
bool | ReplaceEntry (gdcmDictEntry *NewEntry) |
replaces an already existing Dicom Element by a new one | |
bool | RemoveEntry (TagKey key) |
removes an already existing Dicom Dictionary Entry, identified by its Tag | |
bool | RemoveEntry (guint16 group, guint16 element) |
removes an already existing Dicom Dictionary Entry, identified by its group,element number | |
gdcmDictEntry * | GetDictEntryByName (TagName name) |
Get the dictionnary entry identified by it's name. | |
gdcmDictEntry * | GetDictEntryByNumber (guint16 group, guint16 element) |
Get the dictionnary entry identified by a given tag (group,element). | |
std::list< std::string > * | GetDictEntryNames (void) |
Consider all the entries of the public dicom dictionnary. Build all list of all the tag names of all those entries. | |
std::map< std::string, std::list< std::string > > * | GetDictEntryNamesByCategory (void) |
Consider all the entries of the public dicom dictionnary. Build an hashtable whose keys are the names of the groups (fourth field in each line of dictionary) and whose corresponding values are lists of all the dictionnary entries among that group. Note that apparently the Dicom standard doesn't explicitely define a name (as a string) for each group. A typical usage of this method would be to enable a dynamic configuration of a Dicom file browser: the admin/user can select in the interface which Dicom tags should be displayed. | |
TagKeyHT & | GetEntries (void) |
returns a ref to the Dicom Dictionary H table (map) return the Dicom Dictionary H table | |
Private Attributes | |
std::string | filename |
TagKeyHT | KeyHt |
Access through TagKey (see alternate access with NameHt). | |
TagNameHT | NameHt |
Access through TagName (see alternate access with KeyHt). |
|
Construtor.
Definition at line 24 of file gdcmDict.cxx. References AddNewEntry(), dbg, eatwhite(), gdcmDebug::Error(), filename, and TagName.
00024 { 00025 guint16 group, element; 00026 char buff[1024]; 00027 TagName vr; 00028 TagName fourth; 00029 TagName name; 00030 00031 std::ifstream from(FileName.c_str()); 00032 dbg.Error(!from, "gdcmDict::gdcmDict: can't open dictionary", 00033 FileName.c_str()); 00034 00035 while (!from.eof()) { 00036 from >> std::hex >> group >> element; 00037 eatwhite(from); 00038 from.getline(buff, 256, ' '); 00039 vr = buff; 00040 eatwhite(from); 00041 from.getline(buff, 256, ' '); 00042 fourth = buff; 00043 from.getline(buff, 256, '\n'); 00044 name = buff; 00045 00046 gdcmDictEntry * newEntry = new gdcmDictEntry(group, element, 00047 vr, fourth, name); 00048 AddNewEntry(newEntry); 00049 } 00050 from.close(); 00051 00052 filename=FileName; 00053 } |
|
Destructor.
Definition at line 59 of file gdcmDict.cxx.
00059 { 00060 for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag) { 00061 gdcmDictEntry* EntryToDelete = tag->second; 00062 if ( EntryToDelete ) 00063 delete EntryToDelete; 00064 } 00065 00066 // Since AddNewEntry adds symetrical in both KeyHt and NameHT we can 00067 // assume all the pointed gdcmDictEntries are already cleaned-up when 00068 // we cleaned KeyHt. 00069 KeyHt.clear(); 00070 NameHt.clear(); 00071 } |
|
adds a new Dicom Dictionary Entry
Definition at line 136 of file gdcmDict.cxx. References dbg, gdcmDictEntry::GetKey(), KeyHt, NameHt, TagKey, and gdcmDebug::Verbose(). Referenced by gdcmDict().
00137 { 00138 TagKey key; 00139 key = NewEntry->GetKey(); 00140 00141 if(KeyHt.count(key) == 1) 00142 { 00143 dbg.Verbose(1, "gdcmDict::AddNewEntry already present", key.c_str()); 00144 return(false); 00145 } 00146 else 00147 { 00148 KeyHt[NewEntry->GetKey()] = NewEntry; 00149 NameHt[NewEntry->GetName()] = NewEntry; 00150 return(true); 00151 } 00152 } |
|
Get the dictionnary entry identified by it's name.
Definition at line 219 of file gdcmDict.cxx. References NameHt, and TagName. Referenced by gdcmParser::GetDictEntryByName(), gdcmParser::GetEntryByName(), gdcmParser::GetEntryVRByName(), gdcmParser::GetHeaderEntryByName(), and gdcmParser::SetEntryByName().
|
|
Get the dictionnary entry identified by a given tag (group,element).
Definition at line 232 of file gdcmDict.cxx. References KeyHt, TagKey, and gdcmDictEntry::TranslateToKey(). Referenced by gdcmParser::GetDictEntryByNumber(), gdcmDicomDir::SetElement(), and gdcmParser::UpdateShaEntries().
00232 { 00233 TagKey key = gdcmDictEntry::TranslateToKey(group, element); 00234 if ( ! KeyHt.count(key)) 00235 return NULL; 00236 return KeyHt.find(key)->second; 00237 } |
|
Consider all the entries of the public dicom dictionnary. Build all list of all the tag names of all those entries.
Definition at line 246 of file gdcmDict.cxx. References KeyHt. Referenced by gdcmDictSet::GetPubDictEntryNames().
|
|
Consider all the entries of the public dicom dictionnary. Build an hashtable whose keys are the names of the groups (fourth field in each line of dictionary) and whose corresponding values are lists of all the dictionnary entries among that group. Note that apparently the Dicom standard doesn't explicitely define a name (as a string) for each group. A typical usage of this method would be to enable a dynamic configuration of a Dicom file browser: the admin/user can select in the interface which Dicom tags should be displayed.
Definition at line 280 of file gdcmDict.cxx. References KeyHt. Referenced by gdcmDictSet::GetPubDictEntryNamesByCategory().
00281 { 00282 std::map<std::string, std::list<std::string> > *Result = new std::map<std::string, std::list<std::string> >; 00283 00284 for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag) 00285 { 00286 (*Result)[tag->second->GetFourth()].push_back(tag->second->GetName()); 00287 } 00288 return Result; 00289 } |
|
returns a ref to the Dicom Dictionary H table (map) return the Dicom Dictionary H table
Definition at line 57 of file gdcmDict.h. References KeyHt, and TagKeyHT.
00057 { return KeyHt; } |
|
Print all the dictionary entries contained in this dictionary. Entries will be sorted by tag i.e. the couple (group, element).
Definition at line 80 of file gdcmDict.cxx. References filename, and PrintByKey(). Referenced by gdcmParser::PrintPubDict(), and gdcmParser::PrintShaDict().
00080 { 00081 os<<"Dict file name : "<<filename<<std::endl; 00082 PrintByKey(os); 00083 } |
|
Print all the dictionary entries contained in this dictionary. Entries will be sorted by tag i.e. the couple (group, element).
Definition at line 91 of file gdcmDict.cxx. References KeyHt. Referenced by Print().
00091 { 00092 std::ostringstream s; 00093 00094 for (TagKeyHT::iterator tag = KeyHt.begin(); tag != KeyHt.end(); ++tag){ 00095 s << "Entry : "; 00096 s << "(" << std::hex << std::setw(4) << tag->second->GetGroup() << ','; 00097 s << std::hex << std::setw(4) << tag->second->GetElement() << ") = " << std::dec; 00098 s << tag->second->GetVR() << ", "; 00099 s << tag->second->GetFourth() << ", "; 00100 s << tag->second->GetName() << "." << std::endl; 00101 } 00102 os << s.str(); 00103 } |
|
Print all the dictionary entries contained in this dictionary. Entries will be sorted by the name of the dictionary entries.
Definition at line 113 of file gdcmDict.cxx. References NameHt.
00113 { 00114 std::ostringstream s; 00115 00116 for (TagNameHT::iterator tag = NameHt.begin(); tag != NameHt.end(); ++tag){ 00117 s << "Entry : "; 00118 s << tag->second->GetName() << ","; 00119 s << tag->second->GetVR() << ", "; 00120 s << tag->second->GetFourth() << ", "; 00121 s << "(" << std::hex << std::setw(4) << tag->second->GetGroup() << ','; 00122 s << std::hex << std::setw(4) << tag->second->GetElement() << ") = "; 00123 s << std::dec << std::endl; 00124 } 00125 os << s.str(); 00126 } |
|
removes an already existing Dicom Dictionary Entry, identified by its group,element number
Definition at line 206 of file gdcmDict.cxx. References RemoveEntry().
00206 { 00207 return( RemoveEntry(gdcmDictEntry::TranslateToKey(group, element)) ); 00208 } |
|
removes an already existing Dicom Dictionary Entry, identified by its Tag
Definition at line 176 of file gdcmDict.cxx. References dbg, gdcmDictEntry::GetName(), KeyHt, NameHt, TagKey, and gdcmDebug::Verbose(). Referenced by RemoveEntry(), and ReplaceEntry().
00177 { 00178 if(KeyHt.count(key) == 1) 00179 { 00180 gdcmDictEntry* EntryToDelete = KeyHt.find(key)->second; 00181 00182 if ( EntryToDelete ) 00183 { 00184 NameHt.erase(EntryToDelete->GetName()); 00185 delete EntryToDelete; 00186 } 00187 00188 KeyHt.erase(key); 00189 return (true); 00190 } 00191 else 00192 { 00193 dbg.Verbose(1, "gdcmDict::RemoveEntry unfound entry", key.c_str()); 00194 return (false); 00195 } 00196 } |
|
replaces an already existing Dicom Element by a new one
Definition at line 160 of file gdcmDict.cxx. References gdcmDictEntry::GetKey(), KeyHt, NameHt, and RemoveEntry().
00160 { 00161 if ( RemoveEntry(NewEntry->gdcmDictEntry::GetKey()) ) { 00162 KeyHt[NewEntry->GetKey()] = NewEntry; 00163 NameHt[NewEntry->GetName()] = NewEntry; 00164 return (true); 00165 } 00166 return (false); 00167 } |
|
Definition at line 60 of file gdcmDict.h. Referenced by gdcmDict(), and Print(). |
|
Access through TagKey (see alternate access with NameHt).
Definition at line 63 of file gdcmDict.h. Referenced by AddNewEntry(), GetDictEntryByNumber(), GetDictEntryNames(), GetDictEntryNamesByCategory(), GetEntries(), PrintByKey(), RemoveEntry(), ReplaceEntry(), and ~gdcmDict(). |
|
Access through TagName (see alternate access with KeyHt).
Definition at line 65 of file gdcmDict.h. Referenced by AddNewEntry(), GetDictEntryByName(), PrintByName(), RemoveEntry(), ReplaceEntry(), and ~gdcmDict(). |