1 /*=========================================================================
4 Module: $RCSfile: gdcmElementSet.cxx,v $
6 Date: $Date: 2004/09/16 19:21:57 $
7 Version: $Revision: 1.19 $
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 bool PrintEndLine = true;
73 if ( gdcmSeqEntry* seqEntry = dynamic_cast<gdcmSeqEntry*>(entry) )
75 (void)seqEntry; //not used
86 * \brief Writes the Header Entries (Dicom Elements)
90 void gdcmElementSet::Write(FILE *fp, FileType filetype)
92 for (TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
94 i->second->Write(fp, filetype);
97 //-----------------------------------------------------------------------------
100 //-----------------------------------------------------------------------------
102 //-----------------------------------------------------------------------------
106 * \brief add a new Dicom Element pointer to the H Table
107 * @param newEntry entry to add
109 bool gdcmElementSet::AddEntry( gdcmDocEntry *newEntry)
111 gdcmTagKey key = newEntry->GetKey();
113 if( TagHT.count(key) == 1 )
115 dbg.Verbose(1, "gdcmElementSet::AddEntry key already present: ",
121 TagHT[newEntry->GetKey()] = newEntry;
127 * \brief Clear the hash table from given entry BUT keep the entry.
128 * @param entryToRemove Entry to remove.
130 bool gdcmElementSet::RemoveEntryNoDestroy( gdcmDocEntry *entryToRemove)
132 gdcmTagKey key = entryToRemove->GetKey();
133 if( TagHT.count(key) == 1 )
136 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
140 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: ");
145 * \brief Clear the hash table from given entry AND delete the entry.
146 * @param entryToRemove Entry to remove AND delete.
148 bool gdcmElementSet::RemoveEntry( gdcmDocEntry *entryToRemove)
150 gdcmTagKey key = entryToRemove->GetKey();
151 if( TagHT.count(key) == 1 )
154 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
155 delete entryToRemove;
159 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: ");