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

gdcm::ElementSet Class Reference

ElementSet is based on the STL map<> container (see ElementSet::TagHT), as opposed to SQItem which is based on an STL list container (see ListDocEntry). It contains the 'zero-level- DocEntry (out of any Dicom Sequence) More...

#include <gdcmElementSet.h>

Inheritance diagram for gdcm::ElementSet:

Inheritance graph
[legend]
Collaboration diagram for gdcm::ElementSet:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void Print (std::ostream &os=std::cout, std::string const &indent="")
 Prints the Header Entries (Dicom Elements) from the H Table.
void WriteContent (std::ofstream *fp, FileType filetype)
 Writes the Header Entries (Dicom Elements) from the H Table.
bool AddEntry (DocEntry *Entry)
 add a new Dicom Element pointer to the H Table
bool RemoveEntry (DocEntry *EntryToRemove)
 Clear the hash table from given entry AND delete the entry.
void ClearEntry ()
 delete all entries in the ElementSet
DocEntryGetFirstEntry ()
 Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
DocEntryGetNextEntry ()
 Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).
DocEntryGetDocEntry (uint16_t group, uint16_t elem)
 retrieves a Dicom Element using (group, element)
bool IsEmpty ()
 Tells us if the ElementSet contains no entry.
virtual void Copy (DocEntrySet *set)
 Copies all the attributes from an other DocEntrySet.
virtual std::string GetEntryString (uint16_t group, uint16_t elem)
 Get the "std::string representable" value of the Dicom entry.
virtual void * GetEntryBinArea (uint16_t group, uint16_t elem)
 Gets (from Header) a 'non string' element value.
virtual int GetEntryLength (uint16_t group, uint16_t elem)
 Searches within the DocEntrySet for the value length of a given tag..
DataEntryGetDataEntry (uint16_t group, uint16_t elem)
 Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type DataEntry.
SeqEntryGetSeqEntry (uint16_t group, uint16_t elem)
 Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type SeqEntry.
bool SetEntryString (std::string const &content, uint16_t group, uint16_t elem)
 Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
bool SetEntryString (std::string const &content, DataEntry *entry)
 Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value.
bool SetEntryBinArea (uint8_t *content, int lgth, uint16_t group, uint16_t elem)
 Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.
bool SetEntryBinArea (uint8_t *content, int lgth, DataEntry *entry)
 Accesses an existing DataEntry (i.e. a Dicom Element) and modifies it's content with the given value.
DataEntryInsertEntryString (std::string const &value, uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN)
 Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant.
DataEntryInsertEntryBinArea (uint8_t *binArea, int lgth, uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN)
 Modifies the value of a given Header Entry (Dicom Element) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.
SeqEntryInsertSeqEntry (uint16_t group, uint16_t elem)
 Creates a new gdcm::SeqEntry and adds it to the current DocEntrySet. (remove any existing entry with same group,elem).
virtual bool CheckIfEntryExist (uint16_t group, uint16_t elem)
 Checks if a given Dicom Element exists within the DocEntrySet.
DataEntryNewDataEntry (uint16_t group, uint16_t elem, VRKey const &vr=GDCM_VRUNKNOWN)
 Build a new DataEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
SeqEntryNewSeqEntry (uint16_t group, uint16_t elem)
 Build a new SeqEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.
void Delete ()
 Delete the object.
void Register ()
 Register the object.
void Unregister ()
 Unregister the object.
const unsigned long & GetRefCount () const
 Get the reference counting.
void SetPrintLevel (int level)
 Sets the print level for the Dicom Header Elements.
int GetPrintLevel ()
 Gets the print level for the Dicom Entries.

Protected Member Functions

 ElementSet ()
 Constructor for a given ElementSet.
 ~ElementSet ()
 Canonical destructor.
bool MayIWrite (uint16_t)
 Some group are illegal withing some Dicom Documents Only the Document knows it.
DictEntryGetDictEntry (uint16_t group, uint16_t elem)
 Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element. The public dictionary has precedence on the shadow one(s), if any.
DictEntryGetDictEntry (uint16_t group, uint16_t elem, VRKey const &vr)
 Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary.

Protected Attributes

DocEntryPreviousDocEntry
 To be able to backtrack (Private Sequence, Implicit VR related pb).
int PrintLevel
 Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Private Member Functions

 gdcmTypeMacro (ElementSet)

Private Attributes

TagDocEntryHT TagHT
 Hash Table (map), to provide fast access.
TagDocEntryHT::iterator ItTagHT
 iterator, used to visit the TagHT variable

Detailed Description

ElementSet is based on the STL map<> container (see ElementSet::TagHT), as opposed to SQItem which is based on an STL list container (see ListDocEntry). It contains the 'zero-level- DocEntry (out of any Dicom Sequence)

Definition at line 40 of file gdcmElementSet.h.


Constructor & Destructor Documentation

gdcm::ElementSet::ElementSet  )  [protected]
 

Constructor for a given ElementSet.

Definition at line 31 of file gdcmElementSet.cxx.

00032           : DocEntrySet()
00033 {
00034 }

gdcm::ElementSet::~ElementSet  )  [protected]
 

Canonical destructor.

Definition at line 39 of file gdcmElementSet.cxx.

References ClearEntry().

00040 {
00041    ClearEntry();
00042 }


Member Function Documentation

