]> pilppa.org Git - libplp.git/blob - src/DataReader.hh
Data read optimizations
[libplp.git] / src / DataReader.hh
1 /*
2  * DataReader.hh
3  *
4  *  Created on: Nov 7, 2010
5  *      Author: lamikr
6  */
7
8 #ifndef DATAREADER_H_
9 #define DATAREADER_H_
10
11 #include <string>
12 #include <vector>
13
14 #include "Data.hh"
15 #include "Date.hh"
16 #include "DeviceConfig.hh"
17
18 #include <time.h>
19
20 namespace plp {
21         /**
22          * DataReader is able to read old data from the device.
23          */
24         class DataReader {
25                 public:
26                         DataReader(std::string device_id);
27                         virtual ~DataReader();
28                         DataRange *get_data_range();
29                         /**
30                          * Get monthly summary data.
31                          * Depending from the device type, it may be daily mean value, daily delta, highest value, etc...
32                          */
33                         DataRange *get_yearly_summary(Date *date, EnumSummaryCalculationType calc_type);
34                         DataRange *get_yearly_summary(Date *date);
35                         DataRange *get_yearly_summary(Date *start_date, Date *end_date);
36                         /**
37                          * Get monthly summary data.
38                          * Depending from the device type, it may be daily mean value, daily delta, highest value, etc...
39                          */
40                         DataRange *get_monthly_summary(Date *date, EnumSummaryCalculationType calc_type);
41                         DataRange *get_monthly_summary(Date *date);
42                         DataRange *get_monthly_summary(Date *start_date, Date *end_date);
43
44                         /**
45                          * Get daily summary data calculated from the daily data items.
46                          * Depending from the device type, it may be daily mean value, daily delta, highest value, etc...
47                          */
48                         /*
49                          * Get Daily summary from the latest date
50                          */
51                         DataRange *get_daily_summary();
52                         /*
53                          * Get Daily summary specified by the calc_type from the latest date.
54                          */
55                         DataRange *get_daily_summary(EnumSummaryCalculationType calc_type);
56                         DataRange *get_daily_summary(Date *date, EnumSummaryCalculationType calc_type);
57                         DataRange *get_daily_summary(Date *date);
58                         DataRange *get_daily_summary(Date *start_date, Date *end_date);
59
60                         DataRange *get_hourly_summary(Date *date, EnumSummaryCalculationType calc_type);
61                         DataRange *get_hourly_summary(Date *date);
62                         DataRange *get_hourly_summary(Date *start_date, Date *end_date);
63
64                         DataRange *get_data(Date *start_date, Date *end_date);
65                         std::string get_device_id();
66                         bool get_device_type(std::string& type_param);
67                         Data *get_latest_data();
68                 protected:
69                         std::string                     device_id;
70                         std::string                     device_dir;
71                         std::string                     device_ch_dir;
72                         DeviceConfig                    *device_config;
73                         EnumSummaryCalculationType      summary_calc_type;
74                         Data *find_oldest_data(std::vector<std::string> year_vector);
75                         Data *find_latest_data(std::vector<std::string> year_vector);
76                         DataRange *get_summary(Date *date_param,
77                                         EnumSummaryCalculationType calc_type_param,
78                                         EnumSummaryPeriod period_type_param);
79         };
80 }
81
82 #endif /* DATAREADER_H_ */