]> Creatis software - gdcm.git/blob - src/gdcmElementSet.cxx
PLEASE : keep on waiting for the final version !
[gdcm.git] / src / gdcmElementSet.cxx
1 // gdcmElementSet.cxx
2 //-----------------------------------------------------------------------------
3 //
4 #include "gdcmElementSet.h"
5 #include "gdcmDebug.h"
6
7 //-----------------------------------------------------------------------------
8 // Constructor / Destructor
9 /**
10  * \ingroup gdcmElementSet
11  * \brief   Constructor from a given gdcmElementSet
12  */
13 gdcmElementSet::gdcmElementSet() {
14    //TagDocEntryHT tagHT est un champ de gdcmElementSet.
15    // inutile de faire new ?
16       
17 }
18
19 /**
20  * \ingroup gdcmElementSet
21  * \brief   Canonical destructor.
22  */
23 gdcmElementSet::~gdcmElementSet() 
24 {
25   gdcmDocEntry* EntryToDelete;  
26   for(TagDocEntryHT::iterator cc = tagHT.begin();cc != tagHT.end();++cc)
27    {
28       EntryToDelete = cc->second;
29       if ( EntryToDelete )
30          delete EntryToDelete;  // TODO : a verifier
31    }
32    tagHT.clear();
33 }
34
35
36 //-----------------------------------------------------------------------------
37 // Public
38
39
40 //-----------------------------------------------------------------------------
41 // Print
42 /**
43   * \brief   Prints the Header Entries (Dicom Elements)
44   *          from the H Table
45   * @return
46   */ 
47 void gdcmElementSet::Print(std::ostream & os) {
48    cout << "entree ds gdcmElementSet::Print" << endl;
49    for (TagDocEntryHT::iterator i = tagHT.begin(); i != tagHT.end(); ++i)  
50    {
51       //(*i)->second->SetPrintLevel(printLevel);
52       (i->second)->Print(os);   
53    } 
54 }
55
56
57 //-----------------------------------------------------------------------------
58 // Protected
59
60 //-----------------------------------------------------------------------------
61 // Private
62
63
64 /**
65  * \brief   add a new Dicom Element pointer to the H Table
66  * @param   newDocEntry entry to add
67  */
68 bool gdcmElementSet::AddEntry( gdcmDocEntry *NewEntry) {
69    TagKey key;
70    key = NewEntry->GetKey();
71
72    if(tagHT.count(key) == 1)
73    {
74       dbg.Verbose(1, "gdcmElementSet::AddEntry key already present: ", key.c_str());
75       return(false);
76    } 
77    else 
78    {
79       tagHT[NewEntry->GetKey()] = NewEntry;
80       return(true);
81    }   
82 }
83