bool gdcm::ElementSet::AddEntry DocEntry newEntry  )  [virtual]
 

add a new Dicom Element pointer to the H Table

Parameters:
newEntry entry to add

Implements gdcm::DocEntrySet.

Definition at line 78 of file gdcmElementSet.cxx.

References gdcmWarningMacro, gdcm::DocEntry::GetKey(), gdcm::RefCounter::Register(), and TagHT.

Referenced by gdcm::File::DoTheLoadingJob(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore().

00079 {
00080    const TagKey &key = newEntry->GetKey();
00081 
00082    if ( TagHT.count(key) == 1 )
00083    {
00084       gdcmWarningMacro( "Key already present: " << key );
00085       return false;
00086    }
00087    else
00088    {
00089       TagHT.insert(TagDocEntryHT::value_type(newEntry->GetKey(), newEntry));
00090       newEntry->Register();
00091       return true;
00092    }
00093 }

bool gdcm::DocEntrySet::CheckIfEntryExist uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Checks if a given Dicom Element exists within the DocEntrySet.

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:
true is found

Definition at line 392 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry().

00393 {
00394    return GetDocEntry(group,elem)!=NULL;
00395 }

void gdcm::ElementSet::ClearEntry  )  [virtual]
 

delete all entries in the ElementSet

Implements gdcm::DocEntrySet.

Definition at line 116 of file gdcmElementSet.cxx.

References TagHT.

Referenced by Copy(), gdcm::DicomDir::CreateDicomDir(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::DicomDir::SetElements(), and ~ElementSet().

00117 {
00118    for(TagDocEntryHT::iterator cc = TagHT.begin();cc != TagHT.end(); ++cc)
00119    {
00120       if ( cc->second )
00121       {
00122          cc->second->Unregister();
00123       }
00124    }
00125    TagHT.clear();
00126 }

void gdcm::ElementSet::Copy DocEntrySet set  )  [virtual]
 

Copies all the attributes from an other DocEntrySet.

Parameters:
set entry to copy from
Remarks:
The contained DocEntries a not copied, only referenced

Reimplemented from gdcm::DocEntrySet.

Reimplemented in gdcm::DicomDir.

Definition at line 178 of file gdcmElementSet.cxx.

References ClearEntry(), gdcm::DocEntrySet::Copy(), ItTagHT, and TagHT.

Referenced by gdcm::DicomDir::Copy().

00179 {
00180    // Remove all previous entries
00181    ClearEntry();
00182 
00183    DocEntrySet::Copy(set);
00184 
00185    ElementSet *eltSet = dynamic_cast<ElementSet *>(set);
00186    if( eltSet )
00187    {
00188       TagHT = eltSet->TagHT;
00189       for(ItTagHT = TagHT.begin();ItTagHT != TagHT.end();++ItTagHT)
00190       {
00191          (ItTagHT->second)->Register();
00192       }
00193    }
00194 }

void gdcm::RefCounter::Delete  )  [inline, inherited]
 

Delete the object.

Remarks:
The object is deleted only if its reference counting is to zero

Definition at line 39 of file gdcmRefCounter.h.

Referenced by gdcm::SerieHelper::AddFileName(), gdcm::Document::Backtrack(), gdcm::FileHelper::CheckMandatoryElements(), gdcm::FileHelper::CheckMandatoryEntry(), gdcm::FileHelper::CopyMandatoryEntry(), gdcm::DicomDir::CreateDicomDirChainedList(), gdcm::File::DoTheLoadingJob(), gdcm::Dict::DoTheLoadingJob(), gdcm::DicomDirObject::FillObject(), gdcm::DocEntrySet::InsertEntryBinArea(), gdcm::DocEntrySet::InsertEntryString(), gdcm::DocEntrySet::InsertSeqEntry(), vtkGdcmReader::LoadFileInformation(), vtkGdcmReader::LoadImageInMemory(), main(), gdcm::DicomDir::NewMeta(), gdcm::DicomDirStudy::NewVisit(), gdcm::Document::ParseDES(), gdcm::Document::ParseSQ(), gdcm::Document::ReadNextDocEntry(), gdcm::DicomDir::SetElement(), gdcm::FileHelper::SetMandatoryEntry(), gdcm::FileHelper::SetWriteFileTypeToExplicitVR(), gdcm::FileHelper::SetWriteFileTypeToImplicitVR(), gdcm::FileHelper::SetWriteFileTypeToJPEG(), gdcm::FileHelper::SetWriteToLibido(), gdcm::FileHelper::SetWriteToNoLibido(), gdcm::FileHelper::SetWriteToRaw(), gdcm::FileHelper::SetWriteToRGB(), vtkGdcmWriter::WriteDcmFile(), gdcm::DicomDir::~DicomDir(), and gdcm::Global::~Global().

00039 { Unregister(); }

gdcm::ElementSet::gdcmTypeMacro ElementSet   )  [private]
 

DataEntry * gdcm::DocEntrySet::GetDataEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type DataEntry.

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:
When present, the corresponding DataEntry.

Definition at line 99 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry().

