4 * Created on: Aug 3, 2012
8 #include "../src/DeviceConfig.hh"
9 #include "../src/FileUtil.hh"
10 #include "../src/log.h"
15 #define DEVICE_NAME1 "device_1"
16 #define KEY_NAME1 "key1"
17 #define KEY_NAME2 "key2"
18 #define KEY_NAME3 "key3"
20 #define VALUE_NAME1 "val1"
21 #define VALUE_NAME2 "val2"
22 #define VALUE_NAME3 "val3"
25 DeviceConfig *dev_cfg;
31 DeviceConfig::set_base_dir_name("/tmp/test");
32 dev_cfg = new DeviceConfig(DEVICE_NAME1);
33 fname_full = dev_cfg->get_config_file_name();
34 fname_path = FileUtil::parse_directory_path(fname_full.c_str());
35 log_info("file-name: %s, path_name: %s\n",
36 fname_full.c_str(), fname_path.c_str());
37 dev_cfg->set_config_value(KEY_NAME1, VALUE_NAME1, false);
38 // check that read works even if values have not been saved yet
39 succ = dev_cfg->get_config_value(KEY_NAME1, val);
41 log_info("val1: %s\n", val.c_str());
44 log_error("failed to get value for key: %s\n", KEY_NAME1);
46 dev_cfg->set_config_value(KEY_NAME2, VALUE_NAME2, true);
47 succ = dev_cfg->get_config_value(KEY_NAME2, val);
49 log_info("val2: %s\n", val.c_str());
52 log_error("failed to get value for key: %s\n", KEY_NAME2);
54 succ = dev_cfg->get_config_value(KEY_NAME2, val);
56 log_info("val3: %s\n", val.c_str());
59 log_error("failed to get value for key: %s\n", KEY_NAME2);
61 dev_cfg->set_config_value(KEY_NAME3, VALUE_NAME3, false);
62 // check whether device_config destructor will do the final save
68 int main(int argc, char** argv) {