+2003-04-15 Eric Boix <Eric.Boix@creatis.insa-lyon.fr> with JPR
+ * Memory link hunt (by using valgrind --leak-check=yes PrintHeader).
+ - added src/gdcmVR.cxx gdcmVR.h that objectify the previous
+ gdcmHeader::_dicom_vr.
+ - gdcmHeader::InitVRDict transfered as gdcmVR::gdcmVR().
+ - gdcmHeader::dicom_vr is now of type gdcmVR* as opposed to
+ VRHT*.
+ - gdcmGlobal global object contained class added (see src/gdcmUtil.x)
+
2003-04-9 Eric Boix <Eric.Boix@creatis.insa-lyon.fr> with JPR
* src/Makefile.am now exports all the necessary include files at
make install stage.
gdcmElValSet.cxx \
gdcmHeaderIdo.cxx \
gdcmFile.cxx \
+ gdcmVR.cxx \
gdcmJpeg.cxx
libgdcmincludedir = $(includedir)
gdcmDictEntry.h \
gdcmElValue.h \
gdcmElValSet.h \
+ gdcmVR.h \
gdcmFile.h
EXTRA_DIST = \
dicts[PUB_DICT_NAME] = DefaultPubDict;
}
+gdcmDictSet::~gdcmDictSet() {
+ //FIXME : first destroy pointed dictionaries before trashing hash table.
+ dicts.clear();
+}
+
/**
* \ingroup gdcmDictSet
* \brief Loads a dictionary from a specified file, and add it
// TODO Swig int LoadAllDictFromDirectory(string DirectoryName);
// TODO Swig string* GetAllDictNames();
gdcmDictSet(void);
+ ~gdcmDictSet(void);
void Print(ostream&);
gdcmDict* GetDict(DictKey DictName);
gdcmDict* GetDefaultPubDict(void);
// Refer to gdcmHeader::SetMaxSizeLoadElementValue()
#define _MaxSizeLoadElementValue_ 1024
-VRHT * gdcmHeader::dicom_vr = (VRHT*)0;
+gdcmVR * gdcmHeader::dicom_vr = (gdcmVR*)0;
void gdcmHeader::Initialise(void) {
if (!gdcmHeader::dicom_vr)
- InitVRDict();
+ gdcmHeader::dicom_vr = gdcmGlobal::GetVR();
Dicts = new gdcmDictSet();
RefPubDict = Dicts->GetDefaultPubDict();
RefShaDict = (gdcmDict*)0;
}
gdcmHeader::~gdcmHeader (void) {
+ delete Dicts;
//FIXME obviously there is much to be done here !
return;
}
-void gdcmHeader::InitVRDict (void) {
- if (dicom_vr) {
- dbg.Verbose(0, "gdcmHeader::InitVRDict:", "VR dictionary allready set");
- return;
- }
- VRHT *vr = new VRHT;
- (*vr)["AE"] = "Application Entity"; // At most 16 bytes
- (*vr)["AS"] = "Age String"; // Exactly 4 bytes
- (*vr)["AT"] = "Attribute Tag"; // 2 16-bit unsigned short integers
- (*vr)["CS"] = "Code String"; // At most 16 bytes
- (*vr)["DA"] = "Date"; // Exactly 8 bytes
- (*vr)["DS"] = "Decimal String"; // At most 16 bytes
- (*vr)["DT"] = "Date Time"; // At most 26 bytes
- (*vr)["FL"] = "Floating Point Single"; // 32-bit IEEE 754:1985 float
- (*vr)["FD"] = "Floating Point Double"; // 64-bit IEEE 754:1985 double
- (*vr)["IS"] = "Integer String"; // At most 12 bytes
- (*vr)["LO"] = "Long String"; // At most 64 chars
- (*vr)["LT"] = "Long Text"; // At most 10240 chars
- (*vr)["OB"] = "Other Byte String"; // String of bytes (vr independant)
- (*vr)["OW"] = "Other Word String"; // String of 16-bit words (vr dep)
- (*vr)["PN"] = "Person Name"; // At most 64 chars
- (*vr)["SH"] = "Short String"; // At most 16 chars
- (*vr)["SL"] = "Signed Long"; // Exactly 4 bytes
- (*vr)["SQ"] = "Sequence of Items"; // Not Applicable
- (*vr)["SS"] = "Signed Short"; // Exactly 2 bytes
- (*vr)["ST"] = "Short Text"; // At most 1024 chars
- (*vr)["TM"] = "Time"; // At most 16 bytes
- (*vr)["UI"] = "Unique Identifier"; // At most 64 bytes
- (*vr)["UL"] = "Unsigned Long "; // Exactly 4 bytes
- (*vr)["UN"] = "Unknown"; // Any length of bytes
- (*vr)["US"] = "Unsigned Short "; // Exactly 2 bytes
- (*vr)["UT"] = "Unlimited Text"; // At most 2^32 -1 chars
- dicom_vr = vr;
-}
-
// Fourth semantics:
// CMD Command
// META Meta Information
// CLEANME searching the dicom_vr at each occurence is expensive.
// PostPone this test in an optional integrity check at the end
// of parsing or only in debug mode.
- if ( RealExplicit && !dicom_vr->count(vr) )
+ if ( RealExplicit && !dicom_vr->Count(vr) )
RealExplicit= false;
if ( RealExplicit ) {
return;
}
ElVal->SetValue(NewValue);
+ free(NewValue);
}
/**
#include <map>
#include "gdcmCommon.h"
+#include "gdcmUtil.h"
#include "gdcmException.h"
#include "gdcmDictSet.h"
#include "gdcmElValue.h"
private:
/// Pointer to the Value Representation Hash Table which contains all
/// the VR of the DICOM version3 public dictionary.
- static VRHT *dicom_vr;
+ static gdcmVR *dicom_vr;
/// Global dictionary container
gdcmDictSet* Dicts;
guint32 FindLengthOB(void);
void Initialise(void);
void CheckSwap(void);
- void InitVRDict(void);
void SwitchSwapToBigEndian(void);
// CLEAN ME: NewManualElValToPubDict is NOT called any more.
gdcmElValue* NewManualElValToPubDict(string NewTagName, string VR);
#include <ctype.h> // For isspace
#include "gdcmUtil.h"
+// Library globals.
+gdcmDebug dbg;
+gdcmVR * gdcmGlobal::VR = new gdcmVR();
+
gdcmDebug::gdcmDebug(int level) {
DebugLevel = level;
}
#endif
}
-gdcmDebug dbg;
+///////////////////////////////////////////////////////////////////////////
+gdcmGlobal::gdcmGlobal(void) {
+}
+
+gdcmGlobal::~gdcmGlobal(void) {
+ delete VR;
+}
+
+gdcmVR * gdcmGlobal::GetVR(void) {
+ return VR;
+}
+///////////////////////////////////////////////////////////////////////////
// Because is not yet available in g++2.96
istream& eatwhite(istream& is) {
char c;
// gdcmUtil.h
+#ifndef GDCMUTIL_H
+#define GDCMUTIL_H
+
#include <iostream>
#include <vector>
#include <string>
+#include "gdcmVR.h"
using namespace std;
class gdcmDebug {
void Exit(int);
};
+class gdcmGlobal {
+private:
+ static gdcmVR *VR;
+public:
+ gdcmGlobal(void);
+ ~gdcmGlobal(void);
+ static gdcmVR * GetVR(void);
+};
+
istream & eatwhite(istream & is);
void Tokenize (const string& str,
const string& delimiters = " ");
extern gdcmDebug dbg;
+
+#endif
--- /dev/null
+// gdcmVR.cxx
+
+#include "gdcmVR.h"
+#include "gdcmUtil.h"
+
+gdcmVR::gdcmVR () {
+ // NOTE: making the affectation directely to dicom_vr instead of passing
+ // through an apparently unncessary local variable vr, crashes with
+ // gcc... Beware.
+ VRHT *vr = new VRHT;
+ (*vr)["AE"] = "Application Entity"; // At most 16 bytes
+ (*vr)["AS"] = "Age String"; // Exactly 4 bytes
+ (*vr)["AT"] = "Attribute Tag"; // 2 16-bit unsigned short integers
+ (*vr)["CS"] = "Code String"; // At most 16 bytes
+ (*vr)["DA"] = "Date"; // Exactly 8 bytes
+ (*vr)["DS"] = "Decimal String"; // At most 16 bytes
+ (*vr)["DT"] = "Date Time"; // At most 26 bytes
+ (*vr)["FL"] = "Floating Point Single"; // 32-bit IEEE 754:1985 float
+ (*vr)["FD"] = "Floating Point Double"; // 64-bit IEEE 754:1985 double
+ (*vr)["IS"] = "Integer String"; // At most 12 bytes
+ (*vr)["LO"] = "Long String"; // At most 64 chars
+ (*vr)["LT"] = "Long Text"; // At most 10240 chars
+ (*vr)["OB"] = "Other Byte String"; // String of bytes (vr independant)
+ (*vr)["OW"] = "Other Word String"; // String of 16-bit words (vr dep)
+ (*vr)["PN"] = "Person Name"; // At most 64 chars
+ (*vr)["SH"] = "Short String"; // At most 16 chars
+ (*vr)["SL"] = "Signed Long"; // Exactly 4 bytes
+ (*vr)["SQ"] = "Sequence of Items"; // Not Applicable
+ (*vr)["SS"] = "Signed Short"; // Exactly 2 bytes
+ (*vr)["ST"] = "Short Text"; // At most 1024 chars
+ (*vr)["TM"] = "Time"; // At most 16 bytes
+ (*vr)["UI"] = "Unique Identifier"; // At most 64 bytes
+ (*vr)["UL"] = "Unsigned Long "; // Exactly 4 bytes
+ (*vr)["UN"] = "Unknown"; // Any length of bytes
+ (*vr)["US"] = "Unsigned Short "; // Exactly 2 bytes
+ (*vr)["UT"] = "Unlimited Text"; // At most 2^32 -1 chars
+ dicom_vr = vr;
+}
+
+gdcmVR::~gdcmVR() {
+ dicom_vr->clear();
+ delete dicom_vr;
+}
+
+int gdcmVR::Count(VRKey key) {
+ return dicom_vr->count(key);
+}
--- /dev/null
+// gdcmVR.h
+
+#ifndef GDCMVR_H
+#define GDCMVR_H
+
+#include <map>
+#include <string>
+#include "gdcmCommon.h"
+
+typedef string VRKey;
+typedef string VRAtr;
+typedef map<VRKey, VRAtr> VRHT; // Value Representation Hash Table
+
+/*
+ * \defgroup gdcmVR
+ * \brief Container for dicom Value Representation Hash Table
+ * \note This is a singleton
+ */
+class GDCM_EXPORT gdcmVR {
+private:
+ VRHT *dicom_vr;
+public:
+ gdcmVR();
+ ~gdcmVR();
+ int Count(VRKey);
+};
+
+#endif