]> Creatis software - gdcm.git/blob - src/gdcmElValSet.cxx
* hashtest.cxx removed (since allready in Test)
[gdcm.git] / src / gdcmElValSet.cxx
1 #include "gdcmlib.h"
2 #include "gdcmUtil.h"
3
4 TagElValueHT & ElValSet::GetTagHt(void) {
5         return tagHt;
6 }
7
8 void ElValSet::Add(ElValue * newElValue) {
9         tagHt[newElValue->GetKey()]   = newElValue;
10         NameHt[newElValue->GetName()] = newElValue;
11 }
12
13 void ElValSet::Print(ostream & os) {
14         for (TagElValueHT::iterator tag = tagHt.begin();
15                   tag != tagHt.end();
16                   ++tag){
17                 os << tag->first << ": ";
18                 os << "[" << tag->second->GetValue() << "]";
19                 os << "[" << tag->second->GetName()  << "]";
20                 os << "[" << tag->second->GetVR()    << "]" << endl;
21         }
22 }
23
24 void ElValSet::PrintByName(ostream & os) {
25         for (TagElValueNameHT::iterator tag = NameHt.begin();
26                   tag != NameHt.end();
27                   ++tag){
28                 os << tag->first << ": ";
29                 os << "[" << tag->second->GetValue() << "]";
30                 os << "[" << tag->second->GetKey()  << "]";
31                 os << "[" << tag->second->GetVR()    << "]" << endl;
32         }
33 }
34
35 ElValue* ElValSet::GetElement(guint32 group, guint32 element) {
36         TagKey key = gdcmDictEntry::TranslateToKey(group, element);
37         if ( ! tagHt.count(key))
38                 return (ElValue*)0;
39         if (tagHt.count(key) > 1)
40                 dbg.Verbose(0, "ElValSet::GetElValue",
41                             "multiple entries for this key (FIXME) !");
42         return tagHt.find(key)->second;
43 }
44
45 string ElValSet::GetElValue(guint32 group, guint32 element) {
46         TagKey key = gdcmDictEntry::TranslateToKey(group, element);
47         if ( ! tagHt.count(key))
48                 return "UNFOUND";
49         if (tagHt.count(key) > 1)
50                 dbg.Verbose(0, "ElValSet::GetElValue",
51                             "multiple entries for this key (FIXME) !");
52         return tagHt.find(key)->second->GetValue();
53 }
54
55 string ElValSet::GetElValue(string TagName) {
56         if ( ! NameHt.count(TagName))
57                 return "UNFOUND";
58         if (NameHt.count(TagName) > 1)
59                 dbg.Verbose(0, "ElValSet::GetElValue",
60                             "multipe entries for this key (FIXME) !");
61         return NameHt.find(TagName)->second->GetValue();
62 }
63