From 4f189b7cd8d7aff962887245b7b30ede39b7856c Mon Sep 17 00:00:00 2001 From: regrain Date: Mon, 24 Oct 2005 16:00:46 +0000 Subject: [PATCH] * Change the DocEntry inheritance to RefCounter -- BeNours --- Testing/TestDataEntry.cxx | 100 ++++++++++++++++++------------------ Testing/TestInline.cxx | 34 ++++-------- src/gdcmDataEntry.h | 15 ++++-- src/gdcmDicomDir.cxx | 12 +++-- src/gdcmDicomDirObject.cxx | 7 +-- src/gdcmDocEntry.h | 16 +++--- src/gdcmDocEntryArchive.cxx | 26 +++++++--- src/gdcmDocEntrySet.cxx | 16 +++--- src/gdcmDocEntrySet.h | 6 +-- src/gdcmDocument.cxx | 22 ++++---- src/gdcmElementSet.cxx | 28 ++-------- src/gdcmElementSet.h | 5 +- src/gdcmFile.cxx | 19 +++---- src/gdcmFileHelper.cxx | 47 ++++++++++++----- src/gdcmSQItem.cxx | 50 ++++-------------- src/gdcmSQItem.h | 6 +-- src/gdcmSeqEntry.cxx | 22 ++++++-- src/gdcmSeqEntry.h | 21 +++++--- 18 files changed, 226 insertions(+), 226 deletions(-) diff --git a/Testing/TestDataEntry.cxx b/Testing/TestDataEntry.cxx index 73ad2d4c..f0dc13f5 100644 --- a/Testing/TestDataEntry.cxx +++ b/Testing/TestDataEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestDataEntry.cxx,v $ Language: C++ - Date: $Date: 2005/10/24 01:17:54 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/10/24 16:00:46 $ + Version: $Revision: 1.9 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -43,7 +43,7 @@ int TestDataEntry(int , char *[]) //------------------------------------------------------------------ dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + entry = gdcm::DataEntry::New(dict); dict->SetVR("US"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -59,7 +59,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: 1" << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } @@ -74,7 +74,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: 2" << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } @@ -89,17 +89,17 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: 0" << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + entry = gdcm::DataEntry::New(dict); dict->SetVR("LT"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -114,7 +114,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetLength() << " - Must be: " << strlen(data) + strlen(data)%2 << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -124,7 +124,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetBinArea(),data,entry->GetLength()) != 0 ) @@ -132,7 +132,7 @@ int TestDataEntry(int , char *[]) std::cout << " Failed" << std::endl << " Content of bin area is incorrect" << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetString().c_str(),data,entry->GetLength()) != 0 ) @@ -142,7 +142,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << data << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -154,18 +154,18 @@ int TestDataEntry(int , char *[]) << " Found " << entry->GetValue(i) << " - Must be " << svalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + entry = gdcm::DataEntry::New(dict); dict->SetVR("US"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -181,7 +181,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetLength() << " - Must be: " << nbvalue*sizeof(uint16_t) << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 ) @@ -191,7 +191,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << data << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -201,7 +201,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -213,7 +213,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << svalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -231,7 +231,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << data << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -241,7 +241,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -253,18 +253,18 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << svalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + entry = gdcm::DataEntry::New(dict); dict->SetVR("UL"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -280,7 +280,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetLength() << " - Must be: " << nbvalue*sizeof(uint32_t) << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetString().c_str(),data,strlen(data)) != 0 ) @@ -290,7 +290,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << data << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -300,7 +300,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -312,7 +312,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << lvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -330,7 +330,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << data << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -340,7 +340,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -352,18 +352,18 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << lvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + entry = gdcm::DataEntry::New(dict); dict->SetVR("FL"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -379,7 +379,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetLength() << " - Must be: " << nbvalue*sizeof(float) << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 ) @@ -389,7 +389,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << fdata << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -399,7 +399,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -411,7 +411,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << fvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -429,7 +429,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << fdata << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -439,7 +439,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -451,18 +451,18 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << fvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ dict = gdcm::DictEntry::New(0x0000,0x0000); - entry = new gdcm::DataEntry(dict); + entry = gdcm::DataEntry::New(dict); dict->SetVR("FD"); std::cout << "Test for VR = " << dict->GetVR() << "..." << std::endl; @@ -478,7 +478,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetLength() << " - Must be: " << nbvalue*sizeof(double) << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( memcmp(entry->GetString().c_str(),fdata,strlen(fdata)) != 0 ) @@ -488,7 +488,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << fdata << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -498,7 +498,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -512,7 +512,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << dvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } @@ -530,7 +530,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetString().c_str() << " - Must be: " << fdata << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } if( entry->GetValueCount() != nbvalue ) @@ -540,7 +540,7 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValueCount() << " - Must be: " << nbvalue << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } for(i=0;iGetValueCount();i++) @@ -552,14 +552,14 @@ int TestDataEntry(int , char *[]) << " Found: " << entry->GetValue(i) << " - Must be: " << dvalue[i] << std::endl; dict->Delete(); - delete entry; + entry->Delete(); return 1; } } std::cout << std::endl; dict->Delete(); - delete entry; + entry->Delete(); //------------------------------------------------------------------ std::cout< -#include +/*#include #ifdef CMAKE_HAVE_SYS_TIMES_H #include #else @@ -57,28 +57,6 @@ double passDirect(double a, double b); double passRef(double &a, double &b); double passPtr(double *a, double *b); -/* -//To perform a full check, just put the two 'static' functions -//hifpswap and hNoifpswap in a .h - - static inline void hifpswap(double *a, double *b) - { - double tmp; - tmp = *a; - *a = *b; - *b = tmp; - } - - static void hNoifpswap(double *a, double *b) - { - double tmp; - tmp = *a; - *a = *b; - *b = tmp; - } - -*/ - #define \ mswap(a, b) \ { \ @@ -412,3 +390,9 @@ int TestInline(int argc, char *argv[]) return 0; } +*/ + +int TestInline(int argc, char *argv[]) +{ + return 0; +} diff --git a/src/gdcmDataEntry.h b/src/gdcmDataEntry.h index f8882df9..d9e71a3a 100644 --- a/src/gdcmDataEntry.h +++ b/src/gdcmDataEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDataEntry.h,v $ Language: C++ - Date: $Date: 2005/10/23 15:32:30 $ - Version: $Revision: 1.4 $ + Date: $Date: 2005/10/24 16:00:47 $ + Version: $Revision: 1.5 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -35,10 +35,11 @@ namespace gdcm */ class GDCM_EXPORT DataEntry : public DocEntry { + gdcmTypeMacro(DataEntry); + public: - DataEntry(DictEntry *e); - DataEntry(DocEntry *d); - ~DataEntry(); + static DataEntry *New(DictEntry *e) {return new DataEntry(e);} + static DataEntry *New(DocEntry *d) {return new DataEntry(d);} // Print void Print(std::ostream &os = std::cout, std::string const &indent = ""); @@ -118,6 +119,10 @@ public: } TValueFlag; protected: + DataEntry(DictEntry *e); + DataEntry(DocEntry *d); + ~DataEntry(); + // Methods : void NewBinArea(void); void DeleteBinArea(void); diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index ee3fb0eb..f002e6f7 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/10/21 16:02:01 $ - Version: $Revision: 1.164 $ + Date: $Date: 2005/10/24 16:00:47 $ + Version: $Revision: 1.165 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -319,7 +319,7 @@ DicomDirMeta *DicomDir::NewMeta() if ( dynamic_cast(entry) ) break; - RemoveEntryNoDestroy(entry); + RemoveEntry(entry); MetaElems->AddEntry(entry); entry = GetFirstEntry(); @@ -737,6 +737,7 @@ void DicomDir::CreateDicomDir() // 3 - we find an other tag // + we create the object for the precedent tag // + loop to 1 - + gdcmDebugMacro("Create DicomDir"); // Directory record sequence DocEntry *e = GetDocEntry(0x0004, 0x1220); @@ -1092,7 +1093,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, tmpEl = it->Elem; dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl); - entry = new DataEntry( dictEntry ); // Be sure it's never a DataEntry ! + entry = DataEntry::New( dictEntry ); // Be sure it's never a DataEntry ! entry->SetOffset(0); // just to avoid further missprinting @@ -1144,6 +1145,7 @@ void DicomDir::SetElement(std::string const &path, DicomDirType type, gdcmWarningMacro("GDCM_DICOMDIR_META ?!? should never print that"); } si->AddEntry(entry); + entry->Delete(); } } @@ -1160,7 +1162,7 @@ void DicomDir::MoveSQItem(DocEntrySet *dst,DocEntrySet *src) entry = src->GetFirstEntry(); while(entry) { - src->RemoveEntryNoDestroy(entry); + src->RemoveEntry(entry); dst->AddEntry(entry); // we destroyed -> the current iterator is not longer valid entry = src->GetFirstEntry(); diff --git a/src/gdcmDicomDirObject.cxx b/src/gdcmDicomDirObject.cxx index e5300269..b287b7f7 100644 --- a/src/gdcmDicomDirObject.cxx +++ b/src/gdcmDicomDirObject.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDirObject.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:49 $ - Version: $Revision: 1.21 $ + Date: $Date: 2005/10/24 16:00:47 $ + 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 @@ -67,11 +67,12 @@ void DicomDirObject::FillObject(ListDicomDirMetaElem const &elemList) tmpGr = it->Group; tmpEl = it->Elem; dictEntry = Global::GetDicts()->GetDefaultPubDict()->GetEntry(tmpGr,tmpEl); - entry = new DataEntry(dictEntry); + entry = DataEntry::New(dictEntry); entry->SetOffset(0); // just to avoid further missprinting entry->SetString(it->Value); AddEntry(entry); + entry->Delete(); } } diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index 6791b02e..b779a89a 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.h,v $ Language: C++ - Date: $Date: 2005/10/23 15:32:31 $ - Version: $Revision: 1.54 $ + Date: $Date: 2005/10/24 16:00:47 $ + Version: $Revision: 1.55 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,7 +19,7 @@ #ifndef GDCMDOCENTRY_H #define GDCMDOCENTRY_H -#include "gdcmBase.h" +#include "gdcmRefCounter.h" #include "gdcmDictEntry.h" #include @@ -35,12 +35,11 @@ class SeqEntry; * \brief The dicom header of a Dicom file contains a set of such entries * (when successfuly parsed against a given Dicom dictionary) */ -class GDCM_EXPORT DocEntry : public Base +class GDCM_EXPORT DocEntry : public RefCounter { -public: - DocEntry(DictEntry*); - virtual ~DocEntry(); + gdcmTypeMacro(DocEntry); +public: virtual void Print (std::ostream &os = std::cout, std::string const &indent = ""); virtual void WriteContent(std::ofstream *fp, FileType filetype); @@ -126,6 +125,9 @@ public: virtual void Copy(DocEntry *e); protected: + DocEntry(DictEntry*); + virtual ~DocEntry(); + /// \brief pointer to the underlying Dicom dictionary element DictEntry *DicomDict; diff --git a/src/gdcmDocEntryArchive.cxx b/src/gdcmDocEntryArchive.cxx index 0e9b2d53..c82a1e96 100644 --- a/src/gdcmDocEntryArchive.cxx +++ b/src/gdcmDocEntryArchive.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntryArchive.cxx,v $ Language: C++ - Date: $Date: 2005/07/11 14:40:40 $ - Version: $Revision: 1.16 $ + Date: $Date: 2005/10/24 16:00:47 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -66,7 +66,10 @@ bool DocEntryArchive::Push(DocEntry *newEntry) DocEntry *old = ArchFile->GetDocEntry(group, elem); Archive[key] = old; if ( old ) - ArchFile->RemoveEntryNoDestroy(old); + { + old->Register(); + ArchFile->RemoveEntry(old); + } // Set the new DocEntry ArchFile->AddEntry(newEntry); @@ -94,7 +97,10 @@ bool DocEntryArchive::Push(uint16_t group, uint16_t elem) DocEntry *old = ArchFile->GetDocEntry(group, elem); Archive[key] = old; if ( old ) - ArchFile->RemoveEntryNoDestroy(old); + { + old->Register(); + ArchFile->RemoveEntry(old); + } return true; } @@ -119,11 +125,16 @@ bool DocEntryArchive::Restore(uint16_t group, uint16_t elem) // Delete the new value DocEntry *rem = ArchFile->GetDocEntry(group, elem); if ( rem ) + { ArchFile->RemoveEntry(rem); + } // Restore the old value - if ( Archive[key] ) - ArchFile->AddEntry(Archive[key]); + if ( restoreIt->second ) + { + ArchFile->AddEntry(restoreIt->second); + restoreIt->second->Unregister(); + } Archive.erase(restoreIt); @@ -142,7 +153,8 @@ void DocEntryArchive::ClearArchive( ) it!=Archive.end(); ++it) { - delete it->second; + if(it->second) + it->second->Unregister(); } Archive.clear(); } diff --git a/src/gdcmDocEntrySet.cxx b/src/gdcmDocEntrySet.cxx index b3cfe401..cc91b75f 100644 --- a/src/gdcmDocEntrySet.cxx +++ b/src/gdcmDocEntrySet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.cxx,v $ Language: C++ - Date: $Date: 2005/10/21 10:48:16 $ - Version: $Revision: 1.64 $ + Date: $Date: 2005/10/24 16:00:47 $ + Version: $Revision: 1.65 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -287,7 +287,7 @@ DataEntry *DocEntrySet::InsertEntryString(std::string const &value, { gdcmWarningMacro("AddEntry failed although this is a creation."); - delete dataEntry; + dataEntry->Delete(); return NULL; } } @@ -346,7 +346,7 @@ DataEntry *DocEntrySet::InsertEntryBinArea(uint8_t *binArea, int lgth, { gdcmWarningMacro( "AddEntry failed although this is a creation."); - delete dataEntry; + dataEntry->Delete(); return NULL; } } @@ -415,7 +415,7 @@ SeqEntry *DocEntrySet::InsertSeqEntry(uint16_t group, uint16_t elem) { gdcmWarningMacro( "AddEntry failed although this is a creation."); - delete seqEntry; + seqEntry->Delete(); return NULL; } } @@ -443,13 +443,14 @@ bool DocEntrySet::CheckIfEntryExist(uint16_t group, uint16_t elem ) * @param group Group number of the new Entry * @param elem Element number of the new Entry * @param vr V(alue) R(epresentation) of the new Entry + * \remarks The user of this method must destroy the DataEntry when unused */ DataEntry *DocEntrySet::NewDataEntry(uint16_t group,uint16_t elem, VRKey const &vr) { DictEntry *dictEntry = GetDictEntry(group, elem, vr); - DataEntry *newEntry = new DataEntry(dictEntry); + DataEntry *newEntry = DataEntry::New(dictEntry); dictEntry->Unregister(); // GetDictEntry register it if (!newEntry) { @@ -465,12 +466,13 @@ DataEntry *DocEntrySet::NewDataEntry(uint16_t group,uint16_t elem, * a default one when absent. * @param group Group number of the new Entry * @param elem Element number of the new Entry + * \remarks The user of this method must destroy the SeqEntry when unused */ SeqEntry* DocEntrySet::NewSeqEntry(uint16_t group, uint16_t elem) { DictEntry *dictEntry = GetDictEntry(group, elem, "SQ"); - SeqEntry *newEntry = new SeqEntry( dictEntry ); + SeqEntry *newEntry = SeqEntry::New( dictEntry ); dictEntry->Unregister(); // GetDictEntry register it if (!newEntry) { diff --git a/src/gdcmDocEntrySet.h b/src/gdcmDocEntrySet.h index 0173958a..3448c892 100644 --- a/src/gdcmDocEntrySet.h +++ b/src/gdcmDocEntrySet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntrySet.h,v $ Language: C++ - Date: $Date: 2005/10/20 15:24:09 $ - Version: $Revision: 1.60 $ + Date: $Date: 2005/10/24 16:00:47 $ + Version: $Revision: 1.61 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -73,8 +73,6 @@ public: virtual bool AddEntry(DocEntry *entry) = 0; /// \brief Removes any type of entry out of the entry set, and destroys it virtual bool RemoveEntry(DocEntry *entryToRemove) = 0; - /// \brief Removes any type of entry out of the entry set, DOESN'T destroy it - virtual bool RemoveEntryNoDestroy(DocEntry *entryToRemove) = 0; /// Gets the first entry of any type of set virtual DocEntry *GetFirstEntry()=0; /// Gets the next entry of any type of set diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index d4410d1b..665604a2 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2005/10/23 15:28:26 $ - Version: $Revision: 1.303 $ + Date: $Date: 2005/10/24 16:00:47 $ + Version: $Revision: 1.304 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1057,7 +1057,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, (!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) ) { if ( !used ) - delete newDocEntry; + newDocEntry->Delete(); break; } @@ -1087,7 +1087,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, if ( newDocEntry->GetGroup()%2 != 0 ) { Fp->seekg( l, std::ios::cur); - delete newDocEntry; // Delete, not in the set + newDocEntry->Delete(); // Delete, not in the set continue; } } @@ -1095,7 +1095,7 @@ void Document::ParseDES(DocEntrySet *set, long offset, { // User asked to skip *any* SeQuence Fp->seekg( l, std::ios::cur); - delete newDocEntry; // Delete, not in the set + newDocEntry->Delete(); // Delete, not in the set continue; } // delay the dynamic cast as late as possible @@ -1148,14 +1148,14 @@ void Document::ParseDES(DocEntrySet *set, long offset, if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) { if ( !used ) - delete newDocEntry; + newDocEntry->Delete(); break; } } // end SeqEntry : VR = "SQ" if ( !used ) { - delete newDocEntry; + newDocEntry->Delete(); } first = false; } // end While @@ -1194,7 +1194,7 @@ void Document::ParseSQ( SeqEntry *seqEntry, } if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max) { - delete newDocEntry; + newDocEntry->Delete(); break; } // create the current SQItem @@ -1212,7 +1212,7 @@ void Document::ParseSQ( SeqEntry *seqEntry, // Let's try :------------ // remove fff0,e000, created out of the SQItem - delete newDocEntry; + newDocEntry->Delete(); Fp->seekg(offsetStartCurrentSQItem, std::ios::beg); // fill up the current SQItem, starting at the beginning of fff0,e000 @@ -1240,7 +1240,7 @@ DocEntry *Document::Backtrack(DocEntry *docEntry) { // delete the Item Starter, built erroneously out of any Sequence // it's not yet in the HTable/chained list - delete docEntry; + docEntry->Delete(); // Get all info we can from PreviousDocEntry uint16_t group = PreviousDocEntry->GetGroup(); @@ -2012,7 +2012,7 @@ DocEntry *Document::ReadNextDocEntry() catch ( FormatError ) { // Call it quits - delete newEntry; + newEntry->Delete(); return 0; } diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index 215589b8..6f1d9840 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 09:17:08 $ - Version: $Revision: 1.66 $ + Date: $Date: 2005/10/24 16:00:47 $ + Version: $Revision: 1.67 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -75,6 +75,7 @@ bool ElementSet::AddEntry(DocEntry *newEntry) else { TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry)); + newEntry->Register(); return true; } } @@ -89,8 +90,7 @@ bool ElementSet::RemoveEntry( DocEntry *entryToRemove) if ( TagHT.count(key) == 1 ) { TagHT.erase(key); - //gdcmWarningMacro( "One element erased."); - delete entryToRemove; + entryToRemove->Unregister(); return true; } @@ -98,24 +98,6 @@ bool ElementSet::RemoveEntry( DocEntry *entryToRemove) return false ; } -/** - * \brief Clear the hash table from given entry BUT keep the entry. - * @param entryToRemove Entry to remove. - */ -bool ElementSet::RemoveEntryNoDestroy(DocEntry *entryToRemove) -{ - const TagKey &key = entryToRemove->GetKey(); - if ( TagHT.count(key) == 1 ) - { - TagHT.erase(key); - //gdcmWarningMacro( "One element erased."); - return true; - } - - gdcmWarningMacro( "Key not present " << key); - return false ; -} - /** * \brief delete all entries in the ElementSet */ @@ -125,7 +107,7 @@ void ElementSet::ClearEntry() { if ( cc->second ) { - delete cc->second; + cc->second->Unregister(); } } TagHT.clear(); diff --git a/src/gdcmElementSet.h b/src/gdcmElementSet.h index fdcb3d0a..d924c6e8 100644 --- a/src/gdcmElementSet.h +++ b/src/gdcmElementSet.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.h,v $ Language: C++ - Date: $Date: 2005/10/18 09:17:08 $ - Version: $Revision: 1.47 $ + Date: $Date: 2005/10/24 16:00:47 $ + Version: $Revision: 1.48 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -52,7 +52,6 @@ public: bool AddEntry(DocEntry *Entry); bool RemoveEntry(DocEntry *EntryToRemove); - bool RemoveEntryNoDestroy(DocEntry *EntryToRemove); void ClearEntry(); DocEntry *GetFirstEntry(); diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index b26c57d8..189987ac 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2005/10/23 15:26:43 $ - Version: $Revision: 1.289 $ + Date: $Date: 2005/10/24 16:00:48 $ + Version: $Revision: 1.290 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -233,7 +233,7 @@ bool File::DoTheLoadingJob( ) DictEntry* newDict = DictEntry::New(GrPixel,NumPixel, PixelVR,"1","Pixel Data"); - DataEntry *newEntry = new DataEntry(newDict); + DataEntry *newEntry = DataEntry::New(newDict); newDict->Delete(); newEntry->Copy(entry); newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea()); @@ -241,6 +241,7 @@ bool File::DoTheLoadingJob( ) RemoveEntry(oldEntry); AddEntry(newEntry); + newEntry->Delete(); } } } @@ -630,7 +631,7 @@ float File::GetXOrigin() if( entry->GetValueCount() == 3 ) { - gdcmAssertMacro( entry->IsValueCountValid() ); + gdcmErrorMacro( entry->IsValueCountValid() ); return (float)entry->GetValue(0); } return 0.0f; @@ -658,7 +659,7 @@ float File::GetYOrigin() if( entry->GetValueCount() == 3 ) { - gdcmAssertMacro( entry->IsValueCountValid() ); + gdcmErrorMacro( entry->IsValueCountValid() ); return (float)entry->GetValue(1); } return 0.0f; @@ -679,7 +680,7 @@ float File::GetZOrigin() { if( entry->GetValueCount() == 3 ) { - gdcmAssertMacro( entry->IsValueCountValid() ); + gdcmErrorMacro( entry->IsValueCountValid() ); return (float)entry->GetValue(2); } gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)"); @@ -691,7 +692,7 @@ float File::GetZOrigin() { if( entry->GetValueCount() == 3 ) { - gdcmAssertMacro( entry->IsValueCountValid() ); + gdcmErrorMacro( entry->IsValueCountValid() ); return (float)entry->GetValue(2); } gdcmWarningMacro( "Wrong Image Position (RET) (0020,0030)"); @@ -704,7 +705,7 @@ float File::GetZOrigin() { if( entry->GetValueCount() == 1 ) { - gdcmAssertMacro( entry->IsValueCountValid() ); + gdcmErrorMacro( entry->IsValueCountValid() ); return (float)entry->GetValue(0); // VM=1 ! } gdcmWarningMacro( "Wrong Slice Location (0020,1041)"); @@ -716,7 +717,7 @@ float File::GetZOrigin() { if( entry->GetValueCount() == 1 ) { - gdcmAssertMacro( entry->IsValueCountValid() ); + gdcmErrorMacro( entry->IsValueCountValid() ); return (float)entry->GetValue(0); } gdcmWarningMacro( "Wrong Location (0020,0050)"); diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index e014d455..51d66886 100644 --- a/src/gdcmFileHelper.cxx +++ b/src/gdcmFileHelper.cxx @@ -4,8 +4,8 @@ Module: $RCSfile: gdcmFileHelper.cxx,v $ Language: C++ - Date: $Date: 2005/10/23 15:24:47 $ - Version: $Revision: 1.69 $ + Date: $Date: 2005/10/24 16:00:48 $ + Version: $Revision: 1.70 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -100,7 +100,7 @@ fh1->Write(newFileName); fp = opens file(fileName); ComputeGroup0002Length( ); BitsAllocated 12->16 - RemoveEntryNoDestroy(palettes, etc) + RemoveEntry(palettes, etc) Document::WriteContent(fp, writetype); RestoreWrite(); (moves back to the File all the archived elements) @@ -865,6 +865,9 @@ void FileHelper::SetWriteToRaw() Archive->Push(photInt); Archive->Push(pixel); + + photInt->Delete(); + pixel->Delete(); } } @@ -917,6 +920,11 @@ void FileHelper::SetWriteToRGB() Archive->Push(photInt); Archive->Push(pixel); + spp->Delete(); + planConfig->Delete(); + photInt->Delete(); + pixel->Delete(); + // Remove any LUT Archive->Push(0x0028,0x1101); Archive->Push(0x0028,0x1102); @@ -945,6 +953,10 @@ void FileHelper::SetWriteToRGB() Archive->Push(bitsAlloc); Archive->Push(bitsStored); Archive->Push(highBit); + + bitsAlloc->Delete(); + bitsStored->Delete(); + highBit->Delete(); } } else @@ -1026,6 +1038,7 @@ void FileHelper::SetWriteFileTypeToJPEG() tss->SetString(ts); Archive->Push(tss); + tss->Delete(); } void FileHelper::SetWriteFileTypeToExplicitVR() @@ -1037,6 +1050,7 @@ void FileHelper::SetWriteFileTypeToExplicitVR() tss->SetString(ts); Archive->Push(tss); + tss->Delete(); } /** @@ -1051,6 +1065,7 @@ void FileHelper::SetWriteFileTypeToImplicitVR() tss->SetString(ts); Archive->Push(tss); + tss->Delete(); } @@ -1073,8 +1088,8 @@ void FileHelper::SetWriteToLibido() { std::string rows, columns; - DataEntry *newRow=new DataEntry(oldRow->GetDictEntry()); - DataEntry *newCol=new DataEntry(oldCol->GetDictEntry()); + DataEntry *newRow=DataEntry::New(oldRow->GetDictEntry()); + DataEntry *newCol=DataEntry::New(oldCol->GetDictEntry()); newRow->Copy(oldCol); newCol->Copy(oldRow); @@ -1084,11 +1099,15 @@ void FileHelper::SetWriteToLibido() Archive->Push(newRow); Archive->Push(newCol); + + newRow->Delete(); + newCol->Delete(); } DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010); libidoCode->SetString("ACRNEMA_LIBIDO_1.1"); Archive->Push(libidoCode); + libidoCode->Delete(); } /** @@ -1104,6 +1123,7 @@ void FileHelper::SetWriteToNoLibido() DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010); libidoCode->SetString(""); Archive->Push(libidoCode); + libidoCode->Delete(); } } } @@ -1144,7 +1164,7 @@ DataEntry *FileHelper::CopyDataEntry(uint16_t group, uint16_t elem, if ( oldE ) { - newE = new DataEntry(oldE->GetDictEntry()); + newE = DataEntry::New(oldE->GetDictEntry()); newE->Copy(oldE); } else @@ -1288,19 +1308,19 @@ void FileHelper::CheckMandatoryElements() if ( e_0008_0016 ) { // Create 'Source Image Sequence' SeqEntry - SeqEntry *sis = new SeqEntry ( + SeqEntry *sis = SeqEntry::New ( Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x2112) ); SQItem *sqi = new SQItem(1); // (we assume 'SOP Instance UID' exists too) // create 'Referenced SOP Class UID' - DataEntry *e_0008_1150 = new DataEntry( + DataEntry *e_0008_1150 = DataEntry::New( Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1150) ); e_0008_1150->SetString( e_0008_0016->GetString()); sqi->AddEntry(e_0008_1150); // create 'Referenced SOP Instance UID' DataEntry *e_0008_0018 = FileInternal->GetDataEntry(0x0008, 0x0018); - DataEntry *e_0008_1155 = new DataEntry( + DataEntry *e_0008_1155 = DataEntry::New( Global::GetDicts()->GetDefaultPubDict()->GetEntry(0x0008, 0x1155) ); e_0008_1155->SetString( e_0008_0018->GetString()); sqi->AddEntry(e_0008_1155); @@ -1308,6 +1328,7 @@ void FileHelper::CheckMandatoryElements() sis->AddSQItem(sqi,1); // temporarily replaces any previous 'Source Image Sequence' Archive->Push(sis); + sis->Delete(); // 'Image Type' (The written image is no longer an 'ORIGINAL' one) CopyMandatoryEntry(0x0008,0x0008,"DERIVED\\PRIMARY"); @@ -1399,17 +1420,19 @@ void FileHelper::CheckMandatoryEntry(uint16_t group,uint16_t elem,std::string va DataEntry *entry = FileInternal->GetDataEntry(group,elem); if ( !entry ) { - entry = new DataEntry(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem)); + entry = DataEntry::New(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem)); entry->SetString(value); Archive->Push(entry); + entry->Delete(); } } void FileHelper::SetMandatoryEntry(uint16_t group,uint16_t elem,std::string value) { - DataEntry *entry = new DataEntry(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem)); + DataEntry *entry = DataEntry::New(Global::GetDicts()->GetDefaultPubDict()->GetEntry(group,elem)); entry->SetString(value); Archive->Push(entry); + entry->Delete(); } void FileHelper::CopyMandatoryEntry(uint16_t group,uint16_t elem,std::string value) @@ -1417,6 +1440,7 @@ void FileHelper::CopyMandatoryEntry(uint16_t group,uint16_t elem,std::string val DataEntry *entry = CopyDataEntry(group,elem); entry->SetString(value); Archive->Push(entry); + entry->Delete(); } /** @@ -1452,7 +1476,6 @@ void FileHelper::RestoreWriteMandatory() Archive->Restore(0x0020,0x000d); Archive->Restore(0x0020,0x000e); - } //----------------------------------------------------------------------------- diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index 0ed62981..7c8d61c6 100644 --- a/src/gdcmSQItem.cxx +++ b/src/gdcmSQItem.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:50 $ - Version: $Revision: 1.76 $ + Date: $Date: 2005/10/24 16:00:48 $ + Version: $Revision: 1.77 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -110,6 +110,7 @@ bool SQItem::AddEntry(DocEntry *entry) if (DocEntries.empty() ) { DocEntries.push_back(entry); + entry->Register(); return true; } @@ -131,9 +132,11 @@ bool SQItem::AddEntry(DocEntry *entry) break; } while (it != DocEntries.begin() ); - insertSpot = it++; - insertSpot++; // ?!? + ++it; + insertSpot = it; + //++insertSpot; // ?!? DocEntries.insert(insertSpot, entry); + entry->Register(); return true; } @@ -152,7 +155,7 @@ bool SQItem::RemoveEntry( DocEntry *entryToRemove ) { DocEntries.erase(it); gdcmWarningMacro( "One element erased: " << entryToRemove->GetKey() ); - delete entryToRemove; + entryToRemove->Unregister(); return true; } } @@ -160,30 +163,6 @@ bool SQItem::RemoveEntry( DocEntry *entryToRemove ) return false ; } -/** - * \brief Clear the std::list from given entry BUT keep the entry. - * @param entryToRemove Entry to remove. - * @return true if the entry was found and removed; false otherwise - */ -bool SQItem::RemoveEntryNoDestroy(DocEntry *entryToRemove) -{ - for(ListDocEntry::iterator it = DocEntries.begin(); - it != DocEntries.end(); - ++it) - { - if ( *it == entryToRemove ) - { - DocEntries.erase(it); - gdcmWarningMacro( "One element removed, no destroyed: " - << entryToRemove->GetKey() ); - return true; - } - } - - gdcmWarningMacro( "Entry not found:" << entryToRemove->GetKey() ); - return false ; -} - /** * \brief Remove all entry in the Sequence Item */ @@ -193,27 +172,18 @@ void SQItem::ClearEntry() cc != DocEntries.end(); ++cc) { - delete *cc; + (*cc)->Unregister(); } DocEntries.clear(); } -/** - * \brief Clear the std::list from given Sequence Item BUT keep the entries - */ -void SQItem::ClearEntryNoDestroy() -{ - DocEntries.clear(); -} - - /** * \brief Move all the entries from a given Sequence Item */ void SQItem::MoveObject(SQItem *source) { DocEntries = source->DocEntries; - source->ClearEntryNoDestroy(); + source->DocEntries.clear(); } /** diff --git a/src/gdcmSQItem.h b/src/gdcmSQItem.h index 4dca0cff..42567308 100644 --- a/src/gdcmSQItem.h +++ b/src/gdcmSQItem.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.h,v $ Language: C++ - Date: $Date: 2005/10/19 13:17:05 $ - Version: $Revision: 1.45 $ + Date: $Date: 2005/10/24 16:00:48 $ + Version: $Revision: 1.46 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -49,9 +49,7 @@ public: bool AddEntry(DocEntry *Entry); // add to the List bool RemoveEntry(DocEntry *EntryToRemove); - bool RemoveEntryNoDestroy(DocEntry *EntryToRemove); void ClearEntry(); - void ClearEntryNoDestroy(); void MoveObject(SQItem *source); DocEntry *GetFirstEntry(); diff --git a/src/gdcmSeqEntry.cxx b/src/gdcmSeqEntry.cxx index 0cfd3643..c0647f9d 100644 --- a/src/gdcmSeqEntry.cxx +++ b/src/gdcmSeqEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.cxx,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:50 $ - Version: $Revision: 1.58 $ + Date: $Date: 2005/10/24 16:00:48 $ + 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 @@ -129,7 +129,7 @@ void SeqEntry::ClearSQItem() } if (SeqTerm) { - delete SeqTerm; + SeqTerm->Unregister(); } } @@ -195,6 +195,22 @@ unsigned int SeqEntry::GetNumberOfSQItems() return Items.size(); } +/** + * \brief Sets the Sequence Delimitation Item + * \param e Delimitation item + */ +void SeqEntry::SetDelimitationItem(DocEntry *e) +{ + if( SeqTerm != e ) + { + if( SeqTerm ) + SeqTerm->Unregister(); + SeqTerm = e; + if( SeqTerm ) + SeqTerm->Register(); + } +} + //----------------------------------------------------------------------------- // Protected diff --git a/src/gdcmSeqEntry.h b/src/gdcmSeqEntry.h index cae73c89..7836f8c0 100644 --- a/src/gdcmSeqEntry.h +++ b/src/gdcmSeqEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.h,v $ Language: C++ - Date: $Date: 2005/10/18 08:35:50 $ - Version: $Revision: 1.35 $ + Date: $Date: 2005/10/24 16:00:48 $ + 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 @@ -39,11 +39,12 @@ typedef std::list ListSQItem; */ class GDCM_EXPORT SeqEntry : public DocEntry { + gdcmTypeMacro(SeqEntry); + public: - SeqEntry( DictEntry *e); - SeqEntry( DocEntry *d, int depth ); - ~SeqEntry(); - + static SeqEntry *New(DictEntry *e) {return new SeqEntry(e);} + static SeqEntry *New(DocEntry *d, int depth) {return new SeqEntry(d,depth);} + void Print(std::ostream &os = std::cout, std::string const &indent = "" ); void WriteContent(std::ofstream *fp, FileType filetype); @@ -57,8 +58,8 @@ public: /// Sets the delimitor mode void SetDelimitorMode(bool dm) { DelimitorMode = dm; } - /// Sets the Sequence Delimitation Item - void SetDelimitationItem(DocEntry *e) { SeqTerm = e; } + + void SetDelimitationItem(DocEntry *e); /// Gets the Sequence Delimitation Item DocEntry *GetDelimitationItem() { return SeqTerm;} @@ -71,6 +72,10 @@ public: protected: private: + SeqEntry( DictEntry *e); + SeqEntry( DocEntry *d, int depth ); + ~SeqEntry(); + // Variables /// If this Sequence is in delimitor mode (length =0xffffffff) or not bool DelimitorMode; -- 2.45.1