]> pilppa.org Git - lib1wire.git/blob - src/DeviceConfig.hh
Use pointers in date comparison functions.
[lib1wire.git] / src / DeviceConfig.hh
1 /*
2  * DeviceConfig.hh
3  *
4  *  Created on: Dec 9, 2010
5  *      Author: lamikr
6  */
7
8 #ifndef DEVICECONFIG_HH_
9 #define DEVICECONFIG_HH_
10
11 #include <string>
12
13 extern "C" {
14 #include <uci.h>
15 #include <plp/config.h>
16 }
17
18 #define DEVICE_CONFIG__FILE_NAME                "dev_cfg.txt"
19 #define DEVICE_CONFIG__SECTION_TYPE             "device"
20 #define DEVICE_CONFIG__SECTION_NAME             "base_data"
21 #define DEVICE_CONFIG_VALUE_KEY__TYPE           "type"
22 #define DEVICE_CONFIG_VALUE_KEY__ID             "id"
23 #define DEVICE_CONFIG_VALUE_KEY__NAME           "name"
24
25 namespace w1 {
26         enum enum_summary_calculation {SUM, DELTA, MIN, MAX, MEAN};
27
28         struct ConfigHandle {
29                 public:
30                         ConfigHandle(uci_context *ctx_param, uci_package *pkg_param);
31                         ~ConfigHandle();
32                         struct uci_context      *ctx;
33                         struct uci_package      *pkg;
34         };
35
36         class DeviceConfig {
37                 public:
38                         DeviceConfig(std::string device_id_param);
39                         virtual ~DeviceConfig();
40                         static std::string get_base_dir_name();
41                         static void set_base_dir_name(std::string store_param);
42                         std::string get_cfg_value(std::string key);
43                         void set_cfg_value(std::string key, std::string value);
44                         enum_summary_calculation get_summary_calculation_type();
45                 private:
46                         static std::string      store_base_dir;
47                         std::string             device_id;
48                         std::string             device_type;
49                         ConfigHandle            *uci_handle;
50                         ConfigHandle *load_device_config(std::string device_id_param);
51                         std::string get_dir_name(std::string device_id);
52                         std::string get_file_name(std::string device_id_param);
53         };
54 }
55
56 #endif /* DEVICECONFIG_HH_ */