8000 ConfigTree with some checks added by chleh · Pull Request #912 · ufz/ogs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ConfigTree with some checks added #912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 8, 2016
Merged

Conversation

chleh
Copy link
Collaborator
@chleh chleh commented Dec 12, 2015

This PR introduces a wrapper class for the Boost Property Tree. The purpose of the wrapper is:

  • to tell the user about settings that have not been read. The messages include some hints about where something went wrong.
  • to enforce (to some extent) that each setting is parsed exactly once
  • to make (by rather long method names) settings easily greppable from source code. I think this way it will be more easy later on to provide a comprehensive documentation of all possible OGS-6 input parameters.
  • to enforce a certain style of XML tag names [a-z0-9_].
  • to avoid or reduce the amount of input error handling code in OGS-6 routines.
  • to enforce that a particular parameter is always read with the same type.

Those points are basically implemented by keeping track of how many times a routine asks for a certain parameter. The destructor then will check that everything has been read.

Currently the changes in this PR are somewhat scattered. i will clean it up later on. I believe that everything we need can be done with the new class and that a transition is easy.

The main part (interface) of this PR is in BaseLib/ConfigTreeNew.h. It is used pretty much in the same way as the Boost property tree (cf. Tests/BaseLib/TestConfigTree.cpp). Please have a look if any feature is missing or if you disagree with my implementation.

A typical waring message will look like this:
ConfigTree: At path <OpenGeoSysProject/processes/process/linear_solver>: Key <eigen> has been read 1 time(s) less than it was present in the configuration tree.
(of cause this particular message will not occur.)

In this PR the options of ProcessVariables are parsed with the new ConfigTree. Once this PR is accepted I will make the transition to the new ConfigTree in all of OGS-6.

There is one design question to be discussed: Currently the new ConfigTree cannot be passed as const & but only as reference to a modifiable object. That can be changed if I make one member variable mutable. Should I do that?

@endJunction
Copy link
Member

Looks OK. I think that to truly find out if the design is good an exemplary change to any of the current config parsers would be helpful. Maybe you could choose one particularly ugly example :)

* is generated. The message contains a hint where it occured.
* * enforces a naming scheme of settings: letters a-z, numbers 0-9, underscore
* * provides some functionality to read lists of values using range-based for loops.
* * has rater lng method names that are easily greppable from the source code. So a list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lng -> long

@TomFischer
Copy link
Member

Good job, go on!

@chleh
Copy link
Collaborator Author
chleh commented Dec 21, 2015

Telling from this thread: http://stackoverflow.com/questions/10783391/is-it-possible-to-move-a-boostoptional
My new class needs boost >= 1.56, because of move-construction and move-assignment for boost::optional. Is it possible that we require at least boost 1.56? Otherwise I will either have to come up with a different way of describing optional values (unique pointers?), or I will have to drop this PR.

See also: http://www.boost.org/doc/libs/1_60_0/libs/optional/doc/html/boost_optional/relnotes.html

@TomFischer
Copy link
Member

I haven't any objections to require a higher boost version.

@chleh chleh added this to the Documentation & Benchmarks milestone Dec 22, 2015
@chleh chleh mentioned this pull request Jan 6, 2016
@bilke bilke mentioned this pull request Jan 6, 2016
@ogsbot
Copy link
Member
ogsbot commented Jan 6, 2016

Jenkins: OGS-6/Win-PRs failed: https://svn.ufz.de:8443/job/OGS-6/job/Win-PRs/891/

@endJunction
Copy link
Member

Jenkins test this please.

It was just the DenseMatrix test again...

@bilke
Copy link
Member
bilke commented Jan 7, 2016

Cool stuff! 👍

markVisited(root);
boost::optional<ConfigTreeNew> t;
t.emplace(*subtree, *this, root);
return std::move(t);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BaseLib/ConfigTreeNew.cpp:99:16: warning: moving a local object in a return statement prevents copy elision
clang's suggestion: note: remove std::move call here

@chleh could you explain why making t an rvalue is needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I can't, will remove it.

TomFischer added a commit that referenced this pull request Jan 8, 2016
ConfigTree with some checks added
@TomFischer TomFischer merged commit 7f4b49d into ufz:master Jan 8, 2016
ConfigTreeNew::
getConfParamOptional(std::string const& param)
{
checkUnique(param);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the other getters (getConfParam and its optional version) without this checkUnique?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other methods call this one, so additional checks are not necessary.

@endJunction
Copy link
Member

I'd recommend to have consistent tabs/whitespaces at least in a single file. (Or use clang-format)

@chleh
Copy link
Collaborator Author
chleh commented Jan 8, 2016

Since this PR has already been merged, I will fix the indentation in a subsequent PR.


if (subtree) {
markVisited(root);
return boost::optional<ConfigTreeNew>(std::move(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as for the other move: copy-elision with std::move is not possible. I think the return statement could be just

return ConfigTreeNew(*subtree, *this, root);

@chleh chleh mentioned this pull request Jan 14, 2016
@chleh chleh deleted the config-tree branch March 8, 2016 10:36
@ogsbot
Copy link
Member
ogsbot commented Jun 19, 2020

OpenGeoSys development has been moved to GitLab.

See this pull request on GitLab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0