Referenced by gdcm::FileHelper::CheckMandatoryElements(), gdcm::FileHelper::CheckMandatoryEntry(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::File::GetBitsAllocated(), gdcm::File::GetBitsStored(), gdcm::DocEntrySet::GetEntryBinArea(), gdcm::File::GetHighBitPosition(), gdcm::File::GetPlanarConfiguration(), gdcm::File::GetRescaleIntercept(), gdcm::File::GetRescaleSlope(), gdcm::File::GetSamplesPerPixel(), gdcm::File::GetXOrigin(), gdcm::File::GetXSize(), gdcm::File::GetXSpacing(), gdcm::File::GetYOrigin(), gdcm::File::GetYSize(), gdcm::File::GetYSpacing(), gdcm::File::GetZOrigin(), gdcm::File::GetZSize(), gdcm::File::GetZSpacing(), gdcm::File::IsSignedPixelData(), Print(), gdcm::DocEntrySet::SetEntryBinArea(), gdcm::DocEntrySet::SetEntryString(), gdcm::FileHelper::SetWriteToLibido(), gdcm::FileHelper::SetWriteToNoLibido(), userSuppliedLessThanFunction(), gdcm::FileHelper::Write(), gdcm::File::Write(), and gdcm::DicomDirMeta::WriteContent().

00100 {
00101    DocEntry *currentEntry = GetDocEntry(group, elem);
00102    if ( !currentEntry )
00103       return NULL;
00104 
00105    return dynamic_cast<DataEntry*>(currentEntry);
00106 }

DictEntry * gdcm::DocEntrySet::GetDictEntry uint16_t  group,
uint16_t  elem,
VRKey const &  vr
[protected, inherited]
 

Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary.

Parameters:
group group number of the searched DictEntry
elem element number of the searched DictEntry
vr V(alue) R(epresentation) to use, if necessary
Returns:
Corresponding DictEntry when it exists, NULL otherwise.
Remarks:
The returned DictEntry is registered

Definition at line 484 of file gdcmDocEntrySet.cxx.

References gdcm::GDCM_VRUNKNOWN, gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::DictEntry::GetVM(), gdcm::DictEntry::GetVR(), gdcm::DictEntry::New(), gdcm::RefCounter::Register(), and gdcm::RefCounter::Unregister().

00486 {
00487    DictEntry *dictEntry = GetDictEntry(group,elem);
00488    DictEntry *goodEntry = dictEntry;
00489    VRKey goodVR = vr;
00490    TagName vm;
00491    if (elem == 0x0000) 
00492       goodVR="UL";
00493 
00494    if ( goodEntry )
00495    {
00496       if ( goodVR != goodEntry->GetVR()
00497         && goodVR != GDCM_VRUNKNOWN )
00498       { 
00499          gdcmWarningMacro("For (" << std::hex << group << "|"
00500             << elem << "), found VR : [" << vr << "]"
00501             << " expected: [" << goodEntry->GetVR() << "]" ) ;
00502         // avoid confusing further validator with "FIXME" VM
00503         // when possible      
00504          vm = dictEntry->GetVM();
00505          goodEntry = NULL;
00506       }
00507       dictEntry->Unregister();
00508    }
00509    else
00510    {
00511       vm = "FIXME";
00512    }
00513    // Create a new virtual DictEntry if necessary
00514    if (!goodEntry)
00515    {
00516       if (dictEntry)
00517       {
00518 
00519          goodEntry = DictEntry::New(group, elem, goodVR, vm,//"FIXME", 
00520                                     dictEntry->GetName() );
00521       }
00522       else
00523       {
00524          goodEntry = DictEntry::New(group, elem, goodVR);
00525       }
00526    }
00527    else
00528    {
00529       goodEntry->Register();
00530    }
00531    return goodEntry;
00532 }

DictEntry * gdcm::DocEntrySet::GetDictEntry uint16_t  group,
uint16_t  elem
[protected, inherited]
 

Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element. The public dictionary has precedence on the shadow one(s), if any.

Parameters:
group Group number of the searched DictEntry
elem Element number of the searched DictEntry
Returns:
Corresponding DictEntry when it exists, NULL otherwise.
Remarks:
The returned DictEntry is registered when existing

Definition at line 457 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, gdcm::DictSet::GetDefaultPubDict(), gdcm::Global::GetDicts(), gdcm::Dict::GetEntry(), and gdcm::RefCounter::Register().

Referenced by gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::Document::ReadNextDocEntry().

00458 {
00459    DictEntry *found = 0;
00460    Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
00461    if (!pubDict) 
00462    {
00463       gdcmWarningMacro( "We SHOULD have a default dictionary");
00464    }
00465    else
00466    {
00467       found = pubDict->GetEntry(group, elem);
00468       if( found )
00469          found->Register();
00470    }
00471    return found;
00472 }

DocEntry * gdcm::ElementSet::GetDocEntry uint16_t  group,
uint16_t  elem
[virtual]
 

retrieves a Dicom Element using (group, element)

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:

Implements gdcm::DocEntrySet.

Definition at line 163 of file gdcmElementSet.cxx.

References TagHT, and gdcm::DictEntry::TranslateToKey().

Referenced by gdcm::File::AnonymizeFile(), gdcm::File::AnonymizeNoLoad(), gdcm::FileHelper::CopyDataEntry(), gdcm::DicomDir::CreateDicomDir(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::DicomDir::DoTheLoadingJob(), gdcm::File::GetPixelAreaLength(), gdcm::File::GetPixelOffset(), gdcm::Document::GetTransferSyntax(), gdcm::File::HasLUT(), gdcm::Document::IsDicomV3(), gdcm::Document::IsPapyrus(), gdcm::File::IsReadable(), gdcm::Document::LoadEntryBinArea(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore().

00164 {
00165    TagKey key = DictEntry::TranslateToKey(group, elem);
00166    TagDocEntryHT::iterator it = TagHT.find(key);
00167 
00168    if ( it!=TagHT.end() )
00169       return it->second;
00170    return NULL;
00171 }

void * gdcm::DocEntrySet::GetEntryBinArea uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Gets (from Header) a 'non string' element value.

Parameters:
group group number of the Entry
elem element number of the Entry
Returns:
Pointer to the 'non string' area

Definition at line 69 of file gdcmDocEntrySet.cxx.

References gdcm::DataEntry::GetBinArea(), and gdcm::DocEntrySet::GetDataEntry().

Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().

00070 {
00071    DataEntry *entry = GetDataEntry(group, elem);
00072    if ( entry )
00073       return entry->GetBinArea();
00074    return 0;
00075 }

int gdcm::DocEntrySet::GetEntryLength uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Searches within the DocEntrySet for the value length of a given tag..

Parameters:
group Group number of the searched tag.
elem Element number of the searched tag.
Returns:
Corresponding element length; -1 if not found

Definition at line 84 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetLength().

Referenced by gdcm::DicomDir::SetElement(), and gdcm::File::Write().

00085 {
00086    DocEntry *entry = GetDocEntry(group, elem);
00087    if ( entry )
00088       return entry->GetLength();
00089    return -1;
00090 }

std::string gdcm::DocEntrySet::GetEntryString uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Get the "std::string representable" value of the Dicom entry.

Parameters:
group Group number of the searched tag.
elem Element number of the searched tag.
Returns:
Corresponding element value when it exists, and the string GDCM_UNFOUND otherwise.

Definition at line 47 of file gdcmDocEntrySet.cxx.

References gdcm::GDCM_NOTLOADED, gdcm::GDCM_UNFOUND, gdcm::GDCM_UNREAD, gdcm::DocEntrySet::GetDocEntry(), gdcm::DataEntry::GetString(), gdcm::DataEntry::IsNotLoaded(), gdcm::DataEntry::IsUnfound(), and gdcm::DataEntry::IsUnread().

Referenced by gdcm::SerieHelper::AddFileName(), gdcm::File::AnonymizeFile(), gdcm::FileHelper::CheckMandatoryElements(), gdcm::SerieHelper::CreateUniqueSeriesIdentifier(), gdcm::SerieHelper::CreateUserDefinedFileIdentifier(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::File::DoTheLoadingJob(), gdcm::File::GetImageNumber(), gdcm::File::GetImageOrientationPatient(), gdcm::File::GetLUTNbits(), gdcm::File::GetModality(), gdcm::File::GetNumberOfScalarComponents(), gdcm::File::GetNumberOfScalarComponentsRaw(), gdcm::File::GetPixelSize(), gdcm::File::GetPixelType(), gdcm::Document::GetTransferSyntaxName(), gdcm::PixelReadConvert::GrabInformationsFromFile(), gdcm::File::IsMonochrome(), gdcm::File::IsMonochrome1(), gdcm::File::IsPaletteColor(), gdcm::File::IsReadable(), gdcm::File::IsYBRFull(), gdcm::Document::operator<(), and gdcm::DicomDir::SetElement().

00048 {
00049    DataEntry *entry = dynamic_cast<DataEntry *>(GetDocEntry(group,elem));
00050    if ( entry )
00051    {
00052       if( entry->IsNotLoaded() )
00053          return GDCM_NOTLOADED;
00054       if( entry->IsUnfound() )
00055          return GDCM_UNFOUND;
00056       if( entry->IsUnread() )
00057          return GDCM_UNREAD;
00058       return entry->GetString();
00059    }
00060    return GDCM_UNFOUND;
00061 }

DocEntry * gdcm::ElementSet::GetFirstEntry  )  [virtual]
 

Get the first entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).

Returns:
The first DocEntry if found, otherwhise NULL

Implements gdcm::DocEntrySet.

Definition at line 133 of file gdcmElementSet.cxx.

References ItTagHT, and TagHT.

Referenced by gdcm::Document::ComputeGroup0002Length(), gdcm::DicomDir::DoTheLoadingJob(), gdcm::DicomDir::NewMeta(), and gdcm::Validator::SetInput().

00134 {
00135    ItTagHT = TagHT.begin();
00136    if (ItTagHT != TagHT.end())
00137       return  ItTagHT->second;
00138    return NULL;
00139 }

DocEntry * gdcm::ElementSet::GetNextEntry  )  [virtual]
 

Get the next entry while visiting *the* 'zero level' DocEntrySet (DocEntries out of any Sequence).

Note:
: meaningfull only if GetFirstEntry already called
Returns:
The next DocEntry if found, otherwhise NULL

Implements gdcm::DocEntrySet.

Definition at line 147 of file gdcmElementSet.cxx.

References gdcmAssertMacro, ItTagHT, and TagHT.

Referenced by gdcm::Document::ComputeGroup0002Length(), and gdcm::Validator::SetInput().

00148 {
00149    gdcmAssertMacro (ItTagHT != TagHT.end());
00150 
00151    ++ItTagHT;
00152    if (ItTagHT != TagHT.end())
00153       return  ItTagHT->second;
00154    return NULL;
00155 }

int gdcm::Base::GetPrintLevel  )  [inline, inherited]
 

Gets the print level for the Dicom Entries.

Definition at line 50 of file gdcmBase.h.

00050 { return PrintLevel; }

const unsigned long& gdcm::RefCounter::GetRefCount  )  const [inline, inherited]
 

Get the reference counting.

Returns:
Reference count

Definition at line 56 of file gdcmRefCounter.h.

00057    {
00058       return RefCount;
00059    }

SeqEntry * gdcm::DocEntrySet::GetSeqEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Same as Document::GetDocEntry except it returns a result only when the corresponding entry is of type SeqEntry.

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:
When present, the corresponding SeqEntry.

Definition at line 115 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry().

Referenced by gdcm::Document::DoTheLoadingDocumentJob().

00116 {
00117    DocEntry *currentEntry = GetDocEntry(group, elem);
00118    if ( !currentEntry )
00119       return NULL;
00120       
00121    return dynamic_cast<SeqEntry*>(currentEntry);
00122 }

DataEntry * gdcm::DocEntrySet::InsertEntryBinArea uint8_t *  binArea,
int  lgth,
uint16_t  group,
uint16_t  elem,
VRKey const &  vr = GDCM_VRUNKNOWN
[inherited]
 

Modifies the value of a given Header Entry (Dicom Element) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.

Parameters:
binArea (binary) value to be set
lgth length of the Bin Area we want to set
group Group number of the Entry
elem Element number of the Entry
vr V(alue) R(epresentation) of the Entry -if private Entry-
Returns:
pointer to the modified/created Header Entry (NULL when creation failed).

Definition at line 270 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::RemoveEntry(), and gdcm::DocEntrySet::SetEntryBinArea().

Referenced by gdcm::FileHelper::InsertEntryBinArea().

00273 {
00274    DataEntry *dataEntry = 0;
00275    DocEntry *currentEntry = GetDocEntry( group, elem );
00276 
00277    // Verify the currentEntry
00278    if (currentEntry)
00279    {
00280       dataEntry = dynamic_cast<DataEntry *>(currentEntry);
00281 
00282       // Verify the VR
00283       if ( dataEntry )
00284          if ( dataEntry->GetVR()!=vr )
00285             dataEntry = NULL;
00286 
00287       // if currentEntry doesn't correspond to the requested dataEntry
00288       if ( !dataEntry)
00289       {
00290          if ( !RemoveEntry(currentEntry) )
00291          {
00292             gdcmWarningMacro( "Removal of previous DocEntry failed.");
00293             return NULL;
00294          }
00295       }
00296    }
00297 
00298    // Create a new dataEntry if necessary
00299    if ( !dataEntry)
00300    {
00301       dataEntry = NewDataEntry(group, elem, vr);
00302 
00303       if ( !AddEntry(dataEntry) )
00304       {
00305          gdcmWarningMacro( "AddEntry failed although this is a creation.");
00306          dataEntry->Delete();
00307          return NULL;
00308       }
00309       dataEntry->Delete();
00310    }
00311 
00312    // Set the dataEntry value
00313    uint8_t *tmpArea;
00314    if ( lgth>0 && binArea )
00315    {
00316       tmpArea = new uint8_t[lgth];
00317       memcpy(tmpArea,binArea,lgth);
00318    }
00319    else
00320    {
00321       tmpArea = 0;
00322    }
00323    if ( !SetEntryBinArea(tmpArea,lgth,dataEntry) )
00324    {
00325       if ( tmpArea )
00326       {
00327          delete[] tmpArea;
00328       }
00329    }
00330    return dataEntry;
00331 }  

DataEntry * gdcm::DocEntrySet::InsertEntryString std::string const &  value,
uint16_t  group,
uint16_t  elem,
VRKey const &  vr = GDCM_VRUNKNOWN
[inherited]
 

Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant.

Parameters:
value (string) Value to be set
group Group number of the Entry
elem Element number of the Entry
vr V(alue) R(epresentation) of the Entry -if private Entry-
Returns:
pointer to the modified/created Header Entry (NULL when creation failed).

Definition at line 212 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::RemoveEntry(), and gdcm::DocEntrySet::SetEntryString().

Referenced by gdcm::FileHelper::InsertEntryString(), gdcm::FileHelper::Write(), and gdcm::File::Write().

00215 {
00216    DataEntry *dataEntry = 0;
00217    DocEntry *currentEntry = GetDocEntry( group, elem );
00218    
00219    if (currentEntry)
00220    {
00221       dataEntry = dynamic_cast<DataEntry *>(currentEntry);
00222 
00223       // Verify the VR
00224       if ( dataEntry )
00225          if ( dataEntry->GetVR()!=vr )
00226             dataEntry = NULL;
00227 
00228       // if currentEntry doesn't correspond to the requested dataEntry
00229       if ( !dataEntry)
00230       {
00231          if ( !RemoveEntry(currentEntry) )
00232          {
00233             gdcmWarningMacro( "Removal of previous DocEntry failed.");
00234             return NULL;
00235          }
00236       }
00237    }
00238 
00239    // Create a new dataEntry if necessary
00240    if ( !dataEntry )
00241    {
00242       dataEntry = NewDataEntry( group, elem, vr );
00243 
00244       if ( !AddEntry(dataEntry) )
00245       {
00246          gdcmWarningMacro("AddEntry failed although this is a creation.");
00247          dataEntry->Delete();
00248          return NULL;
00249       }
00250       dataEntry->Delete();
00251    }
00252 
00253    // Set the dataEntry value
00254    SetEntryString(value, dataEntry); // The std::string value
00255    return dataEntry;
00256 }

