]> Creatis software - gdcm.git/commitdiff
* src/gdcmDocument.cxx : bug fix on potential memory leak
authorregrain <regrain>
Tue, 25 Jan 2005 11:11:57 +0000 (11:11 +0000)
committerregrain <regrain>
Tue, 25 Jan 2005 11:11:57 +0000 (11:11 +0000)
   * src/gdcmSQItem.cxx : initialize the SQItemNumber value in the constructor
   * src/gdcmSQItem.[h|cxx], gdcmElementSet.[h|cxx], gdcmDicomDir*.[h|cxx] :
     Add ClearXxx methods to remove all the content of the list or map
   * gdcmDocEntrySet.h : add GetFirst/NextEntry in pure virtual
   -- BeNours

15 files changed:
ChangeLog
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h
src/gdcmDicomDirPatient.cxx
src/gdcmDicomDirPatient.h
src/gdcmDicomDirSerie.cxx
src/gdcmDicomDirSerie.h
src/gdcmDicomDirStudy.cxx
src/gdcmDicomDirStudy.h
src/gdcmDocEntrySet.h
src/gdcmDocument.cxx
src/gdcmElementSet.cxx
src/gdcmElementSet.h
src/gdcmSQItem.cxx
src/gdcmSQItem.h

index d77b19c690c80e4844441c6d038121e5d2831839..f7c038a8f90b5e80904693967dcc0537f35e1c3f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-01-25 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * src/gdcmDocument.cxx : bug fix on potential memory leak
+   * src/gdcmSQItem.cxx : initialize the SQItemNumber value in the constructor
+   * src/gdcmSQItem.[h|cxx], gdcmElementSet.[h|cxx], gdcmDicomDir*.[h|cxx] : 
+     Add ClearXxx methods to remove all the content of the list or map
+   * gdcmDocEntrySet.h : add GetFirst/NextEntry in pure virtual
+
 2005-01-24 Mathieu Malaterre  <Mathieu.Malaterre@creatis.insa-lyon.fr>
    * Grealty simplify the JPEg decompression, no need to differenciate based on 
      the JPEG possible type (with/without fragment, with/without multiple frame). 
index 568223b8adf19c62672d876485625e13b1f0eaf0..01fb17ce6fa768436f8cd2f2ba75037f424f6459 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:10:52 $
-  Version:   $Revision: 1.116 $
+  Date:      $Date: 2005/01/25 11:11:58 $
+  Version:   $Revision: 1.117 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -146,12 +146,7 @@ DicomDir::~DicomDir()
    SetProgressMethod(NULL);
    SetEndMethod(NULL);
 
-   for(ListDicomDirPatient::iterator cc = Patients.begin();
-                                     cc!= Patients.end();
-                                   ++cc)
-   {
-      delete *cc;
-   }
+   ClearPatient();
    if ( MetaElems )
    {
       delete MetaElems;
@@ -476,14 +471,24 @@ DicomDirMeta *DicomDir::NewMeta()
 
  // friend class hunting : we miss GetLastEntry and GetPreviousEntry
  //                  to be able to remove any direct reference to TagHT
-
-   DocEntry *e = GetFirstEntry();
-   if (e)
+   DocEntry *entry = GetFirstEntry();
+   if( entry )
    //if ( TagHT.begin() != TagHT.end() ) // after Document Parsing
    { 
       MetaElems = new DicomDirMeta(true);
 
-      TagDocEntryHT::iterator lastOneButSequence = TagHT.end();
+      entry = GetFirstEntry();
+      while( entry )
+      {
+         if( dynamic_cast<SeqEntry *>(entry) )
+            break;
+
+         RemoveEntryNoDestroy(entry);
+         MetaElems->AddEntry(entry);
+
+         entry = GetFirstEntry();
+      }
+      /*TagDocEntryHT::iterator lastOneButSequence = TagHT.end();
       lastOneButSequence --;
       // ALL the 'out of Sequence' Tags belong to Meta Elems
       // (we skip 0004|1220 [Directory record sequence] )
@@ -492,7 +497,7 @@ DicomDirMeta *DicomDir::NewMeta()
                                    ++cc)
       {
          MetaElems->AddEntry( cc->second );
-      }
+      }*/
    }
    else  // after root directory parsing
    {
@@ -503,7 +508,8 @@ DicomDirMeta *DicomDir::NewMeta()
 }
 
 /**
- * \brief   adds a new Patient (with the basic elements) to a partially created DICOMDIR
+ * \brief   adds a new Patient (with the basic elements) to a partially created
+ *          DICOMDIR
  */
 DicomDirPatient *DicomDir::NewPatient()
 {
@@ -512,6 +518,20 @@ DicomDirPatient *DicomDir::NewPatient()
    return p;
 }
 
+/**
+ * \brief   Remove all Patients
+ */
+void DicomDir::ClearPatient()
+{
+   for(ListDicomDirPatient::iterator cc = Patients.begin();
+                                     cc!= Patients.end();
+                                   ++cc)
+   {
+      delete *cc;
+   }
+   Patients.clear();
+}
+
 /**
  * \brief   adds to the HTable 
  *          the Entries (Dicom Elements) corresponding to the given type
@@ -812,12 +832,12 @@ void DicomDir::CreateDicomDir()
          continue;
       }
 
-      if( si )
-         MoveSQItem(si,tmpSI);
+      //if( si )
+         //MoveSQItem(si,tmpSI);
       tmpSI=s->GetNextSQItem();
    }
 // friend hunting : this one will be difficult to remove !
-   TagHT.clear();
+   ClearEntry();
 }
 
 /**
@@ -863,14 +883,6 @@ bool DicomDir::AddSerieToEnd(DicomDirSerie *dd)
          study->AddSerie(dd);
          return true;
       }
-/*      if( (*itp)->GetDicomDirStudies().size() > 0 )
-      {
-         ListDicomDirStudy::const_iterator itst = 
-            (*itp)->GetDicomDirStudies().end();
-         itst--;
-         (*itst)->AddSerie(dd);
-         return true;
-      }*/
    }
    return false;
 }
