1 /*=========================================================================
4 Module: $RCSfile: gdcmElementSet.cxx,v $
6 Date: $Date: 2004/09/03 14:04:02 $
7 Version: $Revision: 1.18 $
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)
37 * \ingroup gdcmElementSet
38 * \brief Canonical destructor.
40 gdcmElementSet::~gdcmElementSet()
42 for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc)
44 gdcmDocEntry* entryToDelete = cc->second;
54 //-----------------------------------------------------------------------------
58 //-----------------------------------------------------------------------------
61 * \brief Prints the Header Entries (Dicom Elements)
65 void gdcmElementSet::Print(std::ostream & os)
67 for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
69 gdcmDocEntry* entry = i->second;
71 bool PrintEndLine = true;
72 if ( gdcmSeqEntry* seqEntry = dynamic_cast<gdcmSeqEntry*>(entry) )
74 (void)seqEntry; //not used
85 * \brief Writes the Header Entries (Dicom Elements)
89 void gdcmElementSet::Write(FILE *fp, FileType filetype)
91 for (TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
93 i->second->Write(fp, filetype);
96 //-----------------------------------------------------------------------------
99 //-----------------------------------------------------------------------------
101 //-----------------------------------------------------------------------------
105 * \brief add a new Dicom Element pointer to the H Table
106 * @param newEntry entry to add
108 bool gdcmElementSet::AddEntry( gdcmDocEntry *newEntry)
110 gdcmTagKey key = newEntry->GetKey();
112 if( TagHT.count(key) == 1 )
114 dbg.Verbose(1, "gdcmElementSet::AddEntry key already present: ",
120 TagHT[newEntry->GetKey()] = newEntry;
126 * \brief Clear the hash table from given entry BUT keep the entry.
127 * @param entryToRemove Entry to remove.
129 bool gdcmElementSet::RemoveEntryNoDestroy( gdcmDocEntry *entryToRemove)
131 gdcmTagKey key = entryToRemove->GetKey();
132 if( TagHT.count(key) == 1 )
135 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
139 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: ");
144 * \brief Clear the hash table from given entry AND delete the entry.
145 * @param entryToRemove Entry to remove AND delete.
147 bool gdcmElementSet::RemoveEntry( gdcmDocEntry *entryToRemove)
149 gdcmTagKey key = entryToRemove->GetKey();
150 if( TagHT.count(key) == 1 )
153 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
154 delete entryToRemove;
158 dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: ");