]> Creatis software - gdcm.git/blobdiff - src/gdcmElementSet.cxx
ENH: Move the old setup.py to its new home
[gdcm.git] / src / gdcmElementSet.cxx
index 0f332f77b49c7ecc984fc84fefbae66a1342fc96..d071067ca02daf98552b910b5bfcb3f24069e691 100644 (file)
@@ -3,12 +3,12 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/07/19 03:34:12 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2004/09/27 08:39:07 $
+  Version:   $Revision: 1.23 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
-  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
                                                                                 
      This software is distributed WITHOUT ANY WARRANTY; without even
      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  * \ingroup gdcmElementSet
  * \brief   Constructor from a given gdcmElementSet
  */
+//BOZ depthLevel is not usefull anymore
 gdcmElementSet::gdcmElementSet(int depthLevel) 
-              : gdcmDocEntrySet(depthLevel)
+              : gdcmDocEntrySet()
 {
+  (void)depthLevel;
 }
 
 /**
@@ -62,22 +64,19 @@ gdcmElementSet::~gdcmElementSet()
   *          from the H Table
   * @return
   */ 
-void gdcmElementSet::Print(std::ostream & os)
+void gdcmElementSet::Print(std::ostream& os)
 {
    for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
    {
       gdcmDocEntry* entry = i->second;
       entry->Print(os);   
-      bool PrintEndLine = true;
       if ( gdcmSeqEntry* seqEntry = dynamic_cast<gdcmSeqEntry*>(entry) )
       {
-         (void)seqEntry;  //not used
-         PrintEndLine = false;
-      }
-      if( PrintEndLine )
-      {
-         os << std::endl;
+         (void)seqEntry;
+         // Avoid the newline for a sequence:
+         continue;
       }
+      os << std::endl;
    }
 }
 
@@ -86,7 +85,7 @@ void gdcmElementSet::Print(std::ostream & os)
   *          from the H Table
   * @return
   */ 
-void gdcmElementSet::Write(FILE *fp, FileType filetype)
+void gdcmElementSet::Write(FILEfp, FileType filetype)
 {
    for (TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
    {
@@ -103,9 +102,9 @@ void gdcmElementSet::Write(FILE *fp, FileType filetype)
 
 /**
  * \brief   add a new Dicom Element pointer to the H Table
- * @param   NewEntry entry to add
+ * @param   newEntry entry to add
  */
-bool gdcmElementSet::AddEntry( gdcmDocEntry *newEntry)
+bool gdcmElementSet::AddEntry( gdcmDocEntrynewEntry)
 {
    gdcmTagKey key = newEntry->GetKey();
 
@@ -123,16 +122,35 @@ bool gdcmElementSet::AddEntry( gdcmDocEntry *newEntry)
 }
 
 /**
- * \brief   Clear the hash table from given entry.
- * @param   EntryToRemove Entry to remove.
+ * \brief   Clear the hash table from given entry BUT keep the entry.
+ * @param   entryToRemove Entry to remove.
+ */
+bool gdcmElementSet::RemoveEntryNoDestroy( gdcmDocEntry* entryToRemove)
+{
+   gdcmTagKey key = entryToRemove->GetKey();
+   if( TagHT.count(key) == 1 )
+   {
+      TagHT.erase(key);
+      dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
+      return true;
+   }
+
+   dbg.Verbose(0, "gdcmElementSet::RemoveEntry: key not present: ");
+   return false ;
+}
+
+/**
+ * \brief   Clear the hash table from given entry AND delete the entry.
+ * @param   entryToRemove Entry to remove AND delete.
  */
-bool gdcmElementSet::RemoveEntry( gdcmDocEntry *entryToRemove)
+bool gdcmElementSet::RemoveEntry( gdcmDocEntryentryToRemove)
 {
    gdcmTagKey key = entryToRemove->GetKey();
    if( TagHT.count(key) == 1 )
    {
       TagHT.erase(key);
       dbg.Verbose(0, "gdcmElementSet::RemoveEntry: one element erased.");
+      delete entryToRemove;
       return true;
    }