@@ -896,20 +908,6 @@ bool DicomDir::AddImageToEnd(DicomDirImage *dd)
             return true;
          }
       }
-/*      if( (*itp)->GetDicomDirStudies().size() > 0 )
-      {
-         ListDicomDirStudy::const_iterator itst = 
-            (*itp)->GetDicomDirStudies().end();
-         itst--;
-
-         if( (*itst)->GetDicomDirSeries().size() > 0 )
-         {
-            ListDicomDirSerie::const_iterator its = (*itst)->GetDicomDirSeries().end();
-            its--;
-            (*its)->AddImage(dd);
-            return true;
-         }
-      }*/
    }
    return false;
 }
@@ -921,8 +919,8 @@ bool DicomDir::AddImageToEnd(DicomDirImage *dd)
  */
 void DicomDir::SetElements(std::string const & path, VectDocument const &list)
 {
-   TagHT.clear();
-   Patients.clear();
+   ClearEntry();
+   ClearPatient();
 
    std::string patPrevName         = "", patPrevID  = "";
    std::string studPrevInstanceUID = "", studPrevID = "";
@@ -985,7 +983,7 @@ void DicomDir::SetElements(std::string const & path, VectDocument const &list)
  * @param dst destination SQItem
  * @param src source SQItem
  */
-void DicomDir::MoveSQItem(SQItem *dst,SQItem *src)
+void DicomDir::MoveSQItem(DocEntrySet *dst,DocEntrySet *src)
 {
    DocEntry *entry;
 
index f3f9b073e4f48101e4d9ec85dbad3629a886543d..39c703b8595a924ba525f4ea9c75c82966e69ee4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/20 11:09:23 $
-  Version:   $Revision: 1.49 $
+  Date:      $Date: 2005/01/25 11:11:58 $
+  Version:   $Revision: 1.50 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -100,6 +100,9 @@ public:
    DicomDirMeta    *NewMeta();
    DicomDirPatient *NewPatient();
 
+   /// Removing
+   void ClearPatient();
+
    /// Write  
    bool WriteDicomDir(std::string const &fileName);
 
@@ -132,7 +135,7 @@ private:
    void SetElements(std::string const &path, VectDocument const &list);
    void SetElement (std::string const &path, DicomDirType type,
                     Document *header);
-   void MoveSQItem(SQItem *dst,SQItem *src);
+   void MoveSQItem(DocEntrySet *dst,DocEntrySet *src);
 
    static bool HeaderLessThan(Document *header1, Document *header2);
    
index ceeea5b4fe4179e6a699b5712105b98d5c8c3f73..9a339e21f4ed7b59afea54045f30e40a638d4e44 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirPatient.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/23 10:12:33 $
-  Version:   $Revision: 1.31 $
+  Date:      $Date: 2005/01/25 11:11:58 $
+  Version:   $Revision: 1.32 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -47,12 +47,7 @@ DicomDirPatient::DicomDirPatient(bool empty):
  */
 DicomDirPatient::~DicomDirPatient() 
 {
-   for(ListDicomDirStudy::const_iterator cc = Studies.begin();
-                                         cc != Studies.end(); 
-                                       ++cc )
-   {
-      delete *cc;
-   }
+   ClearStudy();
 }
 
 //-----------------------------------------------------------------------------
@@ -106,6 +101,20 @@ DicomDirStudy* DicomDirPatient::NewStudy()
    return st; 
 }   
 
+/**
+ * \brief  Remove all studies in the patient 
+ */
+void DicomDirPatient::ClearStudy()
+{
+   for(ListDicomDirStudy::const_iterator cc = Studies.begin();
+                                         cc != Studies.end(); 
+                                       ++cc )
+   {
+      delete *cc;
+   }
+   Studies.clear();
+}
+
 /**
  * \brief   Get the first entry while visiting the DicomDirStudy
  * \return  The first DicomDirStudy if found, otherwhise NULL
index d1f9ebfe38f514622b2440275087ef83ea120de9..5ef17805aa867d0bb9346d1faad6f32c5733c9f6 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirPatient.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/20 16:16:42 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2005/01/25 11:11:58 $
+  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
@@ -49,8 +49,9 @@ public:
 
    /// adds the passed STUDY to the STUDY chained List for this PATIENT.
    void AddStudy(DicomDirStudy *obj) { Studies.push_back(obj); };
-
    DicomDirStudy *NewStudy(); 
+
+   void ClearStudy();
          
 private:
 
index 5b0b3179cea36d1ee4c1b03337f472c03f83be60..a03c64800f76bcff2b74821fc417933e0c82ff8e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirSerie.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/23 10:12:33 $
-  Version:   $Revision: 1.33 $
+  Date:      $Date: 2005/01/25 11:11:58 $
+  Version:   $Revision: 1.34 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -46,12 +46,7 @@ DicomDirSerie::DicomDirSerie(bool empty):
  */
 DicomDirSerie::~DicomDirSerie() 
 {
-   for(ListDicomDirImage::iterator cc = Images.begin();
-                                   cc != Images.end();
-                                   ++cc)
-   {
-      delete *cc;
-   }
+   ClearImage();
 }
 
 //-----------------------------------------------------------------------------
@@ -95,7 +90,8 @@ void DicomDirSerie::WriteContent(std::ofstream *fp, FileType t)
 }
 
 /**
- * \brief   adds a new Image (with the basic elements) to a partially created DICOMDIR
+ * \brief   adds a new Image (with the basic elements) to a partially created 
+ *          DICOMDIR
  */
 DicomDirImage *DicomDirSerie::NewImage()
 {
@@ -104,6 +100,20 @@ DicomDirImage *DicomDirSerie::NewImage()
    return st;   
 }
 
