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
Branches
Tags
No related merge requests found
......@@ -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")
......
......@@ -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)
......
......@@ -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,
......
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment