Skip to content
Snippets Groups Projects
Commit 6a8ab174 authored by Ger van Diepen's avatar Ger van Diepen
Browse files

bug 78:

Added function version
parent 3916c9db
No related branches found
No related tags found
No related merge requests found
...@@ -56,7 +56,7 @@ dnl ...@@ -56,7 +56,7 @@ dnl
lofar_GENERAL lofar_GENERAL
lofar_INTERNAL(LCS/ACC/APS,APS,,1,APS/ParameterSet.h) lofar_INTERNAL(LCS/ACC/APS,APS,,1,APS/ParameterSet.h)
lofar_INTERNAL(LCS/Common,Common,,1,Common/LofarTypedefs.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_EXTERNAL(pyrap,1,pyrap/Converters/PycBasicData.h)
lofar_AIPSPP(1,"-lcasa") lofar_AIPSPP(1,"-lcasa")
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
# $Id$ # $Id$
from _pyparameterset import ParameterValue from _pyparameterset import ParameterValue
from _pyparameterset import ParameterSet from _pyparameterset import PyParameterSet
class parametervalue(ParameterValue): class parametervalue(ParameterValue):
...@@ -35,18 +35,18 @@ class parametervalue(ParameterValue): ...@@ -35,18 +35,18 @@ class parametervalue(ParameterValue):
return self.get() return self.get()
class parameterset(ParameterSet): class parameterset(PyParameterSet):
""" """
The Python interface to ParameterSet The Python interface to ParameterSet
""" """
def __init__(self, filename=None, caseInsensitive=False): def __init__(self, filename=None, caseInsensitive=False):
if filename==None: if filename==None:
ParameterSet.__init__ (self, caseInsensitive); PyParameterSet.__init__ (self, caseInsensitive);
elif isinstance(filename, bool): elif isinstance(filename, bool):
ParameterSet.__init__ (self, filename); PyParameterSet.__init__ (self, filename);
else: else:
ParameterSet.__init__ (self, filename, caseInsensitive); PyParameterSet.__init__ (self, filename, caseInsensitive);
def __getitem__(self, key): def __getitem__(self, key):
return self.get (key) return self.get (key)
......
...@@ -29,11 +29,29 @@ ...@@ -29,11 +29,29 @@
#include <boost/python.hpp> #include <boost/python.hpp>
#include <boost/python/args.hpp> #include <boost/python/args.hpp>
#include "Package__Version.cc"
using namespace boost::python; using namespace boost::python;
using namespace casa::pyrap; using namespace casa::pyrap;
namespace LOFAR { namespace ACC { namespace APS { 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 // Define function pointers for overloaded functions to be able to tell
// boost-python which function to take. // boost-python which function to take.
void (ParameterSet::*fadd)(const string&, const string&) = void (ParameterSet::*fadd)(const string&, const string&) =
...@@ -115,10 +133,12 @@ namespace LOFAR { namespace ACC { namespace APS { ...@@ -115,10 +133,12 @@ namespace LOFAR { namespace ACC { namespace APS {
// Define the python interface to ParameterSet. // Define the python interface to ParameterSet.
void pyparameterset() void pyparameterset()
{ {
class_<ParameterSet> ("ParameterSet") class_<PyParameterSet> ("PyParameterSet")
.def (init<bool>()) .def (init<bool>())
.def (init<std::string, bool>()) .def (init<std::string, bool>())
.def ("version", &PyParameterSet::version,
(boost::python::arg("type")="other"))
.def ("size", &ParameterSet::size) .def ("size", &ParameterSet::size)
.def ("__len__", &ParameterSet::size) .def ("__len__", &ParameterSet::size)
.def ("makeSubset", &ParameterSet::makeSubset, .def ("makeSubset", &ParameterSet::makeSubset,
......
...@@ -60,6 +60,12 @@ print "" ...@@ -60,6 +60,12 @@ print ""
# Create and check a new parset using same keys/values as in parset file. # Create and check a new parset using same keys/values as in parset file.
ps=parameterset() 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", "7")
ps.add ("a.b.lange_naam", "dit is nu een andere naam geworden met extra spaties aan het einde ") 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") ps.add ("a.b.c", "5")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment