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
//------------------------------------------------------------------
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;
<< " Found: " << entry->GetValueCount()
<< " - Must be: 1" << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
<< " Found: " << entry->GetValueCount()
<< " - Must be: 2" << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
<< " 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;
<< " Found: " << entry->GetLength()
<< " - Must be: " << strlen(data) + strlen(data)%2 << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
if( entry->GetValueCount() != nbvalue )
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
if( memcmp(entry->GetBinArea(),data,entry->GetLength()) != 0 )
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 )
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << data << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
for(i=0;i<entry->GetValueCount();i++)
<< " 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;
<< " 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 )
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << data << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
if( entry->GetValueCount() != nbvalue )
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
for(i=0;i<entry->GetValueCount();i++)
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << svalue[i] << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
}
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << data << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
if( entry->GetValueCount() != nbvalue )
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
for(i=0;i<entry->GetValueCount();i++)
<< " 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;
<< " 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 )
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << data << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
if( entry->GetValueCount() != nbvalue )
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
for(i=0;i<entry->GetValueCount();i++)
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << lvalue[i] << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
}
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << data << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
if( entry->GetValueCount() != nbvalue )
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
for(i=0;i<entry->GetValueCount();i++)
<< " 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;
<< " 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 )
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << fdata << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
if( entry->GetValueCount() != nbvalue )
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
for(i=0;i<entry->GetValueCount();i++)
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << fvalue[i] << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
}
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << fdata << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
if( entry->GetValueCount() != nbvalue )
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
for(i=0;i<entry->GetValueCount();i++)
<< " 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;
<< " 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 )
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << fdata << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
if( entry->GetValueCount() != nbvalue )
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
for(i=0;i<entry->GetValueCount();i++)
<< " Found: " << entry->GetValue(i)
<< " - Must be: " << dvalue[i] << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
}
<< " Found: " << entry->GetString().c_str()
<< " - Must be: " << fdata << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
if( entry->GetValueCount() != nbvalue )
<< " Found: " << entry->GetValueCount()
<< " - Must be: " << nbvalue << std::endl;
dict->Delete();
- delete entry;
+ entry->Delete();
return 1;
}
for(i=0;i<entry->GetValueCount();i++)
<< " 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<<std::flush;
Program: gdcm
Module: $RCSfile: TestInline.cxx,v $
Language: C++
- Date: $Date: 2005/10/24 13:17:22 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2005/10/24 16:00:46 $
+ 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
#include "gdcmDebug.h"
#include <iostream>
-#include <time.h>
+/*#include <time.h>
#ifdef CMAKE_HAVE_SYS_TIMES_H
#include <sys/times.h>
#else
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) \
{ \
return 0;
}
+*/
+
+int TestInline(int argc, char *argv[])
+{
+ return 0;
+}
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
*/
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 = "");
} TValueFlag;
protected:
+ DataEntry(DictEntry *e);
+ DataEntry(DocEntry *d);
+ ~DataEntry();
+
// Methods :
void NewBinArea(void);
void DeleteBinArea(void);
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
if ( dynamic_cast<SeqEntry *>(entry) )
break;
- RemoveEntryNoDestroy(entry);
+ RemoveEntry(entry);
MetaElems->AddEntry(entry);
entry = GetFirstEntry();
// 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);
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
gdcmWarningMacro("GDCM_DICOMDIR_META ?!? should never print that");
}
si->AddEntry(entry);
+ entry->Delete();
}
}
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();
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
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();
}
}
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
#ifndef GDCMDOCENTRY_H
#define GDCMDOCENTRY_H
-#include "gdcmBase.h"
+#include "gdcmRefCounter.h"
#include "gdcmDictEntry.h"
#include <iostream>
* \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);
virtual void Copy(DocEntry *e);
protected:
+ DocEntry(DictEntry*);
+ virtual ~DocEntry();
+
/// \brief pointer to the underlying Dicom dictionary element
DictEntry *DicomDict;
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
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);
DocEntry *old = ArchFile->GetDocEntry(group, elem);
Archive[key] = old;
if ( old )
- ArchFile->RemoveEntryNoDestroy(old);
+ {
+ old->Register();
+ ArchFile->RemoveEntry(old);
+ }
return true;
}
// 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);
it!=Archive.end();
++it)
{
- delete it->second;
+ if(it->second)
+ it->second->Unregister();
}
Archive.clear();
}
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
{
gdcmWarningMacro("AddEntry failed although this is a creation.");
- delete dataEntry;
+ dataEntry->Delete();
return NULL;
}
}
{
gdcmWarningMacro( "AddEntry failed although this is a creation.");
- delete dataEntry;
+ dataEntry->Delete();
return NULL;
}
}
{
gdcmWarningMacro( "AddEntry failed although this is a creation.");
- delete seqEntry;
+ seqEntry->Delete();
return NULL;
}
}
* @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)
{
* 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)
{
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
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
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
(!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) )
{
if ( !used )
- delete newDocEntry;
+ newDocEntry->Delete();
break;
}
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;
}
}
{
// 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
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
}
if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max)
{
- delete newDocEntry;
+ newDocEntry->Delete();
break;
}
// create the current SQItem
// 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
{
// 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();
catch ( FormatError )
{
// Call it quits
- delete newEntry;
+ newEntry->Delete();
return 0;
}
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
else
{
TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry));
+ newEntry->Register();
return true;
}
}
if ( TagHT.count(key) == 1 )
{
TagHT.erase(key);
- //gdcmWarningMacro( "One element erased.");
- delete entryToRemove;
+ entryToRemove->Unregister();
return true;
}
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
*/
{
if ( cc->second )
{
- delete cc->second;
+ cc->second->Unregister();
}
}
TagHT.clear();
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
bool AddEntry(DocEntry *Entry);
bool RemoveEntry(DocEntry *EntryToRemove);
- bool RemoveEntryNoDestroy(DocEntry *EntryToRemove);
void ClearEntry();
DocEntry *GetFirstEntry();
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
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());
RemoveEntry(oldEntry);
AddEntry(newEntry);
+ newEntry->Delete();
}
}
}
if( entry->GetValueCount() == 3 )
{
- gdcmAssertMacro( entry->IsValueCountValid() );
+ gdcmErrorMacro( entry->IsValueCountValid() );
return (float)entry->GetValue(0);
}
return 0.0f;
if( entry->GetValueCount() == 3 )
{
- gdcmAssertMacro( entry->IsValueCountValid() );
+ gdcmErrorMacro( entry->IsValueCountValid() );
return (float)entry->GetValue(1);
}
return 0.0f;
{
if( entry->GetValueCount() == 3 )
{
- gdcmAssertMacro( entry->IsValueCountValid() );
+ gdcmErrorMacro( entry->IsValueCountValid() );
return (float)entry->GetValue(2);
}
gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)");
{
if( entry->GetValueCount() == 3 )
{
- gdcmAssertMacro( entry->IsValueCountValid() );
+ gdcmErrorMacro( entry->IsValueCountValid() );
return (float)entry->GetValue(2);
}
gdcmWarningMacro( "Wrong Image Position (RET) (0020,0030)");
{
if( entry->GetValueCount() == 1 )
{
- gdcmAssertMacro( entry->IsValueCountValid() );
+ gdcmErrorMacro( entry->IsValueCountValid() );
return (float)entry->GetValue(0); // VM=1 !
}
gdcmWarningMacro( "Wrong Slice Location (0020,1041)");
{
if( entry->GetValueCount() == 1 )
{
- gdcmAssertMacro( entry->IsValueCountValid() );
+ gdcmErrorMacro( entry->IsValueCountValid() );
return (float)entry->GetValue(0);
}
gdcmWarningMacro( "Wrong Location (0020,0050)");
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
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)
Archive->Push(photInt);
Archive->Push(pixel);
+
+ photInt->Delete();
+ pixel->Delete();
}
}
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);
Archive->Push(bitsAlloc);
Archive->Push(bitsStored);
Archive->Push(highBit);
+
+ bitsAlloc->Delete();
+ bitsStored->Delete();
+ highBit->Delete();
}
}
else
tss->SetString(ts);
Archive->Push(tss);
+ tss->Delete();
}
void FileHelper::SetWriteFileTypeToExplicitVR()
tss->SetString(ts);
Archive->Push(tss);
+ tss->Delete();
}
/**
tss->SetString(ts);
Archive->Push(tss);
+ tss->Delete();
}
{
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);
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();
}
/**
DataEntry *libidoCode = CopyDataEntry(0x0008,0x0010);
libidoCode->SetString("");
Archive->Push(libidoCode);
+ libidoCode->Delete();
}
}
}
if ( oldE )
{
- newE = new DataEntry(oldE->GetDictEntry());
+ newE = DataEntry::New(oldE->GetDictEntry());
newE->Copy(oldE);
}
else
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);
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");
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)
DataEntry *entry = CopyDataEntry(group,elem);
entry->SetString(value);
Archive->Push(entry);
+ entry->Delete();
}
/**
Archive->Restore(0x0020,0x000d);
Archive->Restore(0x0020,0x000e);
-
}
//-----------------------------------------------------------------------------
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
if (DocEntries.empty() )
{
DocEntries.push_back(entry);
+ entry->Register();
return true;
}
break;
} while (it != DocEntries.begin() );
- insertSpot = it++;
- insertSpot++; // ?!?
+ ++it;
+ insertSpot = it;
+ //++insertSpot; // ?!?
DocEntries.insert(insertSpot, entry);
+ entry->Register();
return true;
}
{
DocEntries.erase(it);
gdcmWarningMacro( "One element erased: " << entryToRemove->GetKey() );
- delete entryToRemove;
+ entryToRemove->Unregister();
return true;
}
}
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
*/
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();
}
/**
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
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();
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
}
if (SeqTerm)
{
- delete SeqTerm;
+ SeqTerm->Unregister();
}
}
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
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
*/
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);
/// 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;}
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;