tools:config
                Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tools:config [2017/12/14 08:00] – created 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: | ||
| </ | </ | ||
| + | The above example shows such a configuration class. When an object of this class is created, some of the values are initialized with default values and then added to the configuration. | ||
| + | <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.1513234812.txt.gz · Last modified: 2017/12/14 08:00 by graf
                
                