GDCM_NAME_SPACE::DocEntryArchive Class Reference

Container It's goal is to change the File header correctly. At this time, the change is only made for the first level of the Document. In the future, it might consider Dicom Sequences (SeqEntry, within any SQItem). The change is made by replacing a DocEntry by an other that is created outside the class. The old value is kept. When we restore the File status, the added DocEntry is deleted and replaced by the old value. More...

#include <gdcmDocEntryArchive.h>

Collaboration diagram for GDCM_NAME_SPACE::DocEntryArchive:

Collaboration graph
[legend]
List of all members.

Private Member Functions

 DocEntryArchive (File *file)
 Constructor.
 ~DocEntryArchive ()
 Destructor.
void Print (std::ostream &os=std::cout)
 Print all.
bool Push (DocEntry *newEntry)
 Replaces in the Header a DocEntry by the new DocEntry. The initial DocEntry is kept in archive.
bool Push (uint16_t group, uint16_t elem)
 Removes out of the Header a DocEntry. (it's kept in archive).
bool Restore (uint16_t group, uint16_t elem)
 Restore in the Header the DocEntry specified by (group,element). The archive entry is destroyed.
void ClearArchive (void)
 Removes all DocEntry from the archive, and destroy them. The archives entries aren't restored.

Private Attributes

FileArchFile
 pointer to the gdcm::File pointer we want to save values from
TagDocEntryHT Archive
 H table to save values.

Friends

class FileHelper

Detailed Description

Container It's goal is to change the File header correctly. At this time, the change is only made for the first level of the Document. In the future, it might consider Dicom Sequences (SeqEntry, within any SQItem). The change is made by replacing a DocEntry by an other that is created outside the class. The old value is kept. When we restore the File status, the added DocEntry is deleted and replaced by the old value.

Definition at line 37 of file gdcmDocEntryArchive.h.


Constructor & Destructor Documentation

GDCM_NAME_SPACE::DocEntryArchive::DocEntryArchive File file  )  [private]
 

Constructor.

Definition at line 32 of file gdcmDocEntryArchive.cxx.

References ArchFile.

00033 {
00034    ArchFile = file;
00035 }

GDCM_NAME_SPACE::DocEntryArchive::~DocEntryArchive  )  [private]
 

Destructor.

Definition at line 40 of file gdcmDocEntryArchive.cxx.

References ClearArchive().

00041 {
00042    ClearArchive();
00043 }


Member Function Documentation

void GDCM_NAME_SPACE::DocEntryArchive::ClearArchive void   )  [private]
 

Removes all DocEntry from the archive, and destroy them. The archives entries aren't restored.

Definition at line 155 of file gdcmDocEntryArchive.cxx.

References Archive.

Referenced by ~DocEntryArchive().

00156 {
00157    for(TagDocEntryHT::iterator it = Archive.begin();
00158        it!=Archive.end();
00159        ++it)
00160    {
00161       if(it->second)
00162          it->second->Unregister();
00163    }
00164    Archive.clear();
00165 }

void GDCM_NAME_SPACE::DocEntryArchive::Print std::ostream &  os = std::cout  )  [private]
 

Print all.

Parameters:
os The output stream to be written to.

Definition at line 179 of file gdcmDocEntryArchive.cxx.

References Archive.

00180 {
00181    os << "Elements in archives :" << std::endl;
00182    for(TagDocEntryHT::iterator it = Archive.begin();
00183        it!=Archive.end();
00184        ++it)
00185    {
00186       if ( it->second )
00187          it->second->Print(os);
00188    }
00189 }

bool GDCM_NAME_SPACE::DocEntryArchive::Push uint16_t  group,
uint16_t  elem
[private]
 

Removes out of the Header a DocEntry. (it's kept in archive).

Parameters:
group Group number of the Entry to remove
elem Element number of the Entry to remove
Returns:
FALSE when an other DocEntry is already archived with the same key TRUE otherwise

Definition at line 95 of file gdcmDocEntryArchive.cxx.

References ArchFile, Archive, GDCM_NAME_SPACE::ElementSet::GetDocEntry(), and GDCM_NAME_SPACE::ElementSet::RemoveEntry().

00096 {
00097    //TagKey key = DictEntry::TranslateToKey(group, elem);
00098    TagKey key(group, elem);
00099    if ( Archive.find(key)==Archive.end() )
00100    {
00101       // Save the old DocEntry if any
00102       DocEntry *old = ArchFile->GetDocEntry(group, elem);
00103       Archive[key] = old;
00104       if ( old )
00105       {
00106          old->Register();
00107          ArchFile->RemoveEntry(old);
00108       }
00109 
00110       return true;
00111    }
00112    return false;
00113 }

bool GDCM_NAME_SPACE::DocEntryArchive::Push DocEntry newEntry  )  [private]
 

Replaces in the Header a DocEntry by the new DocEntry. The initial DocEntry is kept in archive.

