dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #13411
Re: [HG DOLFIN] Add initial version of new?parameter?system. See test in sandbox/misc.
On Sat, May 09, 2009 at 11:36:23AM +0200, Johan Hake wrote:
> On Saturday 09 May 2009 00:50:37 Anders Logg wrote:
> > On Fri, May 08, 2009 at 03:01:18PM +0200, Johan Hake wrote:
> > > On Friday 08 May 2009 14:57:11 Anders Logg wrote:
> > > > On Fri, May 08, 2009 at 02:49:01PM +0200, Johan Hake wrote:
> > > > > On Friday 08 May 2009 14:11:32 DOLFIN wrote:
> > > > > > One or more new changesets pushed to the primary dolfin repository.
> > > > > > A short summary of the last three changesets is included below.
> > > > > >
> > > > > > changeset: 6101:f22b49031d081323d6c6ce18eccbb12c80240b22
> > > > > > tag: tip
> > > > > > user: Anders Logg <logg@xxxxxxxxx>
> > > > > > date: Fri May 08 14:11:28 2009 +0200
> > > > > > files: ChangeLog dolfin/parameter/NewParameter.cpp
> > > > > > dolfin/parameter/NewParameter.h dolfin/parameter/Parameters.cpp
> > > > > > dolfin/parameter/Parameters.h dolfin/parameter/dolfin_parameter.h
> > > > > > sandbox/misc/cpp/main.cpp description:
> > > > > > Add initial version of new parameter system. See test in
> > > > > > sandbox/misc.
> > > > > >
> > > > > > Implementation similar to before, but much simplified as a result
> > > > > > of removing the ParameterValue class and subclassing (New)Parameter
> > > > > > directly.
> > > > > >
> > > > > > Implementation consists of two classes: Parameters and
> > > > > > (New)Parameter. Only supports int and double so far. Range checks
> > > > > > implemented.
> > > > > >
> > > > > > Check if this looks ok. Will continue to add more features.
> > > > >
> > > > > Looks nice. The info was a bit verbose for me, but that's details.
> > > >
> > > > I'm working on an ever more verbose version now, but it's prettier and
> > > > looks more like what you suggested to me a few days back.
> > >
> > > Ok!
> > >
> > > > > Will it be possible to
> > > > >
> > > > > my_params.add("another params",my_other_params);
> > > > >
> > > > > where my_other_params is a Parameters?
> > > >
> > > > Yes, that should be possible to fix. And I guess you mean those should
> > > > then be nested? So after the above line, one may do
> > > >
> > > > my_params["another params"]["foo"] = 1.0;
> > >
> > > Exactly!
> >
> > I've implemented this, but I had to change the last [] to ().
>
> Looks nice!
Does this look like it will wrap nicely to Python?
Which features are missing now? I know of two things at least:
1. Adding value types bool and string
2. Command-line options (using po)
> > Having [] both for nested databases and parameters works fine in
> > Python but doing it in C++ would mess up the inheritance completely.
> > I think it's doable but it would complicate the implementation.
>
> Is it possible to let NewParameter define a minimal interface, maybe just keep
> the name of the parameter/parameterlist, then let Parameters and a new class
> ValueParameter inherit the NewParameter?
I don't think it's possible. The problem is that the thing operator[]
returns must be something that supports the *full* interface of *both*
Parameters and NewParameter. Otherwise it will not be possible to do
// Requires returned object to work as a parameter database
parameters["nested parameters"].add("tolerance", 0.01);
// Requires returned object to work as a parameter
parameters["num iterations"] = 1000;
One would then need a dynamic cast on the user side which is not that
nice. It would be possible to solve this by exposing the full
interface and returning errors when the wrong functions are called but
it will make the implementation much less transparent.
--
Anders
Attachment:
signature.asc
Description: Digital signature
Follow ups
References