SeqEntry * gdcm::DocEntrySet::InsertSeqEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Creates a new gdcm::SeqEntry and adds it to the current DocEntrySet. (remove any existing entry with same group,elem).

Parameters:
group Group number of the Entry
elem Element number of the Entry
Returns:
pointer to the created SeqEntry (NULL when creation failed).

Definition at line 341 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::AddEntry(), gdcm::RefCounter::Delete(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::DocEntrySet::RemoveEntry().

Referenced by gdcm::FileHelper::InsertSeqEntry().

00342 {
00343    SeqEntry *seqEntry = 0;
00344    DocEntry *currentEntry = GetDocEntry( group, elem );
00345 
00346    // Verify the currentEntry
00347    if ( currentEntry )
00348    {
00349       seqEntry = dynamic_cast<SeqEntry *>(currentEntry);
00350 
00351       // Verify the VR
00352       if ( seqEntry )
00353          seqEntry = NULL;
00354 
00355       // if currentEntry doesn't correspond to the requested seqEntry
00356       if ( !seqEntry )
00357       {
00358          if (!RemoveEntry(currentEntry))
00359          {
00360             gdcmWarningMacro( "Removal of previous DocEntry failed for ("
00361                <<std::hex << group << "|" << elem <<")" );
00362             return NULL;
00363          }
00364       }
00365    }
00366    // Create a new seqEntry if necessary
00367    if ( !seqEntry )
00368    {
00369       seqEntry = NewSeqEntry(group, elem);
00370 
00371       if ( !AddEntry(seqEntry) )
00372       {
00373          gdcmWarningMacro( "AddEntry failed although this is a creation for ("
00374             <<std::hex << group << "|" << elem <<")" );
00375          seqEntry->Delete();
00376          return NULL;
00377       }
00378       seqEntry->Delete();
00379    }
00380    // Remark :
00381    // SequenceDelimitationItem will be added at the end of the SeqEntry,
00382    // at write time
00383    return seqEntry;
00384 } 

bool gdcm::ElementSet::IsEmpty  )  [inline, virtual]
 

Tells us if the ElementSet contains no entry.

Implements gdcm::DocEntrySet.

Definition at line 58 of file gdcmElementSet.h.

Referenced by gdcm::Document::DoTheLoadingDocumentJob(), and gdcm::Document::IsParsable().

00058 { return TagHT.empty(); }

bool gdcm::ElementSet::MayIWrite uint16_t   )  [inline, protected]
 

Some group are illegal withing some Dicom Documents Only the Document knows it.

Reimplemented in gdcm::File.

Definition at line 67 of file gdcmElementSet.h.

Referenced by WriteContent().

00068                  { return true; }

DataEntry * gdcm::DocEntrySet::NewDataEntry uint16_t  group,
uint16_t  elem,
VRKey const &  vr = GDCM_VRUNKNOWN
[inherited]
 

Build a new DataEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.

Parameters:
group Group number of the new Entry
elem Element number of the new Entry
vr V(alue) R(epresentation) of the new Entry
Remarks:
The user of this method must destroy the DataEntry when unused

Definition at line 406 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::DataEntry::New(), and gdcm::RefCounter::Unregister().

Referenced by gdcm::FileHelper::CopyDataEntry(), gdcm::DocEntrySet::InsertEntryBinArea(), gdcm::DocEntrySet::InsertEntryString(), and gdcm::Document::ReadNextDocEntry().

00408 {
00409    DictEntry *dictEntry = GetDictEntry(group, elem, vr);
00410 
00411    DataEntry *newEntry = DataEntry::New(dictEntry);
00412    dictEntry->Unregister(); // GetDictEntry register it
00413    if (!newEntry) 
00414    {
00415       gdcmWarningMacro( "Failed to allocate DataEntry for ("
00416           <<std::hex << group << "|" << elem <<")" );
00417       return 0;
00418    }
00419    return newEntry;
00420 }

SeqEntry * gdcm::DocEntrySet::NewSeqEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Build a new SeqEntry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.

Parameters:
group Group number of the new Entry
elem Element number of the new Entry
Remarks:
The user of this method must destroy the SeqEntry when unused

Definition at line 430 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), gdcm::SeqEntry::New(), and gdcm::RefCounter::Unregister().

Referenced by gdcm::Document::Backtrack(), gdcm::DocEntrySet::InsertSeqEntry(), and gdcm::Document::ReadNextDocEntry().

00431 {
00432    DictEntry *dictEntry = GetDictEntry(group, elem, "SQ");
00433 
00434    SeqEntry *newEntry = SeqEntry::New( dictEntry );
00435    dictEntry->Unregister(); // GetDictEntry register it
00436    if (!newEntry)
00437    {
00438       gdcmWarningMacro( "Failed to allocate SeqEntry for ("
00439          <<std::hex << group << "|" << elem <<")" );
00440       return 0;
00441    }
00442    return newEntry;
00443 }

