X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDictSet.cxx;h=3b3c53c6ee9eff6b7fa79e9653f2e32d9d770f82;hb=559c3639fc5b255b36a951f352db1addead9f78f;hp=6e5b998cc33d0bff163000bc5266d8c7531b6c50;hpb=fd37aa842b5d31ca266b6bda8a77f3201d02338d;p=gdcm.git diff --git a/src/gdcmDictSet.cxx b/src/gdcmDictSet.cxx index 6e5b998c..3b3c53c6 100644 --- a/src/gdcmDictSet.cxx +++ b/src/gdcmDictSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDictSet.cxx,v $ Language: C++ - Date: $Date: 2004/09/27 08:39:06 $ - Version: $Revision: 1.37 $ + Date: $Date: 2004/10/28 19:53:29 $ + Version: $Revision: 1.44 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,31 +21,34 @@ #include #include // For getenv +namespace gdcm +{ + //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief The Dictionnary Set obtained with this constructor simply * contains the Default Public dictionnary. */ -gdcmDictSet::gdcmDictSet() +DictSet::DictSet() { DictPath = BuildDictPath(); std::string pubDictFile(DictPath); pubDictFile += PUB_DICT_FILENAME; - Dicts[PUB_DICT_NAME] = new gdcmDict(pubDictFile); + Dicts[PUB_DICT_NAME] = new Dict(pubDictFile); } /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief Destructor */ -gdcmDictSet::~gdcmDictSet() +DictSet::~DictSet() { // Remove dictionnaries for (DictSetHT::iterator tag = Dicts.begin(); tag != Dicts.end(); ++tag) { - gdcmDict *entryToDelete = tag->second; + Dict *entryToDelete = tag->second; if ( entryToDelete ) { delete entryToDelete; @@ -55,27 +58,18 @@ gdcmDictSet::~gdcmDictSet() Dicts.clear(); // Remove virtual dictionnary entries - std::map::iterator it; - for(it = VirtualEntry.begin(); it != VirtualEntry.end(); ++it) - { - gdcmDictEntry *entry = it->second; - if ( entry ) - { - delete entry; - } - it->second = NULL; - } + VirtualEntry.clear(); } //----------------------------------------------------------------------------- // Print /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief Print, in an informal fashion, the list of all the dictionaries - * contained is this gdcmDictSet, along with their respective content. + * contained is this DictSet, along with their respective content. * @param os Output stream used for printing. */ -void gdcmDictSet::Print(std::ostream& os) +void DictSet::Print(std::ostream& os) { for (DictSetHT::iterator dict = Dicts.begin(); dict != Dicts.end(); ++dict) { @@ -87,19 +81,19 @@ void gdcmDictSet::Print(std::ostream& os) //----------------------------------------------------------------------------- // Public /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief Consider all the entries of the public dicom dictionnary. * Build all list of all the tag names of all those entries. - * \sa gdcmDictSet::GetPubDictTagNamesByCategory + * \sa DictSet::GetPubDictTagNamesByCategory * @return A list of all entries of the public dicom dictionnary. */ -std::list *gdcmDictSet::GetPubDictEntryNames() +EntryNamesList * DictSet::GetPubDictEntryNames() { return GetDefaultPubDict()->GetDictEntryNames(); } /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief * - Consider all the entries of the public dicom dictionnary. * - Build an hashtable whose keys are the names of the groups @@ -124,38 +118,37 @@ std::list *gdcmDictSet::GetPubDictEntryNames() * corresponding values are lists of all the dictionnary entries * among that group. */ -std::map > * - gdcmDictSet::GetPubDictEntryNamesByCategory() +EntryNamesByCatMap * DictSet::GetPubDictEntryNamesByCategory() { return GetDefaultPubDict()->GetDictEntryNamesByCategory(); } /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief Loads a dictionary from a specified file, and add it - * to already the existing ones contained in this gdcmDictSet. - * @param fileName Absolute or relative filename containing the + * to already the existing ones contained in this DictSet. + * @param filename Absolute or relative filename containing the * dictionary to load. * @param name Symbolic name that be used as identifier of the newly * created dictionary. */ -gdcmDict *gdcmDictSet::LoadDictFromFile(std::string const & fileName, - DictKey const & name) +Dict *DictSet::LoadDictFromFile(std::string const & filename, + DictKey const & name) { - gdcmDict *newDict = new gdcmDict(fileName); + Dict *newDict = new Dict(filename); AppendDict(newDict, name); return newDict; } /** - * \ingroup gdcmDictSet + * \ingroup DictSet * \brief Retrieve the specified dictionary (when existing) from this - * gdcmDictSet. + * DictSet. * @param dictName The symbolic name of the searched dictionary. * \result The retrieved dictionary. */ -gdcmDict *gdcmDictSet::GetDict(DictKey const & dictName) +Dict *DictSet::GetDict(DictKey const & dictName) { DictSetHT::iterator dict = Dicts.find(dictName); if(dict != Dicts.end()) @@ -166,30 +159,33 @@ gdcmDict *gdcmDictSet::GetDict(DictKey const & dictName) } /** - * \brief Create a gdcmDictEntry which will be reference + * \brief Create a DictEntry which will be reference * in no dictionnary * @return virtual entry */ -gdcmDictEntry *gdcmDictSet::NewVirtualDictEntry(uint16_t group, - uint16_t element, - std::string vr, - std::string fourth, - std::string name) +DictEntry *DictSet::NewVirtualDictEntry( uint16_t group, + uint16_t element, + TagName vr, + TagName fourth, + TagName name) { - gdcmDictEntry* entry; - const std::string tag = gdcmDictEntry::TranslateToKey(group,element) + DictEntry *entry; + const std::string tag = DictEntry::TranslateToKey(group,element) + "#" + vr + "#" + fourth + "#" + name; - std::map::iterator it; + TagKeyHT::iterator it; it = VirtualEntry.find(tag); if(it != VirtualEntry.end()) { - entry = it->second; + entry = &(it->second); } else { - entry = new gdcmDictEntry(group, element, vr, fourth, name); - VirtualEntry[tag] = entry; + DictEntry ent(group, element, vr, fourth, name); + VirtualEntry.insert( + std::map::value_type + (tag, ent)); + entry = &(VirtualEntry.find(tag)->second); } return entry; @@ -202,7 +198,7 @@ gdcmDictEntry *gdcmDictSet::NewVirtualDictEntry(uint16_t group, * to "../Dicts/". * @return path to directory containing the dictionnaries */ -std::string gdcmDictSet::BuildDictPath() +std::string DictSet::BuildDictPath() { std::string resultPath; const char *envPath = 0; @@ -215,7 +211,7 @@ std::string gdcmDictSet::BuildDictPath() { resultPath += '/'; } - dbg.Verbose(1, "gdcmDictSet::BuildDictPath:", + dbg.Verbose(1, "DictSet::BuildDictPath:", "Dictionary path set from environnement"); } else @@ -228,11 +224,11 @@ std::string gdcmDictSet::BuildDictPath() //----------------------------------------------------------------------------- // Protected -bool gdcmDictSet::AppendDict(gdcmDict *newDict, DictKey const & name) +bool DictSet::AppendDict(Dict *newDict, DictKey const & name) { Dicts[name] = newDict; - return true; //FIXME + return true; } //----------------------------------------------------------------------------- @@ -240,4 +236,4 @@ bool gdcmDictSet::AppendDict(gdcmDict *newDict, DictKey const & name) //----------------------------------------------------------------------------- - +} // end namespace gdcm