]> Creatis software - gdcm.git/blob - src/gdcmElValSet.cxx
Ajout fonctions
[gdcm.git] / src / gdcmElValSet.cxx
1 // gdcmElValSet.cxx
2
3 #include "gdcm.h"
4 #include "gdcmUtil.h"
5
6 TagElValueHT & ElValSet::GetTagHt(void) {
7         return tagHt;
8 }
9
10 void ElValSet::Add(ElValue * newElValue) {
11         tagHt[newElValue->GetKey()]   = newElValue;
12         NameHt[newElValue->GetName()] = newElValue;
13 }
14
15 void ElValSet::Print(ostream & os) {
16         for (TagElValueHT::iterator tag = tagHt.begin();
17                   tag != tagHt.end();
18                   ++tag){
19                 os << tag->first << ": ";
20                 os << "[" << tag->second->GetValue() << "]";
21                 os << "[" << tag->second->GetName()  << "]";
22                 os << "[" << tag->second->GetVR()    << "]" << endl;
23         }
24 }
25
26 void ElValSet::PrintByName(ostream & os) {
27         for (TagElValueNameHT::iterator tag = NameHt.begin();
28                   tag != NameHt.end();
29                   ++tag){
30                 os << tag->first << ": ";
31                 os << "[" << tag->second->GetValue() << "]";
32                 os << "[" << tag->second->GetKey()  << "]";
33                 os << "[" << tag->second->GetVR()    << "]" << endl;
34         }
35 }
36
37 ElValue* ElValSet::GetElementByNumber(guint32 group, guint32 element) {
38         TagKey key = gdcmDictEntry::TranslateToKey(group, element);
39         if ( ! tagHt.count(key))
40                 return (ElValue*)0;
41         if (tagHt.count(key) > 1)
42                 dbg.Verbose(0, "ElValSet::GetElementByNumber",
43                             "multiple entries for this key (FIXME) !");
44         return tagHt.find(key)->second;
45 }
46
47 ElValue* ElValSet::GetElementByName(string TagName) {
48    if ( ! NameHt.count(TagName))
49       return (ElValue*)0;
50    if (NameHt.count(TagName) > 1)
51       dbg.Verbose(0, "ElValSet::GetElement",
52                   "multipe entries for this key (FIXME) !");
53    return NameHt.find(TagName)->second;
54 }
55
56 string ElValSet::GetElValueByNumber(guint32 group, guint32 element) {
57         TagKey key = gdcmDictEntry::TranslateToKey(group, element);
58         if ( ! tagHt.count(key))
59                 return "gdcm::Unfound";
60         if (tagHt.count(key) > 1)
61                 dbg.Verbose(0, "ElValSet::GetElValueByNumber",
62                             "multiple entries for this key (FIXME) !");
63         return tagHt.find(key)->second->GetValue();
64 }
65
66 int ElValSet::SetElValueByNumber(string content, guint32 group, guint32 element) {
67         TagKey key = gdcmDictEntry::TranslateToKey(group, element);
68         if ( ! tagHt.count(key))
69                 return 0;
70         if (tagHt.count(key) > 1) {
71                 dbg.Verbose(0, "ElValSet::SetElValueByNumber",
72                             "multiple entries for this key (FIXME) !");
73                 return (0); 
74         }
75                                        
76         tagHt[key]->SetValue(content);
77         return(1);              
78 }
79
80 string ElValSet::GetElValueByName(string TagName) {
81         if ( ! NameHt.count(TagName))
82                 return "gdcm::Unfound";
83         if (NameHt.count(TagName) > 1)
84                 dbg.Verbose(0, "ElValSet::GetElValue",
85                             "multipe entries for this key (FIXME) !");
86         return NameHt.find(TagName)->second->GetValue();
87 }
88
89 int ElValSet::SetElValueByName(string content, string TagName) {
90         if ( ! NameHt.count(TagName))
91                 return 0;
92         if (NameHt.count(TagName) > 1) {
93                 dbg.Verbose(0, "ElValSet::SetElValue",
94                             "multipe entries for this key (FIXME) !");
95                 return 0;
96         }
97         NameHt.find(TagName)->second->SetValue(content);
98 }
99
100