void gdcm::ElementSet::Print std::ostream &  os = std::cout,
std::string const &  indent = ""
[virtual]
 

Prints the Header Entries (Dicom Elements) from the H Table.

Parameters:
os ostream to write to
indent Indentation string to be prepended during printing

Reimplemented from gdcm::Base.

Reimplemented in gdcm::DicomDir.

Definition at line 209 of file gdcmElementSet.cxx.

References gdcm::DataEntry::FLAG_PIXELDATA, gdcm::DocEntrySet::GetDataEntry(), gdcm::DocEntry::Print(), gdcm::Base::PrintLevel, gdcm::DataEntry::SetFlag(), gdcm::Base::SetPrintLevel(), and TagHT.

Referenced by gdcm::FileHelper::Print().

00210 {
00211    // Let's change the 'warning value' for Pixel Data,
00212    // to avoid human reader to be confused by 'gdcm::NotLoaded'.   
00213    DataEntry *pixelElement = GetDataEntry(0x7fe0,0x0010);
00214    if ( pixelElement != 0 )
00215    {
00216       pixelElement->SetFlag( DataEntry::FLAG_PIXELDATA );
00217    }
00218 
00219    for( TagDocEntryHT::const_iterator i = TagHT.begin(); i != TagHT.end(); ++i)
00220    {
00221       DocEntry *entry = i->second;
00222 
00223       entry->SetPrintLevel(PrintLevel);
00224       entry->Print(os);   
00225 
00226       if ( dynamic_cast<SeqEntry *>(entry) )
00227       {
00228          // Avoid the newline for a sequence:
00229          continue;
00230       }
00231       os << std::endl;
00232    }
00233 }

void gdcm::RefCounter::Register  )  [inline, inherited]
 

Register the object.

Remarks:
It increments the reference counting

Definition at line 44 of file gdcmRefCounter.h.

Referenced by gdcm::SQItem::AddEntry(), AddEntry(), gdcm::Dict::AddEntry(), gdcm::SeqEntry::AddSQItem(), gdcm::SeqEntry::Copy(), gdcm::DicomDir::Copy(), gdcm::DocEntry::DocEntry(), gdcm::FileHelper::FileHelper(), gdcm::DocEntrySet::GetDictEntry(), gdcm::CommandManager::InSetCommand(), gdcm::DocEntryArchive::Push(), gdcm::Dict::ReplaceEntry(), and gdcm::SeqEntry::SetDelimitationItem().

00044 { RefCount++; }

bool gdcm::ElementSet::RemoveEntry DocEntry entryToRemove  )  [virtual]
 

Clear the hash table from given entry AND delete the entry.

Parameters:
entryToRemove Entry to remove AND delete.

Implements gdcm::DocEntrySet.

Definition at line 99 of file gdcmElementSet.cxx.

References gdcmWarningMacro, gdcm::DocEntry::GetKey(), TagHT, and gdcm::RefCounter::Unregister().

Referenced by gdcm::Document::Backtrack(), gdcm::File::DoTheLoadingJob(), gdcm::DicomDir::NewMeta(), gdcm::Document::ParseDES(), gdcm::DocEntryArchive::Push(), and gdcm::DocEntryArchive::Restore().

00100 {
00101    const TagKey &key = entryToRemove->GetKey();
00102    if ( TagHT.count(key) == 1 )
00103    {
00104       TagHT.erase(key);
00105       entryToRemove->Unregister();
00106       return true;
00107    }
00108 
00109    gdcmWarningMacro( "Key not present : " << key);
00110    return false ;
00111 }

bool gdcm::DocEntrySet::SetEntryBinArea uint8_t *  content,
int  lgth,
DataEntry entry
[inherited]
 

Accesses an existing DataEntry (i.e. a Dicom Element) and modifies it's content with the given value.

Parameters:
content new value (void* -> uint8_t*) to substitute with
entry Entry to be modified
lgth new value length

Definition at line 191 of file gdcmDocEntrySet.cxx.

References gdcm::DataEntry::SetBinArea(), and gdcm::DocEntry::SetLength().

00192 {
00193    if (entry)
00194    {
00195       entry->SetLength(lgth);
00196       entry->SetBinArea(content);  
00197       return true;
00198    }
00199    return false;
00200 }

bool gdcm::DocEntrySet::SetEntryBinArea uint8_t *  content,
int  lgth,
uint16_t  group,
uint16_t  elem
[inherited]
 

Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.

Parameters:
content new value (void* -> uint8_t*) to substitute with
lgth new value length
group group number of the Dicom Element to modify
elem element number of the Dicom Element to modify

Definition at line 154 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, and gdcm::DocEntrySet::GetDataEntry().

Referenced by gdcm::DocEntrySet::InsertEntryBinArea(), and gdcm::FileHelper::SetEntryBinArea().

00156 {
00157    DataEntry *entry = GetDataEntry(group, elem);
00158    if (!entry )
00159    {
00160       gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group <<
00161                         "," << elem << " element (try promotion first).");
00162       return false;
00163    }
00164 
00165    return SetEntryBinArea(content,lgth,entry);
00166 } 

bool gdcm::DocEntrySet::SetEntryString std::string const &  content,
DataEntry entry
[inherited]
 

Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value.

