From 056201f7ae914314059ccb136d35c674a0ad9e0b Mon Sep 17 00:00:00 2001 From: frog Date: Tue, 27 May 2003 15:16:13 +0000 Subject: [PATCH] * gdcmPython/gdcm.i: - typemaps correction to take into account the systematic replacement of "using namespace std" with std:: prefix e.g. std::list, std::string... (cf changes of 2003-05-21). - gdcmGlob global variable of type gdcmGlobal (defined in src/gdcmUtil.cxx and declared in gdcmPython/gdcm.i) is now exported to Python a as cvar. * gdcmPython/__init__.py now defines two functions GetPubDictTagNames() and GetPubDictTagNamesByCategory() as a replacement for deprecated gdcmDictSet.GetPubDictTagNames() and gdcmDictSet.GetPubDictTagNamesByCategory() class functions (i.e. C++ static methods). * gdcmPython/demo/printGroupedPublicDict.py is operational again, with the above changes. ---- Frog --- ChangeLog | 16 ++++++++++++++++ gdcmPython/__init__.py | 6 ++++++ gdcmPython/demo/printGroupedPublicDict.py | 4 ++-- gdcmPython/gdcm.i | 15 ++++++++++----- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33eb0877..1f4c8132 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2003-05-27 Eric Boix + * gdcmPython/gdcm.i: + - typemaps correction to take into account the systematic replacement + of "using namespace std" with std:: prefix e.g. std::list, + std::string... (cf changes of 2003-05-21). + - gdcmGlob global variable of type gdcmGlobal (defined in + src/gdcmUtil.cxx and declared in gdcmPython/gdcm.i) is now + exported to Python a as cvar. + * gdcmPython/__init__.py now defines two functions GetPubDictTagNames() + and GetPubDictTagNamesByCategory() as a replacement for deprecated + gdcmDictSet.GetPubDictTagNames() and + gdcmDictSet.GetPubDictTagNamesByCategory() class functions (i.e. + C++ static methods). + * gdcmPython/demo/printGroupedPublicDict.py is operational again, + with the above changes. + 2003-05-22 Benoit Regrain * setup.py, manifest.in : bug fix under linux diff --git a/gdcmPython/__init__.py b/gdcmPython/__init__.py index e1b32c2a..a4c36f33 100644 --- a/gdcmPython/__init__.py +++ b/gdcmPython/__init__.py @@ -57,3 +57,9 @@ except ImportError,e: gdcmHeader = gdcm.gdcmHeader gdcmDictSet = gdcm.gdcmDictSet gdcmFile = gdcm.gdcmFile + +def GetPubDictTagNames(): + return gdcm.cvar.gdcmGlob.GetDicts().GetPubDictTagNames() + +def GetPubDictTagNamesByCategory(): + return gdcm.cvar.gdcmGlob.GetDicts().GetPubDictTagNamesByCategory() diff --git a/gdcmPython/demo/printGroupedPublicDict.py b/gdcmPython/demo/printGroupedPublicDict.py index 153e173b..7a5aca6d 100644 --- a/gdcmPython/demo/printGroupedPublicDict.py +++ b/gdcmPython/demo/printGroupedPublicDict.py @@ -4,7 +4,7 @@ print "##############################################################" print "### Display all the possible tags of the current public" print "### dictionary" print "##############################################################" -PubList = gdcmDictSet.GetPubDictTagNames() +PubList = GetPubDictTagNames() for i in range(0, len(PubList)): print " ", PubList[i] @@ -12,7 +12,7 @@ print "##############################################################" print "### Display all the possible tags of the current public" print "### dictionary, but grouped by using the Fourth field" print "##############################################################" -PubDict = gdcmDictSet.GetPubDictTagNamesByCategory() +PubDict = GetPubDictTagNamesByCategory() for fourth in PubDict: print " ############ Fourth group = ", fourth, " ##############" for key in PubDict[fourth]: diff --git a/gdcmPython/gdcm.i b/gdcmPython/gdcm.i index 15c6ff38..69e8a82f 100644 --- a/gdcmPython/gdcm.i +++ b/gdcmPython/gdcm.i @@ -6,12 +6,11 @@ #include "gdcmDictSet.h" #include "gdcmElValue.h" #include "gdcmElValSet.h" +#include "gdcmUtil.h" #include "gdcmHeader.h" #include "gdcmFile.h" using namespace std; -using namespace std; - // Utility functions on strings for removing leading and trailing spaces void EatLeadingAndTrailingSpaces(string & s) { while ( s.length() && (s[0] == ' ') ) @@ -24,7 +23,13 @@ typedef unsigned short guint16; typedef unsigned int guint32; //////////////////////////////////////////////////////////////////////////// -%typemap(out) list * { +// Global variables get exported to cvar in Python +%immutable; +extern gdcmGlobal gdcmGlob; +%mutable; + +//////////////////////////////////////////////////////////////////////////// +%typemap(out) std::list * { PyObject* NewItem = (PyObject*)0; PyObject* NewList = PyList_New(0); // The result of this typemap for (list::iterator NewString = ($1)->begin(); @@ -37,7 +42,7 @@ typedef unsigned int guint32; //////////////////////////////////////////////////////////////////////////// // Convert a c++ hash table in a python native dictionary -%typemap(out) map > * { +%typemap(out) std::map > * { PyObject* NewDict = PyDict_New(); // The result of this typemap PyObject* NewKey = (PyObject*)0; PyObject* NewVal = (PyObject*)0; @@ -98,7 +103,6 @@ typedef unsigned int guint32; %typemap(out) std::string { $result = PyString_FromString(($1).c_str()); } -//////%apply int { std::int }; //////////////////////////////////////////////////////////////////////////// %include "gdcmCommon.h" @@ -107,6 +111,7 @@ typedef unsigned int guint32; %include "gdcmDictSet.h" %include "gdcmElValue.h" %include "gdcmElValSet.h" +%include "gdcmUtil.h" %include "gdcmHeader.h" %include "gdcmFile.h" -- 2.48.1