6 TagElValueHT & ElValSet::GetTagHt(void) {
10 void ElValSet::Add(ElValue * newElValue) {
11 tagHt[newElValue->GetKey()] = newElValue;
12 NameHt[newElValue->GetName()] = newElValue;
15 void ElValSet::Print(ostream & os) {
16 for (TagElValueHT::iterator tag = tagHt.begin();
19 os << tag->first << ": ";
20 os << "[" << tag->second->GetValue() << "]";
21 os << "[" << tag->second->GetName() << "]";
22 os << "[" << tag->second->GetVR() << "]" << endl;
27 int ElValSet::Write(FILE * _fp) {
32 // restent à tester les echecs en écriture
33 for (TagElValueHT::iterator tag = tagHt.begin();
38 // peut-on se passer des affectations?
39 // - passer l'adresse du resultat d'une fonction (???)
40 // - acceder au champ sans passer par un accesseur ?
41 gr = tag->second->GetGroup();
42 el = tag->second->GetElement();
43 lgr = tag->second->GetLength();
44 val = tag->second->GetValue().c_str();
46 fwrite ( &gr,(size_t)2 ,(size_t)1 ,_fp); //group
47 fwrite ( &el,(size_t)2 ,(size_t)1 ,_fp); //element
48 //fwrite ( tag->second->GetVR(),(size_t)2 ,(size_t)1 ,_fp); //VR
51 fwrite ( &lgr,(size_t)4 ,(size_t)1 ,_fp); //lgr
52 // voir pb des int16 et int32 : les identifier, les convertir, modifier la longueur
53 fwrite ( val,(size_t)lgr ,(size_t)1 ,_fp); //valeur Elem
57 void ElValSet::PrintByName(ostream & os) {
58 for (TagElValueNameHT::iterator tag = NameHt.begin();
61 os << tag->first << ": ";
62 os << "[" << tag->second->GetValue() << "]";
63 os << "[" << tag->second->GetKey() << "]";
64 os << "[" << tag->second->GetVR() << "]" << endl;
68 ElValue* ElValSet::GetElementByNumber(guint32 group, guint32 element) {
69 TagKey key = gdcmDictEntry::TranslateToKey(group, element);
70 if ( ! tagHt.count(key))
72 if (tagHt.count(key) > 1)
73 dbg.Verbose(0, "ElValSet::GetElementByNumber",
74 "multiple entries for this key (FIXME) !");
75 return tagHt.find(key)->second;
78 ElValue* ElValSet::GetElementByName(string TagName) {
79 if ( ! NameHt.count(TagName))
81 if (NameHt.count(TagName) > 1)
82 dbg.Verbose(0, "ElValSet::GetElement",
83 "multipe entries for this key (FIXME) !");
84 return NameHt.find(TagName)->second;
87 string ElValSet::GetElValueByNumber(guint32 group, guint32 element) {
88 TagKey key = gdcmDictEntry::TranslateToKey(group, element);
89 if ( ! tagHt.count(key))
90 return "gdcm::Unfound";
91 if (tagHt.count(key) > 1)
92 dbg.Verbose(0, "ElValSet::GetElValueByNumber",
93 "multiple entries for this key (FIXME) !");
94 return tagHt.find(key)->second->GetValue();
97 int ElValSet::SetElValueByNumber(string content, guint32 group, guint32 element) {
98 TagKey key = gdcmDictEntry::TranslateToKey(group, element);
99 if ( ! tagHt.count(key))
101 if (tagHt.count(key) > 1) {
102 dbg.Verbose(0, "ElValSet::SetElValueByNumber",
103 "multiple entries for this key (FIXME) !");
107 tagHt[key]->SetValue(content);
111 string ElValSet::GetElValueByName(string TagName) {
112 if ( ! NameHt.count(TagName))
113 return "gdcm::Unfound";
114 if (NameHt.count(TagName) > 1)
115 dbg.Verbose(0, "ElValSet::GetElValue",
116 "multipe entries for this key (FIXME) !");
117 return NameHt.find(TagName)->second->GetValue();
120 int ElValSet::SetElValueByName(string content, string TagName) {
121 if ( ! NameHt.count(TagName))
123 if (NameHt.count(TagName) > 1) {
124 dbg.Verbose(0, "ElValSet::SetElValue",
125 "multipe entries for this key (FIXME) !");
128 NameHt.find(TagName)->second->SetValue(content);