From 6a8ab174ec6b9dd07e460dc3544c44e155150c12 Mon Sep 17 00:00:00 2001 From: Ger van Diepen <diepen@astron.nl> Date: Mon, 3 Nov 2008 09:14:13 +0000 Subject: [PATCH] bug 78: Added function version --- LCS/pyparameterset/configure.in | 2 +- LCS/pyparameterset/src/__init__.py | 10 +++++----- LCS/pyparameterset/src/pyparameterset.cc | 22 +++++++++++++++++++++- LCS/pyparameterset/test/tpyparameterset.py | 6 ++++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/LCS/pyparameterset/configure.in b/LCS/pyparameterset/configure.in index e4106ad331f..ccb2347f6e0 100644 --- a/LCS/pyparameterset/configure.in +++ b/LCS/pyparameterset/configure.in @@ -56,7 +56,7 @@ dnl lofar_GENERAL lofar_INTERNAL(LCS/ACC/APS,APS,,1,APS/ParameterSet.h) lofar_INTERNAL(LCS/Common,Common,,1,Common/LofarTypedefs.h) -lofar_INTERNAL(LCS/pytools,pytools,,1,pytools/Package__Version.h) +lofar_INTERNAL(LCS/pytools,pytools,,,,"") lofar_EXTERNAL(pyrap,1,pyrap/Converters/PycBasicData.h) lofar_AIPSPP(1,"-lcasa") diff --git a/LCS/pyparameterset/src/__init__.py b/LCS/pyparameterset/src/__init__.py index cf5cbd16d8a..2d46d56844a 100755 --- a/LCS/pyparameterset/src/__init__.py +++ b/LCS/pyparameterset/src/__init__.py @@ -20,7 +20,7 @@ # $Id$ from _pyparameterset import ParameterValue -from _pyparameterset import ParameterSet +from _pyparameterset import PyParameterSet class parametervalue(ParameterValue): @@ -35,18 +35,18 @@ class parametervalue(ParameterValue): return self.get() -class parameterset(ParameterSet): +class parameterset(PyParameterSet): """ The Python interface to ParameterSet """ def __init__(self, filename=None, caseInsensitive=False): if filename==None: - ParameterSet.__init__ (self, caseInsensitive); + PyParameterSet.__init__ (self, caseInsensitive); elif isinstance(filename, bool): - ParameterSet.__init__ (self, filename); + PyParameterSet.__init__ (self, filename); else: - ParameterSet.__init__ (self, filename, caseInsensitive); + PyParameterSet.__init__ (self, filename, caseInsensitive); def __getitem__(self, key): return self.get (key) diff --git a/LCS/pyparameterset/src/pyparameterset.cc b/LCS/pyparameterset/src/pyparameterset.cc index 569b11624b2..3f624521070 100644 --- a/LCS/pyparameterset/src/pyparameterset.cc +++ b/LCS/pyparameterset/src/pyparameterset.cc @@ -29,11 +29,29 @@ #include <boost/python.hpp> #include <boost/python/args.hpp> +#include "Package__Version.cc" + using namespace boost::python; using namespace casa::pyrap; namespace LOFAR { namespace ACC { namespace APS { + class PyParameterSet : public ParameterSet + { + public: + PyParameterSet() + : ParameterSet() + {} + PyParameterSet (bool caseInsensitive) + : ParameterSet (caseInsensitive) + {} + PyParameterSet (const string& fileName, bool caseInsensitive) + : ParameterSet (fileName, caseInsensitive) + {} + string version (const string& type) const + { return Version::getInfo<pyparametersetVersion> (type); } + }; + // Define function pointers for overloaded functions to be able to tell // boost-python which function to take. void (ParameterSet::*fadd)(const string&, const string&) = @@ -115,10 +133,12 @@ namespace LOFAR { namespace ACC { namespace APS { // Define the python interface to ParameterSet. void pyparameterset() { - class_<ParameterSet> ("ParameterSet") + class_<PyParameterSet> ("PyParameterSet") .def (init<bool>()) .def (init<std::string, bool>()) + .def ("version", &PyParameterSet::version, + (boost::python::arg("type")="other")) .def ("size", &ParameterSet::size) .def ("__len__", &ParameterSet::size) .def ("makeSubset", &ParameterSet::makeSubset, diff --git a/LCS/pyparameterset/test/tpyparameterset.py b/LCS/pyparameterset/test/tpyparameterset.py index f89cefb5460..3bc87771180 100644 --- a/LCS/pyparameterset/test/tpyparameterset.py +++ b/LCS/pyparameterset/test/tpyparameterset.py @@ -60,6 +60,12 @@ print "" # Create and check a new parset using same keys/values as in parset file. ps=parameterset() +print ">>>" +print ps.version("tree") +print ps.version("full") +print ps.version("top") +print ps.version() +print "<<<" ps.add ("a.b", "7") ps.add ("a.b.lange_naam", "dit is nu een andere naam geworden met extra spaties aan het einde ") ps.add ("a.b.c", "5") -- GitLab