Boost logo

Boost Users :

From: Vladimir Prus (vladimir_at_[hidden])
Date: 2008-06-25 01:47:16


Marty Fried wrote:

> My app has a configuration file. We don't know where it will be for sure, so
> we are planning to make the location of the file a commandline option.
>
> So, after reading the commandline option, we will want to parse the config
> file.
>
> Is this a resaonable and legal thing to do? We will need to call the map's
> notify() function twice, if I interpret it correctly. I suppose I could try
> it, but I wanted to make sure I didn't use a feature that is not part of the
> design, and have it disabled on me in the future.

You don't need to call 'notify' twice -- first, parse the command line (including
calling 'store' put the option into variables_map). Obtain the value of the
necessary option from the variables map, and if necessary, parse the
config file, again, including 'store' like:

        store(parse_config_file(ifs, config_file_options), vm);

After that, call 'notify(vm)' -- once.

I don't think that anything will break *now*, if you call notify twice, but then,
the documentation say:

   /** Specifies a function to be called when the final value
            is determined. */
   typed_value* notifier(function1<void, const T&> f)

and reporting the *final* value twice seems weird.

HTH,
Volodya


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