+/**
+ * \brief  Remove all images in the serie 
+ */
+void DicomDirSerie::ClearImage()
+{
+   for(ListDicomDirImage::iterator cc = Images.begin();
+                                   cc != Images.end();
+                                   ++cc)
+   {
+      delete *cc;
+   }
+   Images.clear();
+}
+
 /**
  * \brief   Get the first entry while visiting the DicomDirImage
  * \return  The first DicomDirImage if found, otherwhise NULL
index c87f0037a94ddaeeccb151675abe3bd1af6d0828..97b67cb96f91dce88eec14cee04f27f821565ba9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirSerie.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/20 16:16:42 $
-  Version:   $Revision: 1.23 $
+  Date:      $Date: 2005/01/25 11:11:58 $
+  Version:   $Revision: 1.24 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -48,9 +48,10 @@ public:
         
    /// adds the passed IMAGE to the IMAGE chained List for this SERIE.    
    void AddImage(DicomDirImage *obj) { Images.push_back(obj); };
-
    DicomDirImage *NewImage();
 
+   void ClearImage();
+
 private:
 
    ///chained list of DicomDirImages (to be exploited recursively)
index b2ef75232fb7aeb66e340c5edf1ab671a6697fd8..058879eec7b5786f32e60c76a0c5d5536a62c9df 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirStudy.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/23 10:12:33 $
-  Version:   $Revision: 1.30 $
+  Date:      $Date: 2005/01/25 11:11:58 $
+  Version:   $Revision: 1.31 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -45,12 +45,7 @@ DicomDirStudy::DicomDirStudy(bool empty):
  */
 DicomDirStudy::~DicomDirStudy() 
 {
-   for(ListDicomDirSerie::iterator cc = Series.begin();
-                                   cc != Series.end();
-                                 ++cc )
-   {
-      delete *cc;
-   }
+   ClearSerie();
 }
 
 //-----------------------------------------------------------------------------