Parameters:
newEntry New entry to substitute to an other entry of the Header
Returns:
FALSE when an other DocEntry is already archived with the same key TRUE otherwise

Definition at line 54 of file gdcmDocEntryArchive.cxx.

References GDCM_NAME_SPACE::ElementSet::AddEntry(), ArchFile, Archive, GDCM_NAME_SPACE::ElementSet::GetDocEntry(), GDCM_NAME_SPACE::DocEntry::GetElement(), GDCM_NAME_SPACE::DocEntry::GetGroup(), GDCM_NAME_SPACE::DocEntry::GetKey(), GDCM_NAME_SPACE::RefCounter::Register(), and GDCM_NAME_SPACE::ElementSet::RemoveEntry().

Referenced by GDCM_NAME_SPACE::FileHelper::CheckMandatoryElements(), GDCM_NAME_SPACE::FileHelper::CheckMandatoryEntry(), GDCM_NAME_SPACE::FileHelper::CopyMandatoryEntry(), GDCM_NAME_SPACE::FileHelper::SetMandatoryEntry(), GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToACR(), GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToExplicitVR(), GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToImplicitVR(), GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToJPEG(), GDCM_NAME_SPACE::FileHelper::SetWriteFileTypeToJPEG2000(), GDCM_NAME_SPACE::FileHelper::SetWriteToLibido(), and GDCM_NAME_SPACE::FileHelper::SetWriteToNoLibido().

00055 {
00056    if ( !newEntry )
00057       return false;
00058 
00059    //uint16_t group = newEntry->GetDictEntry()->GetGroup();
00060    //uint16_t elem  = newEntry->GetDictEntry()->GetElement();
00061    //TagKey key = DictEntry::TranslateToKey(group,elem);
00062 
00063    TagKey key = newEntry->GetKey();
00064    
00065    if ( Archive.find(key) == Archive.end() )
00066    {
00067       uint16_t group = newEntry->GetGroup();
00068       uint16_t elem  = newEntry->GetElement();
00069       
00070       // Save the old DocEntry if any
00071       DocEntry *old = ArchFile->GetDocEntry(group, elem);
00072       Archive[key]  = old;
00073       if ( old )
00074       {
00075          old->Register();
00076          ArchFile->RemoveEntry(old);
00077       }
00078 
00079       // Set the new DocEntry
00080       ArchFile->AddEntry(newEntry);
00081 
00082       return true;
00083    }
00084    return false;
00085 }

bool GDCM_NAME_SPACE::DocEntryArchive::Restore uint16_t  group,
uint16_t  elem
[private]
 

Restore in the Header the DocEntry specified by (group,element). The archive entry is destroyed.

Parameters:
group Group number of the Entry to restore
elem Element number of the Entry to restore
Returns:
FALSE when the key isn't in the archive, TRUE otherwise

Definition at line 123 of file gdcmDocEntryArchive.cxx.

References GDCM_NAME_SPACE::ElementSet::AddEntry(), ArchFile, Archive, GDCM_NAME_SPACE::ElementSet::GetDocEntry(), and GDCM_NAME_SPACE::ElementSet::RemoveEntry().

Referenced by GDCM_NAME_SPACE::FileHelper::RestoreWrite(), GDCM_NAME_SPACE::FileHelper::RestoreWriteMandatory(), and GDCM_NAME_SPACE::FileHelper::RestoreWriteOfLibido().

00124 {
00125    //TagKey key=DictEntry::TranslateToKey(group, elem);
00126    TagKey key(group, elem);
00127    TagDocEntryHT::iterator restoreIt=Archive.find(key);
00128    if ( restoreIt!=Archive.end() )
00129    {
00130       // Delete the new value
00131       DocEntry *rem = ArchFile->GetDocEntry(group, elem);
00132       if ( rem )
00133       {
00134          ArchFile->RemoveEntry(rem);
00135       }
00136 
00137       // Restore the old value
00138       if ( restoreIt->second )
00139       {
00140          ArchFile->AddEntry(restoreIt->second);
00141          restoreIt->second->Unregister();
00142       }
00143 
00144       Archive.erase(restoreIt);
00145 
00146       return true;
00147    }
00148    return false;
00149 }


Friends And Related Function Documentation

friend class FileHelper [friend]
 

Definition at line 40 of file gdcmDocEntryArchive.h.


Member Data Documentation

File* GDCM_NAME_SPACE::DocEntryArchive::ArchFile [private]
 

pointer to the gdcm::File pointer we want to save values from

Definition at line 55 of file gdcmDocEntryArchive.h.

Referenced by DocEntryArchive(), Push(), and Restore().

TagDocEntryHT GDCM_NAME_SPACE::DocEntryArchive::Archive [private]
 

H table to save values.

Definition at line 57 of file gdcmDocEntryArchive.h.

Referenced by ClearArchive(), Print(), Push(), and Restore().


The documentation for this class was generated from the following files:
Generated on Fri Aug 24 13:01:41 2007 for gdcm by  doxygen 1.4.6