|
|
|
|
|
### How it works
|
|
|
|
|
|
It's possible to add as many consistency checks as you want in the ConfigLoader class.
|
|
|
|
|
|
A check is a function those signature is `bool check(boost::property_tree::ptree const&, std::ostream&)`, you can register it through ConfigLoader::addCheck.
|
|
|
|
|
|
When loading the configuration, all registered checks will be called upon the property_ptree. If one check returns `false`, the program will stop.
|
|
|
|
|
|
## example
|
|
|
|
|
|
```
|
|
|
bool
|
|
|
CheckReferentialRotation(pt::ptree const& pt, std::ostream& log) {
|
|
|
DiskReferentialType type = pt.get<DiskReferentialType>("Disk.Referential.Type");
|
|
|
bool pass = true;
|
|
|
switch (type) {
|
|
|
case DR_COROTATING:
|
|
|
if (pt.get_optional<real>("Disk.Referential.Omega")) {
|
|
|
log << "Fatal: Can't specify both " << type << " and Omega.\n";
|
|
|
pass = false;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
return pass;
|
|
|
}
|
|
|
|
|
|
// register in constructor to activate it by default.
|
|
|
ConfigLoader::ConfigLoader(std::ostream& log)
|
|
|
: myLog(log), myChecks() {
|
|
|
...
|
|
|
loader.addCheck(CheckReferentialRotation);
|
|
|
...
|
|
|
}
|
|
|
```
|
|
|
|
|
|
|
|
|
``` |