@@ -106,6 +101,20 @@ DicomDirSerie *DicomDirStudy::NewSerie()
    return st;
 } 
 
+/**
+ * \brief  Remove all series in the study 
+ */
+void DicomDirStudy::ClearSerie()
+{
+   for(ListDicomDirSerie::iterator cc = Series.begin();
+                                   cc != Series.end();
+                                 ++cc )
+   {
+      delete *cc;
+   }
+   Series.clear();
+}
+
 /**
  * \brief   Get the first entry while visiting the DicomDirSeries
  * \return  The first DicomDirSerie if found, otherwhise NULL
index ae743881a0729d44a7bbf3ceddf6a015c4c3c701..0e38bf5c6711d6be75597a3f13c7cd2ec2c59fc2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDirStudy.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/20 16:16:42 $
-  Version:   $Revision: 1.21 $
+  Date:      $Date: 2005/01/25 11:11:58 $
+  Version:   $Revision: 1.22 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -48,8 +48,9 @@ public:
 
    /// adds the passed SERIE to the SERIE chained List for this STUDY.
    void AddSerie(DicomDirSerie *obj) { Series.push_back(obj); };
-
    DicomDirSerie* NewSerie();
+
+   void ClearSerie();
     
 private:
 
index 16cc0e9954b7c4e4286c652abe0004eb592d1475..e1b94f2a483fbd06f13429615131d819f31335bb 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntrySet.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:10:52 $
-  Version:   $Revision: 1.42 $
+  Date:      $Date: 2005/01/25 11:11:58 $
+  Version:   $Revision: 1.43 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -64,6 +64,9 @@ public:
 
    // ------- '... =0;' stands for 'Pure Virtual'
 
+   /// \brief Remove all Entry in the entry set
+   virtual void ClearEntry() = 0;
+
    /// \brief adds any type of entry to the entry set
    virtual bool AddEntry(DocEntry *Entry) = 0;
 
@@ -96,6 +99,9 @@ public:
    ///        identified by its (group,elem) - Sorry for the name !...-
    virtual std::string GetEntryValue(uint16_t group, uint16_t elem) = 0;
 
+   virtual DocEntry *GetFirstEntry()=0;
+   virtual DocEntry *GetNextEntry()=0;
+
    DictEntry *NewVirtualDictEntry(uint16_t group, 
                                   uint16_t elem,
                                   TagName const &vr     = GDCM_UNKNOWN,
index 1065a2ed8d94f44d4067d0ef50d93a9add4172de..1acf58f1c2de5146fe11d73153e934a323fb0c5d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:43:06 $
-  Version:   $Revision: 1.207 $
+  Date:      $Date: 2005/01/25 11:11:58 $
+  Version:   $Revision: 1.208 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1030,7 +1030,8 @@ void Document::ParseDES(DocEntrySet *set, long offset,
       {
          if ( newBinEntry )
          {
-            if ( Filetype == ExplicitVR && ! Global::GetVR()->IsVROfBinaryRepresentable(vr) )
+            if ( Filetype == ExplicitVR && 
+                 !Global::GetVR()->IsVROfBinaryRepresentable(vr) )
             { 
                 ////// Neither ValEntry NOR BinEntry: should mean UNKOWN VR
                 gdcmVerboseMacro( std::hex << newDocEntry->GetGroup() 
@@ -1171,14 +1172,19 @@ void Document::ParseDES(DocEntrySet *set, long offset,
                      newDocEntry->GetOffset(),
                      l, delim_mode);
          }
-         set->AddEntry( newSeqEntry );
+         if( !set->AddEntry( newSeqEntry ) )
+         {
+            used = false;
+         }
          if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max)
          {
+            if( !used )
+               delete newDocEntry;
             break;
          }
       }
 
-      if(!used)
+      if( !used )
          delete newDocEntry;
    }
 }
index f419aed920cb10b58b2738a4ccf1c2dee929d59e..0b634fa7073d1563a13aa957228d70667ef44671 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:10:52 $
-  Version:   $Revision: 1.49 $
+  Date:      $Date: 2005/01/25 11:11:59 $
+  Version:   $Revision: 1.50 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -42,14 +42,7 @@ ElementSet::ElementSet(int depthLevel)
  */
 ElementSet::~ElementSet() 
 {
-   for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc)
-   {
-      if ( cc->second )
-      {
-         delete cc->second;
-      }
-   }
-   TagHT.clear();
+   ClearEntry();
 }
 
 //-----------------------------------------------------------------------------
