Boost logo

Boost Users :

From: Paul Baxter (pauljbaxter_at_[hidden])
Date: 2005-12-08 17:34:52


> "Paul Baxter" <pauljbaxter_at_[hidden]> writes:
>
>> I have a fixed list of parameter names and with each an associated
>> set of attributes. I wish to access the attributes via the parameter
>> name rather than the equivalent list entry index.
>>
>> In the past, we've created ENUMs with meaningful names to represent
>> the parameter name->index mapping but I can't help feeling there
>> must be a better way usng the name directly without this extra
>> artificial mapping type.
>
>
> Is there some reason http://www.boost.org/libs/parameter is not
> appropriate for you?

The parameter library looks like an incredibly useful library, I'm not sure
it is what I'm looking for though, but am happy if you could give me an
example. I'm looking for something that does the name->index 'lookup' at
compile time. (Sorry if this fact wasn't made clearer). My initial reading
of parameter is that it is solving a different problem.

Each of my configurable classes defines a fixed list of parameter names and
associated attributes known at compile time. Rather than accessing via
parameter 'list position' 1, I'd like to access attributes of each parameter
(such as parameter type, default value, min/max values) via the parameter's
name, mainly from a readability and maintainability point of view. If I ever
change the list to add/delete a parameter, the parameter 'access' code would
require a recompile but pick up its new index automatically.

I can't help feeling this should be easy to do and its frustrating that I
can't find a way to achieve this other than the aforementioned enum.

My application is a real-time high-speed one with hundreds (sometimes
thousands) of configuration parameters. I need to interrogate these in a
very short space of time which doesn't allow run-time assessment of strings
for matching them.

Since all are known at compile time I'm sure it must be easy to do this. I'm
pretty sure when someone shows me the obvious solution I will be very
embarrassed, but until then I can do this with a std::map at runtime, but
not at compile time.

Many thanks if anyone can help further.

Paul


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net