tools:config
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tools:config [2017/12/14 08:01] – graf | tools:config [2020/12/03 12:01] (current) – ursgraf | ||
---|---|---|---|
Line 4: | Line 4: | ||
TestConfig : public eeros:: | TestConfig : public eeros:: | ||
public: | public: | ||
- | TestConfig(const char *name) : | + | TestConfig(const char *name) : FileConfig(name), |
- | | + | |
- | // set default values | + | |
- | a(1), | + | |
- | | + | |
- | c{0.1, 0.2, 0.3}, | + | |
- | | + | |
add(" | add(" | ||
add(" | add(" | ||
- | add("init values", c); | + | add("initValues", c); |
add(" | add(" | ||
} | } | ||
Line 23: | Line 17: | ||
</ | </ | ||
- | When such a configuration class object is created, | + | The above example shows such a configuration class. When an object |
+ | <code cpp> | ||
+ | TestConfig configFile(" | ||
+ | </ | ||
+ | |||
+ | If a configuration file exists at the given location, you can load the values from there and overwrite the default values with the values given in the file. | ||
+ | <code cpp> | ||
+ | TestConfig configFile(" | ||
+ | configFile.load(); | ||
+ | </ | ||
+ | |||
+ | WARNING Valid name for the identifiers of the values must not include spaces. ' | ||
+ | You can manually create a suitable configuration file at the given location, e.g. | ||
+ | < | ||
+ | id = 1 | ||
+ | offset = 2.200000 | ||
+ | initValues = 0.1, 0.4, 0.3 | ||
+ | ip = 127.0.0.0 | ||
+ | </ | ||
+ | or you could save the values of your configuration class object into the file (and possible change an existing content). | ||
+ | <code cpp> | ||
+ | configFile.save(); | ||
+ | </ | ||
+ | It's also possible to save to or restore from another file by writing: | ||
+ | <code cpp> | ||
+ | configFile.save(" | ||
+ | configFile.load(" | ||
+ | </ | ||
+ | |||
+ | There is a complete example in the example directory of EEROS. Open a shell in the build directory of your EEROS library and run | ||
+ | < | ||
+ | $ ./ | ||
+ | </ |
tools/config.1513234918.txt.gz · Last modified: 2017/12/14 08:01 by graf