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
#include "gdcmSQItem.h"
#include "gdcmSeqEntry.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmGlobal.h"
#include "gdcmDictSet.h"
#include "gdcmUtil.h"
// 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);
* \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;
}
break;
} while (it != DocEntries.begin() );
- insertSpot = it++;
- insertSpot++; // ?!?
+ ++it;
+ insertSpot = it;
+ //++insertSpot; // ?!?
DocEntries.insert(insertSpot, entry);
+ entry->Register();
return true;
}
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
*/
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
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;
}