X-Git-Url: http://pilppa.org/gitweb/?a=blobdiff_plain;f=src%2FDeviceConfig.hh;h=52f2db87397452bc4b60f32819323034dcd8a703;hb=860d8c023b82eeca9833d4a3f534c6d11a9523f3;hp=90ff28d31edcd92441d441a8c8aace119f6e9ed4;hpb=063ec715601bf9662797725cb39732bea0572d26;p=libplp.git diff --git a/src/DeviceConfig.hh b/src/DeviceConfig.hh index 90ff28d..52f2db8 100644 --- a/src/DeviceConfig.hh +++ b/src/DeviceConfig.hh @@ -9,36 +9,36 @@ #define DEVICECONFIG_HH_ #include +#include "DataSummary.hh" extern "C" { #include - #include "config.h" + #include } -enum EnumSummaryPeriod{PERIOD_YEARLY, PERIOD_MONTHLY, PERIOD_DAILY, PERIOD_HOURLY, PERIOD_MINUTELY, PERIOD_SECONDLY}; -enum EnumSummaryCalculationType {SUM, DELTA, MIN, MAX, MEAN}; +#define DEVICE_CONFIG__FILE_NAME "device_cfg" +#define DEVICE_CONFIG__SECTION_TYPE "device" +#define DEVICE_CONFIG__SECTION_NAME "base_data" +#define DEVICE_CONFIG_VALUE_KEY__TYPE "type" +#define DEVICE_CONFIG_VALUE_KEY__ID "id" +#define DEVICE_CONFIG_VALUE_KEY__NAME "name" -const std::string SUMMARY_PERIOD_NAMES_ARRAY[] = {"yearly", "monthly", "daily", "minutely", "secondly"}; -const std::string CALCULATION_TYPE_NAMES_ARRAY[] = {"sum", "delta", "min", "max", "mean"}; - -#define DEVICE_CONFIG__FILE_NAME "dev_cfg.txt" -#define DEVICE_CONFIG__SECTION_TYPE "device" -#define DEVICE_CONFIG__SECTION_NAME "base_data" -#define DEVICE_CONFIG_VALUE_KEY__TYPE "type" -#define DEVICE_CONFIG_VALUE_KEY__ID "id" -#define DEVICE_CONFIG_VALUE_KEY__NAME "name" - -#define DEFAULT_STORAGE_BASE_DIR "/tmp/w1data" -#define DATAFILE_SUFFIX ".txt" -#define CACHE_DIR_NAME "cache" +#define DEFAULT_STORAGE_BASE_DIR "/tmp/w1data" +#define DATAFILE_SUFFIX ".txt" +#define CACHE_DIR_NAME "cache" namespace plp { struct ConfigHandle { public: - ConfigHandle(uci_context *ctx_param, uci_package *pkg_param); + ConfigHandle(uci_context *ctx_param, + uci_package *pkg_param, + const char *short_fname_param, + const char *full_fname_param); ~ConfigHandle(); struct uci_context *_ctx; struct uci_package *_pkg; + char *short_fname; + char *full_fname; }; class DeviceConfig { @@ -47,18 +47,25 @@ namespace plp { virtual ~DeviceConfig(); static std::string get_base_dir_name(); static void set_base_dir_name(std::string store_param); + static long get_read_interval_seconds(); + static void set_read_interval_seconds(long seconds_param); static DeviceConfig *get_device_config(std::string device_id); - std::string get_cfg_value(std::string key); - void set_cfg_value(std::string key, std::string value); + bool get_config_value(std::string key, std::string& value); + bool set_config_value(std::string key, + std::string value, + bool save_immediately); + std::string get_config_path_name(); + std::string get_config_file_name(); + std::string get_pathless_config_file_name(); EnumSummaryCalculationType get_summary_calculation_type(); private: static std::string store_base_dir; + static long read_interval_seconds; std::string device_id; std::string device_type; ConfigHandle *uci_handle; ConfigHandle *load_device_config(std::string device_id_param); - std::string get_dir_name(std::string device_id); - std::string get_file_name(std::string device_id_param); + }; }