parameter lists in C++

  • Follow


Hi all,

I was wondering if there's an existing library out there that supports
something along the lines of Java's ParameterList concept (look for it
in the list of classes at
http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/index.html).
  The goal is as follows:

1. Have a class define inside of it parameters it needs, default
values, ranges, and validation.  These parameters may be of different
types.
2. When a person instantiates an object of this class, inquire about
its list of needed parameters, and fill them where appropriate.

Thanks!

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply finlaysonc 12/11/2003 12:06:45 PM

Hi,

> 1. Have a class define inside of it parameters it needs, default
> values, ranges, and validation.  These parameters may be of different
> types.

take a look at std::map for a container type which may fit Your needs and
take a look at boost::any at www.boot.org for a generic, yet type safe
wrapper.

> 2. When a person instantiates an object of this class, inquire about
> its list of needed parameters, and fill them where appropriate.

You mean at runtime, well this requires a sort of reflextion (in
java-speak),
which is not directly supported by c++. but you can as a class always return
a list of parameters required, this again would make the class user rather
complicated.

bye
vl



      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply v 12/12/2003 7:02:26 PM


"v" <_qquench_at_compuserve_dot_de_@news.arcor-ip.de> writes:

> Hi,
>
>> 1. Have a class define inside of it parameters it needs, default
>> values, ranges, and validation.  These parameters may be of different
>> types.
>
> take a look at std::map for a container type which may fit Your needs and
> take a look at boost::any at www.boot.org for a generic, yet type safe
> wrapper.

In the sandbox we have some code and tests for Python-style named
parameter lists:

  f(33, acceleration = 9.8, name = "jumper")

source: http://tinyurl.com/yzj0
test:   http://tinyurl.com/yzix

No docs yet, sorry.  I hope you can understand it by looking at the
test code.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
0
Reply David 12/13/2003 2:27:47 AM

2 Replies
96 Views

(page loaded in 0.058 seconds)

Similiar Articles:













7/23/2012 11:34:47 AM


Reply: