-void gdcmDictSet::SetDictPath(void) {
- const char* EnvPath = (char*)0;
- EnvPath = getenv("GDCM_DICT_PATH");
- if (EnvPath && (strlen(EnvPath) != 0)) {
- DictPath = EnvPath;
- if (DictPath[DictPath.length() -1] != '/' )
- DictPath += '/';
- dbg.Verbose(1, "gdcmDictSet::SetDictPath:",
- "Dictionary path set from environnement");
- } else
- DictPath = PUB_DICT_PATH;
+/**
+ * \brief Destructor
+ */
+DictSet::~DictSet()
+{
+ // Remove dictionaries
+ for (DictSetHT::iterator tag = Dicts.begin(); tag != Dicts.end(); ++tag)
+ {
+ Dict *entryToDelete = tag->second;
+ if ( entryToDelete )
+ {
+ delete entryToDelete;
+ }
+ tag->second = NULL;
+ }
+ Dicts.clear();
+
+ // Remove virtual dictionary entries
+ VirtualEntries.clear();
+}
+
+//-----------------------------------------------------------------------------
+// Public
+/**
+ * \brief Loads a dictionary from a specified file, and add it
+ * 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.
+ */
+Dict *DictSet::LoadDictFromFile(std::string const &filename,
+ DictKey const &name)
+{
+ Dict *newDict = new Dict(filename);
+ AppendDict(newDict, name);
+
+ return newDict;
+}
+
+/**
+ * \brief Retrieve the specified dictionary (when existing) from this
+ * DictSet.
+ * @param dictName The symbolic name of the searched dictionary.
+ * \result The retrieved dictionary.
+ */
+Dict *DictSet::GetDict(DictKey const &dictName)
+{
+ DictSetHT::iterator dict = Dicts.find(dictName);
+ if ( dict != Dicts.end() )
+ {
+ return dict->second;
+ }
+ return NULL;
+}
+
+/**
+ * \brief Create a DictEntry which will be referenced in no dictionary
+ * @param group Group number of the Entry
+ * @param elem Element number of the Entry
+ * @param vr Value Representation of the Entry
+ * @param vm Value Multiplicity of the Entry
+ * @param name English name of the Entry
+ * @return virtual entry
+ */
+DictEntry *DictSet::NewVirtualDictEntry( uint16_t group,
+ uint16_t elem,
+ const VRKey &vr,
+ const TagName &vm,
+ const TagName &name)
+{
+ DictEntry *entry;
+
+ // Let's follow 'Purify' advice
+ // const std::string tag = DictEntry::TranslateToKey(group,elem)
+ // + "#" + vr + "#" + vm + "#" + name;
+ ExtendedTagKey tag = DictEntry::TranslateToKey(group,elem).str();
+ tag += "#" + vr.str() + "#" + vm + "#" + name;
+
+ ExtendedTagKeyHT::iterator it;
+
+ it = VirtualEntries.find(tag);
+ if ( it != VirtualEntries.end() )
+ {
+ entry = &(it->second);
+ }
+ else
+ {
+ DictEntry ent(group, elem, vr, vm, name);
+ VirtualEntries.insert(
+ ExtendedTagKeyHT::value_type(tag, ent) );
+ entry = &(VirtualEntries.find(tag)->second);
+ }
+
+ return entry;