1 /*=========================================================================
4 Module: $RCSfile: gdcmElementSet.cxx,v $
6 Date: $Date: 2004/09/17 13:11:16 $
7 Version: $Revision: 1.20 $
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 //BOZ depthLevel is not usefull anymore
32 gdcmElementSet::gdcmElementSet(int depthLevel)
38 * \ingroup gdcmElementSet
39 * \brief Canonical destructor.
41 gdcmElementSet::~gdcmElementSet()
43 for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc)
45 gdcmDocEntry* entryToDelete = cc->second;
55 //-----------------------------------------------------------------------------
59 //-----------------------------------------------------------------------------
62 * \brief Prints the Header Entries (Dicom Elements)
66 void gdcmElementSet::Print(std::ostream & os)
68 for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
70 gdcmDocEntry* entry = i->second;
72 if ( gdcmSeqEntry* seqEntry = dynamic_cast<gdcmSeqEntry*>(entry) )
74 // Avoid the newline for a sequence:
82 * \brief Writes the Header Entries (Dicom Elements)
86 void gdcmElementSet::Write(FILE *fp, FileType filetype)
88 for (TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
90 i->second->Write(fp, filetype);
93 //-----------------------------------------------------------------------------
96 //-----------------------------------------------------------------------------
98 //-----------------------------------------------------------------------------
102 * \brief add a new Dicom Element pointer to the H Table
103 * @param newEntry entry to add
105 bool gdcmElementSet::AddEntry( gdcmDocEntry *newEntry)
107 gdcmTagKey key = newEntry->GetKey();
109 if( TagHT.count(key) == 1 )
111 dbg.Verbose(1, "gdcmElementSet::AddEntry key already present: ",
117 TagHT[newEntry->GetKey()] = newEntry;
123 * \brief Clear the hash table from given entry BUT keep the entry.
124 * @param entryToRemove Entry to remove.
126 bool gdcmElementSet::RemoveEntryNoDestroy( gdcmDocEntry *entryToRemove)
128 gdcmTagKey key = entryToRemove->GetKey();
129 if( TagHT.count(key) == 1 )
132 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
136 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: ");
141 * \brief Clear the hash table from given entry AND delete the entry.
142 * @param entryToRemove Entry to remove AND delete.
144 bool gdcmElementSet::RemoveEntry( gdcmDocEntry *entryToRemove)
146 gdcmTagKey key = entryToRemove->GetKey();
147 if( TagHT.count(key) == 1 )
150 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
151 delete entryToRemove;
155 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: ");