1 /*=========================================================================
4 Module: $RCSfile: gdcmElementSet.cxx,v $
6 Date: $Date: 2004/09/27 08:39:07 $
7 Version: $Revision: 1.23 $
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.html 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 //BOZ depthLevel is not usefull anymore
32 gdcmElementSet::gdcmElementSet(int depthLevel)
39 * \ingroup gdcmElementSet
40 * \brief Canonical destructor.
42 gdcmElementSet::~gdcmElementSet()
44 for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc)
46 gdcmDocEntry* entryToDelete = cc->second;
56 //-----------------------------------------------------------------------------
60 //-----------------------------------------------------------------------------
63 * \brief Prints the Header Entries (Dicom Elements)
67 void gdcmElementSet::Print(std::ostream& os)
69 for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
71 gdcmDocEntry* entry = i->second;
73 if ( gdcmSeqEntry* seqEntry = dynamic_cast<gdcmSeqEntry*>(entry) )
76 // Avoid the newline for a sequence:
84 * \brief Writes the Header Entries (Dicom Elements)
88 void gdcmElementSet::Write(FILE* fp, FileType filetype)
90 for (TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
92 i->second->Write(fp, filetype);
95 //-----------------------------------------------------------------------------
98 //-----------------------------------------------------------------------------
100 //-----------------------------------------------------------------------------
104 * \brief add a new Dicom Element pointer to the H Table
105 * @param newEntry entry to add
107 bool gdcmElementSet::AddEntry( gdcmDocEntry* newEntry)
109 gdcmTagKey key = newEntry->GetKey();
111 if( TagHT.count(key) == 1 )
113 dbg.Verbose(1, "gdcmElementSet::AddEntry key already present: ",
119 TagHT[newEntry->GetKey()] = newEntry;
125 * \brief Clear the hash table from given entry BUT keep the entry.
126 * @param entryToRemove Entry to remove.
128 bool gdcmElementSet::RemoveEntryNoDestroy( gdcmDocEntry* entryToRemove)
130 gdcmTagKey key = entryToRemove->GetKey();
131 if( TagHT.count(key) == 1 )
134 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
138 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: ");
143 * \brief Clear the hash table from given entry AND delete the entry.
144 * @param entryToRemove Entry to remove AND delete.
146 bool gdcmElementSet::RemoveEntry( gdcmDocEntry* entryToRemove)
148 gdcmTagKey key = entryToRemove->GetKey();
149 if( TagHT.count(key) == 1 )
152 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
153 delete entryToRemove;
157 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: ");