]> Creatis software - gdcm.git/blob - src/gdcmElValSet.cxx
b74b475e3f38a92a3d5846fda9abfdae6a632c9a
[gdcm.git] / src / gdcmElValSet.cxx
1 #include "gdcm.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::GetElementByNumber(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::GetElementByNumber",
41                             "multiple entries for this key (FIXME) !");
42         return tagHt.find(key)->second;
43 }
44
45 ElValue* ElValSet::GetElementByName(string TagName) {
46    if ( ! NameHt.count(TagName))
47       return (ElValue*)0;
48    if (NameHt.count(TagName) > 1)
49       dbg.Verbose(0, "ElValSet::GetElement",
50                   "multipe entries for this key (FIXME) !");
51    return NameHt.find(TagName)->second;
52 }
53
54 string ElValSet::GetElValueByNumber(guint32 group, guint32 element) {
55         TagKey key = gdcmDictEntry::TranslateToKey(group, element);
56         if ( ! tagHt.count(key))
57                 return "gdcm::Unfound";
58         if (tagHt.count(key) > 1)
59                 dbg.Verbose(0, "ElValSet::GetElValueByNumber",
60                             "multiple entries for this key (FIXME) !");
61         return tagHt.find(key)->second->GetValue();
62 }
63
64 string ElValSet::GetElValueByName(string TagName) {
65         if ( ! NameHt.count(TagName))
66                 return "gdcm::Unfound";
67         if (NameHt.count(TagName) > 1)
68                 dbg.Verbose(0, "ElValSet::GetElValue",
69                             "multipe entries for this key (FIXME) !");
70         return NameHt.find(TagName)->second->GetValue();
71 }
72