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

gdcm::DictSet Class Reference

Container for managing a set of loaded dictionaries (Dict). More...

#include <gdcmDictSet.h>

Inheritance diagram for gdcm::DictSet:

gdcm::Base List of all members.

Public Member Functions

 DictSet ()
 The Dictionary Set obtained with this constructor simply contains the Default Public dictionary.

 ~DictSet ()
 Destructor.

void Print (std::ostream &os=std::cout, std::string const &indent="")
 Print, in an informal fashion, the list of all the dictionaries contained is this DictSet, along with their respective content.

DictLoadDictFromFile (std::string const &fileName, DictKey const &name)
 Loads a dictionary from a specified file, and add it to already the existing ones contained in this DictSet.

DictGetDict (DictKey const &DictName)
 Retrieve the specified dictionary (when existing) from this DictSet.

DictGetDefaultPubDict ()
 Retrieve the default reference DICOM V3 public dictionary.

DictEntryNewVirtualDictEntry (uint16_t group, uint16_t elem, TagName vr=GDCM_UNKNOWN, TagName vm=GDCM_UNKNOWN, TagName name=GDCM_UNKNOWN)
 Create a DictEntry which will be referenced in no dictionary.

DictGetFirstEntry ()
 Get the first entry while visiting the DictSet.

DictGetNextEntry ()
 Get the next entry while visiting the Hash table (DictSetHT).

void SetPrintLevel (int level)
 Sets the print level for the Dicom Header Elements.

int GetPrintLevel ()
 Gets the print level for the Dicom Entries.


Static Public Member Functions

std::string BuildDictPath ()
 Obtain from the GDCM_DICT_PATH environnement variable the path to directory containing the dictionaries. When the environnement variable is absent the path is defaulted to "../Dicts/".


Protected Member Functions

bool AppendDict (Dict *NewDict, DictKey const &name)
 Adds a Dictionary to a DictSet.


Protected Attributes

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


Private Attributes

DictSetHT Dicts
 Hash table of all dictionaries contained in this DictSet.

DictSetHT::iterator ItDictHt
std::string DictPath
 Directory path to dictionaries.

TagKeyHT VirtualEntry
 H table for the on the fly created DictEntries.


Detailed Description

Container for managing a set of loaded dictionaries (Dict).

Note:
Hopefully, sharing dictionaries should avoid
reloading an already loaded dictionary (saving time)
having many in memory representations of the same dictionary
(saving memory).

Definition at line 40 of file gdcmDictSet.h.


Constructor & Destructor Documentation

gdcm::DictSet::DictSet  ) 
 

The Dictionary Set obtained with this constructor simply contains the Default Public dictionary.

Definition at line 33 of file gdcmDictSet.cxx.

References BuildDictPath(), DictPath, Dicts, PUB_DICT_FILENAME, and PUB_DICT_NAME.

00034 {
00035    DictPath = BuildDictPath();
00036    std::string pubDictFile(DictPath);
00037    pubDictFile += PUB_DICT_FILENAME;
00038    Dicts[PUB_DICT_NAME] = new Dict(pubDictFile);
00039 }

gdcm::DictSet::~DictSet  ) 
 

Destructor.

Definition at line 44 of file gdcmDictSet.cxx.

References Dicts, and VirtualEntry.

00045 {
00046    // Remove dictionaries
00047    for (DictSetHT::iterator tag = Dicts.begin(); tag != Dicts.end(); ++tag) 
00048    {
00049       Dict *entryToDelete = tag->second;
00050       if ( entryToDelete )
00051       {
00052          delete entryToDelete;
00053       }
00054       tag->second = NULL;
00055    }
00056    Dicts.clear();
00057 
00058    // Remove virtual dictionary entries
00059    VirtualEntry.clear();
00060 }


Member Function Documentation

bool gdcm::DictSet::AppendDict Dict newDict,
DictKey const &  name
[protected]
 

Adds a Dictionary to a DictSet.

Returns:
always true

Definition at line 193 of file gdcmDictSet.cxx.

References gdcm::DictKey, and Dicts.

Referenced by LoadDictFromFile().

00194 {
00195    Dicts[name] = newDict;
00196 
00197    return true;
00198 }

std::string gdcm::DictSet::BuildDictPath  )  [static]
 

Obtain from the GDCM_DICT_PATH environnement variable the path to directory containing the dictionaries. When the environnement variable is absent the path is defaulted to "../Dicts/".

Returns:
path to directory containing the dictionaries

Definition at line 164 of file gdcmDictSet.cxx.

References gdcmWarningMacro, and PUB_DICT_PATH.

Referenced by DictSet().

00165 {
00166    std::string resultPath;
00167    const char *envPath = 0;
00168    envPath = getenv("GDCM_DICT_PATH");
00169 
00170    if (envPath && (strlen(envPath) != 0)) 
00171    {
00172       resultPath = envPath;
00173       if ( resultPath[resultPath.length()-1] != '/' )
00174       {
00175          resultPath += '/';
00176       }
00177       gdcmWarningMacro( "Dictionary path set from environnement");
00178    } 
00179    else
00180    {
00181       resultPath = PUB_DICT_PATH;
00182    }
00183 
00184    return resultPath;
00185 }

Dict* gdcm::DictSet::GetDefaultPubDict  )  [inline]
 

Retrieve the default reference DICOM V3 public dictionary.

Definition at line 58 of file gdcmDictSet.h.

References PUB_DICT_NAME.

00058 { return GetDict(PUB_DICT_NAME); };

Dict * gdcm::DictSet::GetDict DictKey const &  dictName  ) 
 

Retrieve the specified dictionary (when existing) from this DictSet.

Parameters:
dictName The symbolic name of the searched dictionary.
Returns:
The retrieved dictionary.

Definition at line 87 of file gdcmDictSet.cxx.

References gdcm::DictKey, and Dicts.

00088 {
00089    DictSetHT::iterator dict = Dicts.find(dictName);
00090    if(dict != Dicts.end())
00091    {
00092       return dict->second;
00093    }
00094    return NULL;
00095 }

Dict * gdcm::DictSet::GetFirstEntry  ) 
 

Get the first entry while visiting the DictSet.

Returns:
The first Dict if found, otherwhise NULL

Definition at line 134 of file gdcmDictSet.cxx.

References Dicts, and ItDictHt.

00135 {
00136    ItDictHt = Dicts.begin();
00137    if( ItDictHt != Dicts.end() )
00138       return ItDictHt->second;
00139    return NULL;
00140 }

Dict * gdcm::DictSet::GetNextEntry  ) 
 

Get the next entry while visiting the Hash table (DictSetHT).

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

Definition at line 147 of file gdcmDictSet.cxx.

References Dicts, gdcmAssertMacro, and ItDictHt.

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

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

Gets the print level for the Dicom Entries.

Definition at line 48 of file gdcmBase.h.

00048 { return PrintLevel; };

Dict * gdcm::DictSet::LoadDictFromFile std::string const &  filename,
DictKey const &  name
 

Loads a dictionary from a specified file, and add it to already the existing ones contained in this DictSet.

Parameters:
filename Absolute or relative filename containing the dictionary to load.
name Symbolic name that be used as identifier of the newly created dictionary.

Definition at line 72 of file gdcmDictSet.cxx.

References AppendDict(), and gdcm::DictKey.

00074 {
00075    Dict *newDict = new Dict(filename);
00076    AppendDict(newDict, name);
00077 
00078    return newDict;
00079 }

DictEntry * gdcm::DictSet::NewVirtualDictEntry uint16_t  group,
uint16_t  element,
TagName  vr = GDCM_UNKNOWN,
TagName  vm = GDCM_UNKNOWN,
TagName  name = GDCM_UNKNOWN
 

Create a DictEntry which will be referenced in no dictionary.

Returns:
virtual entry

Definition at line 102 of file gdcmDictSet.cxx.

References gdcm::TagName, and VirtualEntry.

00107 {
00108    DictEntry *entry;
00109    const std::string tag = DictEntry::TranslateToKey(group,element)
00110                            + "#" + vr + "#" + vm + "#" + name;
00111    TagKeyHT::iterator it;
00112    
00113    it = VirtualEntry.find(tag);
00114    if(it != VirtualEntry.end())
00115    {
00116       entry = &(it->second);
00117    }
00118    else
00119    {
00120       DictEntry ent(group, element, vr, vm, name);
00121       VirtualEntry.insert(
00122          std::map<TagKey, DictEntry>::value_type
00123             (tag, ent));
00124       entry = &(VirtualEntry.find(tag)->second);
00125    }
00126 
00127    return entry;
00128 }

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

Print, in an informal fashion, the list of all the dictionaries contained is this DictSet, along with their respective content.

Parameters:
os Output stream used for printing.
indent Indentation string to be prepended during printing

Reimplemented from gdcm::Base.

Definition at line 211 of file gdcmDictSet.cxx.

References Dicts.

00212 {
00213    for (DictSetHT::iterator dict = Dicts.begin(); dict != Dicts.end(); ++dict)
00214    {
00215       os << "Printing dictionary " << dict->first << std::endl;
00216       dict->second->Print(os);
00217    }
00218 }

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

Definition at line 45 of file gdcmBase.h.

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

00045 { PrintLevel = level; };


Member Data Documentation

std::string gdcm::DictSet::DictPath [private]
 

Directory path to dictionaries.

Definition at line 83 of file gdcmDictSet.h.

Referenced by DictSet().

DictSetHT gdcm::DictSet::Dicts [private]
 

Hash table of all dictionaries contained in this DictSet.

Definition at line 79 of file gdcmDictSet.h.

Referenced by AppendDict(), DictSet(), GetDict(), GetFirstEntry(), GetNextEntry(), Print(), and ~DictSet().

DictSetHT::iterator gdcm::DictSet::ItDictHt [private]
 

Definition at line 80 of file gdcmDictSet.h.

Referenced by GetFirstEntry(), and GetNextEntry().

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

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

Definition at line 53 of file gdcmBase.h.

Referenced by gdcm::Base::Base().

TagKeyHT gdcm::DictSet::VirtualEntry [private]
 

H table for the on the fly created DictEntries.

Definition at line 86 of file gdcmDictSet.h.

Referenced by NewVirtualDictEntry(), and ~DictSet().


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