X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmSQItem.cxx;h=7c8d61c6e5373241d79a2ecac1a420541bfbc4cf;hb=c11ceb36d532037062ada59bfdeea3d24115bc8f;hp=e6b4e1c9cf145dd40fac7e17992e80063d91d2cd;hpb=5b89bede4607999aeb8d5b45311e7ee82f9471ef;p=gdcm.git diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index e6b4e1c9..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/02/02 16:18:48 $ - Version: $Revision: 1.66 $ + 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 @@ -18,8 +18,6 @@ #include "gdcmSQItem.h" #include "gdcmSeqEntry.h" -#include "gdcmValEntry.h" -#include "gdcmBinEntry.h" #include "gdcmGlobal.h" #include "gdcmDictSet.h" #include "gdcmUtil.h" @@ -85,7 +83,9 @@ void SQItem::WriteContent(std::ofstream *fp, FileType filetype) // we just *always* ignore spurious fffe|0000 tag ! if ( (*it)->GetGroup() == 0xfffe && (*it)->GetElement() == 0x0000 ) { - break; // FIXME : continue; ?!? + break; // FIXME : break or continue; ?!? + // --> makes no difference since the only bugged file we have + // contains 'impossible tag' fffe|0000 in last position ! } (*it)->WriteContent(fp, filetype); @@ -103,12 +103,14 @@ void SQItem::WriteContent(std::ofstream *fp, FileType filetype) * \brief Inserts *in the right place* any Entry (Dicom Element) * into the Sequence Item * @param entry Entry to add + * @return always true */ bool SQItem::AddEntry(DocEntry *entry) { if (DocEntries.empty() ) { DocEntries.push_back(entry); + entry->Register(); return true; } @@ -130,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; } @@ -147,42 +151,18 @@ bool SQItem::RemoveEntry( DocEntry *entryToRemove ) it != DocEntries.end(); ++it) { - if( *it == entryToRemove ) + if ( *it == entryToRemove ) { DocEntries.erase(it); - gdcmVerboseMacro( "One element erased: " << entryToRemove->GetKey() ); - delete entryToRemove; + gdcmWarningMacro( "One element erased: " << entryToRemove->GetKey() ); + entryToRemove->Unregister(); return true; } } - gdcmVerboseMacro( "Entry not found: " << entryToRemove->GetKey() ); + gdcmWarningMacro( "Entry not found: " << entryToRemove->GetKey() ); 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); - gdcmVerboseMacro( "One element erased, no destroyed: " - << entryToRemove->GetKey() ); - return true; - } - } - - gdcmVerboseMacro( "Entry not found:" << entryToRemove->GetKey() ); - return false ; -} - /** * \brief Remove all entry in the Sequence Item */ @@ -192,11 +172,20 @@ void SQItem::ClearEntry() cc != DocEntries.end(); ++cc) { - delete *cc; + (*cc)->Unregister(); } DocEntries.clear(); } +/** + * \brief Move all the entries from a given Sequence Item + */ +void SQItem::MoveObject(SQItem *source) +{ + DocEntries = source->DocEntries; + source->DocEntries.clear(); +} + /** * \brief Get the first Dicom entry while visiting the SQItem * \return The first DocEntry if found, otherwhise 0 @@ -204,19 +193,19 @@ void SQItem::ClearEntry() DocEntry *SQItem::GetFirstEntry() { ItDocEntries = DocEntries.begin(); - if( ItDocEntries != DocEntries.end() ) + if ( ItDocEntries != DocEntries.end() ) return *ItDocEntries; return 0; } /** - * \brief Get the next Dicom entry while visiting the chained list + * \brief Get the next Dicom entry while visiting the SQItem * \return The next DocEntry if found, otherwhise NULL */ DocEntry *SQItem::GetNextEntry() { ++ItDocEntries; - if( ItDocEntries != DocEntries.end() ) + if ( ItDocEntries != DocEntries.end() ) return *ItDocEntries; return NULL; }