Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | 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>

List of all members.

Public Member Functions

 DocEntryArchive (File *file)
 Constructor.

 ~DocEntryArchive ()
 Destructor.

void Print (std::ostream &os=std::cout)
 Print all.

bool Push (DocEntry *newEntry)
 Replace in the Header a DocEntry by the new DocEntry. The last DocEntry is kept in archive.

bool Push (uint16_t group, uint16_t elem)
 Replace in the Header a DocEntry by the new DocEntry. The last DocEntry is kept in archive.

bool Restore (uint16_t group, uint16_t elem)
 Restore in the Header the DocEntry that have the generalized key. The old entry is destroyed.

void ClearArchive (void)
 Remove all DocEntry that are in the archive. The entries aren't restored but only destroyed.


Private Attributes

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

TagDocEntryHT Archive
 H table to save values.


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  ) 
 

Constructor.

Definition at line 32 of file gdcmDocEntryArchive.cxx.

References ArchFile.

00033 {
00034    ArchFile = file;
00035 }

gdcm::DocEntryArchive::~DocEntryArchive  ) 
 

Destructor.

Definition at line 40 of file gdcmDocEntryArchive.cxx.

References ClearArchive().

00041 {
00042    ClearArchive();
00043 }


Member Function Documentation

void gdcm::DocEntryArchive::ClearArchive void   ) 
 

Remove all DocEntry that are in the archive. The entries aren't restored but only destroyed.

Definition at line 139 of file gdcmDocEntryArchive.cxx.

References Archive.

Referenced by ~DocEntryArchive().

00140 {
00141    for(TagDocEntryHT::iterator it = Archive.begin();
00142        it!=Archive.end();
00143        ++it)
00144    {
00145       delete it->second;
00146    }
00147    Archive.clear();
00148 }

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

Print all.

Parameters:
os The output stream to be written to.

Definition at line 162 of file gdcmDocEntryArchive.cxx.

References Archive.

00163 {
00164    os << "Elements in archives :" << std::endl;
00165    for(TagDocEntryHT::iterator it = Archive.begin();
00166        it!=Archive.end();
00167        ++it)
00168    {
00169       if(it->second)
00170          it->second->Print(os);
00171    }
00172 }

bool gdcm::DocEntryArchive::Push uint16_t  group,
uint16_t  elem
 

Replace in the Header a DocEntry by the new DocEntry. The last DocEntry is kept in archive.

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

Definition at line 87 of file gdcmDocEntryArchive.cxx.

References ArchFile, Archive, gdcm::ElementSet::GetDocEntry(), and gdcm::ElementSet::RemoveEntryNoDestroy().

00088 {
00089    std::string key = DictEntry::TranslateToKey(group,elem);
00090 
00091    if( Archive.find(key)==Archive.end() )
00092    {
00093       // Save the old DocEntry if any
00094       DocEntry *old = ArchFile->GetDocEntry(group,elem);
00095       Archive[key] = old;
00096       if( old )
00097          ArchFile->RemoveEntryNoDestroy(old);
00098 
00099       return true;
00100    }
00101    return false;
00102 }

bool gdcm::DocEntryArchive::Push DocEntry newEntry  ) 
 

Replace in the Header a DocEntry by the new DocEntry. The last 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 generalized 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(), and gdcm::ElementSet::RemoveEntryNoDestroy().

Referenced by gdcm::FileHelper::SetWriteFileTypeToACR(), gdcm::FileHelper::SetWriteFileTypeToExplicitVR(), gdcm::FileHelper::SetWriteFileTypeToImplicitVR(), 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    std::string 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          ArchFile->RemoveEntryNoDestroy(old);
00070 
00071       // Set the new DocEntry
00072       ArchFile->AddEntry(newEntry);
00073 
00074       return true;
00075    }
00076    return false;
00077 }

bool gdcm::DocEntryArchive::Restore uint16_t  group,
uint16_t  elem
 

Restore in the Header the DocEntry that have the generalized key. The old entry is destroyed.

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

Definition at line 112 of file gdcmDocEntryArchive.cxx.

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

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

00113 {
00114    std::string key=DictEntry::TranslateToKey(group,elem);
00115 
00116    TagDocEntryHT::iterator restoreIt=Archive.find(key);
00117    if( restoreIt!=Archive.end() )
00118    {
00119       // Delete the new value
00120       DocEntry *rem = ArchFile->GetDocEntry(group,elem);
00121       if( rem )
00122          ArchFile->RemoveEntry(rem);
00123 
00124       // Restore the old value
00125       if( Archive[key] )
00126          ArchFile->AddEntry(Archive[key]);
00127 
00128       Archive.erase(restoreIt);
00129 
00130       return true;
00131    }
00132    return false;
00133 }


Member Data Documentation

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

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

Definition at line 53 of file gdcmDocEntryArchive.h.

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

TagDocEntryHT gdcm::DocEntryArchive::Archive [private]
 

H table to save values.

Definition at line 55 of file gdcmDocEntryArchive.h.

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


The documentation for this class was generated from the following files:
Generated on Thu Feb 10 22:18:08 2005 for gdcm by doxygen 1.3.6