X-Git-Url: http://pilppa.org/gitweb/?p=libplp.git;a=blobdiff_plain;f=src%2FStoreDay.hh;h=dc2589519ab3f35c099c83fb6e86b6d8f727cc72;hp=1b416e5fbb78c9c4cd782a7bf5aa58d6c2eedb97;hb=fb1be129d4304d68e42f3e30710968a0899e5482;hpb=88183ebdd35a2bd340d949382f593466dfc887de diff --git a/src/StoreDay.hh b/src/StoreDay.hh index 1b416e5..dc25895 100644 --- a/src/StoreDay.hh +++ b/src/StoreDay.hh @@ -37,17 +37,63 @@ namespace plp { /* * Checks whether store file exist. */ - bool exist(); + bool exist(bool writable); + static bool exist(std::string dev_id, + plp::Date *date, + bool writable); + static bool exist_in_month(string device_id, + Date *date, + bool writable); + static bool exist_in_year(string device_id, + Date *date, + bool writable); + static bool get_next_date_with_data(std::string device_id, + plp::Date *next_date, + plp::Date *max_date); protected: std::string store_fname; bool load(); plp::DataRange *get_max_or_min(EnumSummaryPeriod period_type_param, bool max); static std::string get_dir_name(std::string device_id, plp::Date *date_time_param); + static std::string get_year_dir_name(std::string device_id, + plp::Date *date_time_param); static std::string get_file_name(std::string device_id, plp::Date *date_time_param); plp::DataRange *get_oldest_and_latest_data(std::string fname_param); - bool exist(std::string fname_param); + /** + * Check whether the given file exist and has either read or write permissions. + */ + static bool exist(std::string fname_param, bool writable); + /** + * Go through days in month to find out whether daily data file exist. + * + * If data is not found, false is returned and last scanned date is set to next_date. + * If data is found true is returned and date is set to next_date. + */ + static bool data_day_scan_days_in_month(string dev_id_param, + Date *next_date, + Date *max_date); + /** + * Go through month dir in year to find out first date with data + * after the given date. + * + * If data is not found, false is returned and last scanned date is set to next_date. + * If data is found true is returned and date is set to next_date. + */ + static bool data_day_scan_month_in_year(string dev_id_param, + Date *next_date, + Date *max_date); + /** + * Go through year and month directories to find out first date with data + * after the given date. + * + * If data is not found, false is returned and last scanned date is set to next_date. + * If data is found true is returned and date is set to next_date. + */ + static bool data_day_scan_years(string dev_id_param, + Date *next_date, + Date *max_date); }; }