Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

gdcm::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::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::DocEntryArchive::DocEntryArchive File file  )  [private]
 

Constructor.

Definition at line 32 of file gdcmDocEntryArchive.cxx.

References ArchFile.

00033 {
00034    ArchFile = file;
00035 }

gdcm::DocEntryArchive::~DocEntryArchive  )  [private]
 

Destructor.

Definition at line 40 of file gdcmDocEntryArchive.cxx.

References ClearArchive().

00041 {
00042    ClearArchive();
00043 }


Member Function Documentation

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

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

Definition at line 150 of file gdcmDocEntryArchive.cxx.

References Archive.

Referenced by ~DocEntryArchive().

00151 {
00152    for(TagDocEntryHT::iterator it = Archive.begin();
00153        it!=Archive.end();
00154        ++it)
00155    {
00156       if(it->second)
00157          it->second->Unregister();
00158    }
00159    Archive.clear();
00160 }

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

Print all.

Parameters:
os The output stream to be written to.

Definition at line 174 of file gdcmDocEntryArchive.cxx.

References Archive.

00175 {
00176    os << "Elements in archives :" << std::endl;
00177    for(TagDocEntryHT::iterator it = Archive.begin();
00178        it!=Archive.end();
00179        ++it)
00180    {
00181       if ( it->second )
00182          it->second->Print(os);
00183    }
00184 }

bool gdcm::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 90 of file gdcmDocEntryArchive.cxx.

References ArchFile, Archive, gdcm::ElementSet::GetDocEntry(), gdcm::RefCounter::Register(), gdcm::ElementSet::RemoveEntry(), and gdcm::DictEntry::TranslateToKey().

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

bool gdcm::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::ElementSet::AddEntry(), ArchFile, Archive, gdcm::DocEntry::GetDictEntry(), gdcm::ElementSet::GetDocEntry(), gdcm::DictEntry::GetElement(), gdcm::DictEntry::GetGroup(), gdcm::RefCounter::Register(), gdcm::ElementSet::RemoveEntry(), and gdcm::DictEntry::TranslateToKey().

Referenced by gdcm::FileHelper::CheckMandatoryElements(), gdcm::FileHelper::CheckMandatoryEntry(), gdcm::FileHelper::CopyMandatoryEntry(), gdcm::FileHelper::SetMandatoryEntry(), gdcm::FileHelper::SetWriteFileTypeToACR(), gdcm::FileHelper::SetWriteFileTypeToExplicitVR(), gdcm::FileHelper::SetWriteFileTypeToImplicitVR(), gdcm::FileHelper::SetWriteFileTypeToJPEG(), gdcm::FileHelper::SetWriteToLibido(), gdcm::FileHelper::SetWriteToNoLibido(), gdcm::FileHelper::SetWriteToRaw(), and gdcm::FileHelper::SetWriteToRGB().

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    if ( Archive.find(key) == Archive.end() )
00064    {
00065       // Save the old DocEntry if any
00066       DocEntry *old = ArchFile->GetDocEntry(group, elem);
00067       Archive[key]  = old;
00068       if ( old )
00069       {
00070          old->Register();
00071          ArchFile->RemoveEntry(old);
00072       }
00073 
00074       // Set the new DocEntry
00075       ArchFile->AddEntry(newEntry);
00076 
00077       return true;
00078    }
00079    return false;
00080 }

bool gdcm::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 118 of file gdcmDocEntryArchive.cxx.

References gdcm::ElementSet::AddEntry(), ArchFile, Archive, gdcm::ElementSet::GetDocEntry(), gdcm::ElementSet::RemoveEntry(), and gdcm::DictEntry::TranslateToKey().

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

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


Friends And Related Function Documentation

friend class FileHelper [friend]
 

Definition at line 40 of file gdcmDocEntryArchive.h.


Member Data Documentation

File* gdcm::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::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 Jan 20 10:15:04 2006 for gdcm by  doxygen 1.4.4