[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Resetting hard-coded defaults before loading 'configurable_set
From: |
Evgeniy Tarassov |
Subject: |
Re: [lmi] Resetting hard-coded defaults before loading 'configurable_settings.xml' |
Date: |
Tue, 14 Nov 2006 15:57:10 +0100 |
On 11/10/06, Greg Chicares <address@hidden> wrote:
Evgeniy--In 'gnome-xml-branch',
configurable_settings::load_from_file() has a section that
begins with this comment:
// first of all reset all members to default values
I understand what it does, but would like to understand why.
What problem would occur if we didn't do this?
Oh, i should have added a comment to
configurable_settings::load_from_file method.
IMO when we load settings from the xml file we should not care about
which particular values are specified and which are not. If a value is
absent in the xml file we should (IMHO) treat it as if the value was
present and equal to its default value. Therefore (for me) when code
reads values from the xml file (via load_from_file method) we should
ensure that it sticks to the logic mentioned above.
Currently this method (load_from_file) is called from the constructor
only, but i think we should be able to call it from any other place
too, thats why it has to reset to defaults. Otherwise the following
will not stand:
configurable_settings cs(true); // load values from the file
cs.set_XXX_value("YYY");
...
cs.load_from_file(); // discard changes and reload values
std::cout << "XXX=" << cs.get_XXX_value(); // output the value
If the value XXX is absent in the xml file, then we would expect the
default value for XXX to be printed out. But if we do not reset to
defaults when loading, then "YYY" will be printed out.