EEROS  1.0.0.0
API for the EEROS Real-Time Robotics Framework
MyConfig.hpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <eeros/core/SimpleConfig.hpp>
5 
6 using namespace eeros;
7 
8 class MyConfig : public SimpleConfig {
9 public:
10  MyConfig(const char *name) : SimpleConfig(name) {
11  add("value1", value1);
12  add("value2", value2);
13  }
14 
15  int value1;
16  double value2;
17 };
18 
19 
20 int main(int argc, char **argv) {
21  std::cout << "Config demo started!" << std::endl;
22  std::string fileName("config.txt"); // choose an appropriate path
23  MyConfig configFile(fileName.c_str());
24  configFile.load();
25  std::cout << "Config read from file: value1 = " << configFile.value1 << std::endl;
26  std::cout << "Config read from file: value2 = " << configFile.value2 << std::endl;
27  configFile.value1 += 100;
28  configFile.value2 += 3.5;
29  configFile.save();
30 
31  return 0;
32 }
Definition: MyConfig.hpp:8
Definition: Config.hpp:14
double value2
Definition: MyConfig.hpp:16
int value1
Definition: MyConfig.hpp:15
void endl(LogWriter &w)
Definition: RecordWriter.hpp:19
int main(int argc, char **argv)
Definition: MyConfig.hpp:20
MyConfig(const char *name)
Definition: MyConfig.hpp:10