@@ -183,10 +176,6 @@ SeqEntry *ElementSet::GetSeqEntry(uint16_t group, uint16_t elem)
    return 0;
 }
 
-
-//-----------------------------------------------------------------------------
-// Protected
-
 /**
  * \brief   Checks if a given Dicom Element exists within the H table
  * @param   group   Group number of the searched Dicom Element 
@@ -217,9 +206,20 @@ std::string ElementSet::GetEntryValue(uint16_t group, uint16_t elem)
    return ((ValEntry *)TagHT.find(key)->second)->GetValue();
 }
 
-
-//-----------------------------------------------------------------------------
-// Private
+/**
+ * \brief   delete all entries in the ElementSet
+ */
+void ElementSet::ClearEntry()
+{
+   for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc)
+   {
+      if ( cc->second )
+      {
+         delete cc->second;
+      }
+   }
+   TagHT.clear();
+}
 
 /**
  * \brief   add a new Dicom Element pointer to the H Table
@@ -305,7 +305,6 @@ DocEntry *ElementSet::GetNextEntry()
    return NULL;
 }
 
-
 /**
  * \brief   Get the larst entry while visiting the DocEntrySet
  * \return  The last DocEntry if found, otherwhise NULL
@@ -333,6 +332,11 @@ DocEntry *ElementSet::GetPreviousEntry()
    return NULL;
 }
 
+//-----------------------------------------------------------------------------
+// Protected
+
+//-----------------------------------------------------------------------------
+// Private
 
 //-----------------------------------------------------------------------------
 } // end namespace gdcm
index 0bb3ac648593bea967e49265da2f237c6047c321..0f6e5d500bdf656aa5d382a287373cb826f0b658 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:10:52 $
-  Version:   $Revision: 1.36 $
+  Date:      $Date: 2005/01/25 11:11:59 $
+  Version:   $Revision: 1.37 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,6 +49,7 @@ public:
 
    virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" ); 
 
+   void ClearEntry();
    bool AddEntry(DocEntry *Entry);
    bool RemoveEntry(DocEntry *EntryToRemove);
    bool RemoveEntryNoDestroy(DocEntry *EntryToRemove);
index b63b376a44d153d512b895742fd5cb6f9be9c9b6..0c1cb641eb58b267eb649b2dce72734c809eb74f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:44:54 $
-  Version:   $Revision: 1.58 $
+  Date:      $Date: 2005/01/25 11:11:59 $
+  Version:   $Revision: 1.59 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -38,6 +38,7 @@ SQItem::SQItem(int depthLevel )
           : DocEntrySet( )
 {
    SQDepthLevel = depthLevel;
+   SQItemNumber = 0;
 }
 
 /**
@@ -45,13 +46,7 @@ SQItem::SQItem(int depthLevel )
  */
 SQItem::~SQItem() 
 {
-   for(ListDocEntry::iterator cc = DocEntries.begin();
-                             cc != DocEntries.end();
-                             ++cc)
-   {
-      delete *cc;
-   }
-   DocEntries.clear();
+   ClearEntry();
 }
 
 //-----------------------------------------------------------------------------
@@ -145,6 +140,20 @@ void SQItem::WriteContent(std::ofstream *fp, FileType filetype)
 
 //-----------------------------------------------------------------------------
 // Public
+/**
+ * \brief  Remove all entry in the Sequence Item 
+ */
+void SQItem::ClearEntry()
+{
+   for(ListDocEntry::iterator cc = DocEntries.begin();
+                             cc != DocEntries.end();
+                             ++cc)
+   {
+      delete *cc;
+   }
+   DocEntries.clear();
+}
+
 /**
  * \brief   adds any Entry (Dicom Element) to the Sequence Item
  * @param entry Entry to add
index ea09143edec01bc99ea30a4d3d8671fdae5f2118..de9fa1f0133d6ae537fbc4511320e5ed290c3d61 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/24 16:10:53 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2005/01/25 11:11:59 $
+  Version:   $Revision: 1.36 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,8 +49,7 @@ public:
    /// \brief   returns the DocEntry chained List for this SQ Item.
    ListDocEntry const &GetDocEntries() const { return DocEntries; };
    
-   /// \brief   adds the passed DocEntry to the DocEntry chained List for
-   /// this SQ Item.      
+   void ClearEntry();
    bool AddEntry(DocEntry *Entry); // add to the List
    bool RemoveEntry(DocEntry *EntryToRemove);
    bool RemoveEntryNoDestroy(DocEntry *EntryToRemove);