Program: gdcm
Module: $RCSfile: gdcmElementSet.cxx,v $
Language: C++
- Date: $Date: 2005/02/01 10:29:55 $
- Version: $Revision: 1.52 $
+ 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
#include "gdcmElementSet.h"
#include "gdcmDebug.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
#include "gdcmSeqEntry.h"
+#include "gdcmDataEntry.h"
namespace gdcm
{
/**
* \brief Constructor for a given ElementSet
*/
-//BOZ depthLevel is not usefull anymore
-ElementSet::ElementSet(int depthLevel)
- : DocEntrySet()
+ElementSet::ElementSet()
+ : DocEntrySet()
{
- (void)depthLevel;
}
/**
}
}
-/**
- * \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
* @param newEntry entry to add
{
const TagKey &key = newEntry->GetKey();
- if( TagHT.count(key) == 1 )
+ if ( TagHT.count(key) == 1 )
{
- gdcmVerboseMacro( "Key already present: " << key.c_str());
+ gdcmWarningMacro( "Key already present: " << key );
return false;
}
else
{
TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry));
+ newEntry->Register();
return true;
}
}
bool ElementSet::RemoveEntry( DocEntry *entryToRemove)
{
const TagKey &key = entryToRemove->GetKey();
- if( TagHT.count(key) == 1 )
+ if ( TagHT.count(key) == 1 )
{
TagHT.erase(key);
- //gdcmVerboseMacro( "One element erased.");
- delete entryToRemove;
+ entryToRemove->Unregister();
return true;
}
- gdcmVerboseMacro( "Key not present");
+ gdcmWarningMacro( "Key not present : " << key);
return false ;
}
/**
- * \brief Clear the hash table from given entry BUT keep the entry.
- * @param entryToRemove Entry to remove.
+ * \brief delete all entries in the ElementSet
*/
-bool ElementSet::RemoveEntryNoDestroy(DocEntry *entryToRemove)
+void ElementSet::ClearEntry()
{
- const TagKey &key = entryToRemove->GetKey();
- if( TagHT.count(key) == 1 )
+ for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc)
{
- TagHT.erase(key);
- //gdcmVerboseMacro( "One element erased.");
- return true;
+ if ( cc->second )
+ {
+ cc->second->Unregister();
+ }
}
-
- gdcmVerboseMacro( "Key not present");
- return false ;
+ TagHT.clear();
}
/**
- * \brief Get the first entry while visiting the DocEntrySet
+ * \brief Get the first entry while visiting *the* 'zero level' DocEntrySet
+ * (DocEntries out of any Sequence)
* \return The first DocEntry if found, otherwhise NULL
*/
DocEntry *ElementSet::GetFirstEntry()
}
/**
- * \brief Get the next entry while visiting the Hash table (TagHT)
+ * \brief Get the next entry while visiting *the* 'zero level' DocEntrySet
+ * (DocEntries out of any Sequence)
* \note : meaningfull only if GetFirstEntry already called
* \return The next DocEntry if found, otherwhise NULL
*/
*/
void ElementSet::Print(std::ostream &os, std::string const & )
{
+ // Let's change the 'warning value' for Pixel Data,
+ // to avoid human reader to be confused by 'gdcm::NotLoaded'.
+ DataEntry *pixelElement = GetDataEntry(0x7fe0,0x0010);
+ if ( pixelElement != 0 )
+ {
+ pixelElement->SetFlag( DataEntry::FLAG_PIXELDATA );
+ }
+
for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
{
- DocEntry* entry = i->second;
+ DocEntry *entry = i->second;
entry->SetPrintLevel(PrintLevel);
entry->Print(os);
- if ( dynamic_cast<SeqEntry*>(entry) )
+ if ( dynamic_cast<SeqEntry *>(entry) )
{
// Avoid the newline for a sequence:
continue;