Parameters:
content new value (string) to substitute with
entry Entry to be modified

Definition at line 174 of file gdcmDocEntrySet.cxx.

References gdcm::DataEntry::SetString().

00175 {
00176    if (entry)
00177    {
00178       entry->SetString(content);
00179       return true;
00180    }
00181    return false;
00182 }

bool gdcm::DocEntrySet::SetEntryString std::string const &  content,
uint16_t  group,
uint16_t  elem
[inherited]
 

Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.

Parameters:
content new value (string) to substitute with
group group number of the Dicom Element to modify
elem element number of the Dicom Element to modify

Definition at line 132 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, and gdcm::DocEntrySet::GetDataEntry().

Referenced by gdcm::File::AnonymizeFile(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::DocEntrySet::InsertEntryString(), and gdcm::FileHelper::SetEntryString().

00134 {
00135    DataEntry *entry = GetDataEntry(group, elem);
00136    if (!entry )
00137    {
00138       gdcmWarningMacro( "No corresponding DataEntry " << std::hex << group <<
00139                          "," << elem << " element (try promotion first).");
00140       return false;
00141    }
00142    return SetEntryString(content,entry);
00143 }

void gdcm::Base::SetPrintLevel int  level  )  [inline, inherited]
 

Sets the print level for the Dicom Header Elements.

Note:
0 for Light Print; 1 for 'medium' Print, 2 for Heavy Print

Definition at line 47 of file gdcmBase.h.

Referenced by gdcm::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), Print(), and gdcm::DicomDir::Print().

00047 { PrintLevel = level; }

void gdcm::RefCounter::Unregister  )  [inline, inherited]
 

Unregister the object.

Remarks:
It decrements the reference counting

Definition at line 48 of file gdcmRefCounter.h.

Referenced by gdcm::SeqEntry::ClearSQItem(), gdcm::DicomDir::Copy(), gdcm::DocEntrySet::GetDictEntry(), gdcm::CommandManager::InSetCommand(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), gdcm::Document::ReadNextDocEntry(), gdcm::SQItem::RemoveEntry(), RemoveEntry(), gdcm::SeqEntry::SetDelimitationItem(), gdcm::DocEntry::~DocEntry(), and gdcm::FileHelper::~FileHelper().

00049    {
00050       RefCount--;
00051       if(RefCount<=0)
00052          delete this;
00053    }

void gdcm::ElementSet::WriteContent std::ofstream *  fp,
FileType  filetype
[virtual]
 

Writes the Header Entries (Dicom Elements) from the H Table.

Parameters:
fp ofstream to write to
filetype filetype

Implements gdcm::DocEntrySet.

Reimplemented in gdcm::Document.

Definition at line 52 of file gdcmElementSet.cxx.

References MayIWrite(), and TagHT.

Referenced by gdcm::Document::WriteContent().

00053 {
00054    for (TagDocEntryHT::const_iterator i = TagHT.begin(); 
00055                                      i != TagHT.end(); 
00056                                     ++i)
00057    { 
00058        // depending on the gdcm::Document type 
00059        // (gdcm::File; gdcm::DicomDir, (more to come ?)
00060        // some groups *cannot* be present.
00061        // We hereby protect gdcm for writting stupid things
00062        // if they were found in the original document. 
00063        if ( !MayIWrite( (i->second)->GetGroup() ) ) 
00064           continue;
00065       // Skip 'Group Length' element, since it may be wrong.
00066       //       except for Group 0002 
00067        if ( (i->second)->GetElement() == 0x0000 
00068          && (i->second)->GetGroup() != 0x0002 )
00069           continue; 
00070        i->second->WriteContent(fp, filetype);
00071    } 
00072 }


Member Data Documentation

TagDocEntryHT::iterator gdcm::ElementSet::ItTagHT [private]
 

iterator, used to visit the TagHT variable

Definition at line 74 of file gdcmElementSet.h.

Referenced by Copy(), GetFirstEntry(), and GetNextEntry().

DocEntry* gdcm::DocEntrySet::PreviousDocEntry [protected, inherited]
 

To be able to backtrack (Private Sequence, Implicit VR related pb).

Definition at line 127 of file gdcmDocEntrySet.h.

Referenced by gdcm::Document::Backtrack(), gdcm::DocEntrySet::DocEntrySet(), and gdcm::Document::ParseDES().

int gdcm::Base::PrintLevel [protected, inherited]
 

Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Definition at line 55 of file gdcmBase.h.

Referenced by gdcm::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), Print(), gdcm::DocEntry::Print(), gdcm::DictEntry::Print(), gdcm::DicomDirStudy::Print(), gdcm::DicomDirSerie::Print(), gdcm::DicomDirPatient::Print(), gdcm::DicomDirMeta::Print(), gdcm::DicomDir::Print(), and gdcm::DataEntry::Print().

TagDocEntryHT gdcm::ElementSet::TagHT [private]
 

Hash Table (map), to provide fast access.

Definition at line 72 of file gdcmElementSet.h.

Referenced by AddEntry(), ClearEntry(), Copy(), GetDocEntry(), GetFirstEntry(), GetNextEntry(), Print(), RemoveEntry(), and WriteContent().


The documentation for this class was generated from the following files:
Generated on Fri Jan 20 10:15:05 2006 for gdcm by  doxygen 1.4.4