1 /*=========================================================================
4 Module: $RCSfile: gdcmElementSet.cxx,v $
6 Date: $Date: 2004/06/25 03:06:38 $
7 Version: $Revision: 1.14 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmElementSet.h"
20 #include "gdcmDebug.h"
21 #include "gdcmValEntry.h"
22 #include "gdcmBinEntry.h"
23 #include "gdcmSeqEntry.h"
25 //-----------------------------------------------------------------------------
26 // Constructor / Destructor
28 * \ingroup gdcmElementSet
29 * \brief Constructor from a given gdcmElementSet
31 gdcmElementSet::gdcmElementSet(int depthLevel)
32 : gdcmDocEntrySet(depthLevel) {
36 * \ingroup gdcmElementSet
37 * \brief Canonical destructor.
39 gdcmElementSet::~gdcmElementSet()
41 gdcmDocEntry* EntryToDelete;
42 for(TagDocEntryHT::iterator cc = tagHT.begin();cc != tagHT.end();++cc)
44 EntryToDelete = cc->second;
52 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
59 * \brief Prints the Header Entries (Dicom Elements)
63 void gdcmElementSet::Print(std::ostream & os)
66 for (TagDocEntryHT::iterator i = tagHT.begin(); i != tagHT.end(); ++i)
70 bool PrintEndLine = true;
71 if ( gdcmSeqEntry* SeqEntry = dynamic_cast<gdcmSeqEntry*>(Entry) )
73 (void)SeqEntry; //not used
82 * \brief Writes the Header Entries (Dicom Elements)
86 void gdcmElementSet::Write(FILE *fp, FileType filetype)
89 for (TagDocEntryHT::iterator i = tagHT.begin(); i != tagHT.end(); ++i)
91 i->second->Write(fp, filetype);
94 //-----------------------------------------------------------------------------
97 //-----------------------------------------------------------------------------
99 //-----------------------------------------------------------------------------
103 * \brief add a new Dicom Element pointer to the H Table
104 * @param NewEntry entry to add
106 bool gdcmElementSet::AddEntry( gdcmDocEntry *NewEntry) {
108 key = NewEntry->GetKey();
110 if(tagHT.count(key) == 1)
112 dbg.Verbose(1, "gdcmElementSet::AddEntry key already present: ",
118 tagHT[NewEntry->GetKey()] = NewEntry;
124 * \brief Clear the hash table from given entry.
125 * @param EntryToRemove Entry to remove.
127 bool gdcmElementSet::RemoveEntry( gdcmDocEntry *EntryToRemove)
129 TagKey key = EntryToRemove->GetKey();
130 if(tagHT.count(key) == 1)
133 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
137 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: ");