]> pilppa.org Git - lib1wire.git/blob - src/Data.hh
Started adding support for caches when reading data. Cache files for
[lib1wire.git] / src / Data.hh
1 /*
2  * Data.hh
3  *
4  *  Created on: Dec 8, 2010
5  *      Author: lamikr
6  */
7
8 #ifndef DATA_HH_
9 #define DATA_HH_
10
11 #include <string>
12 #include <valarray>
13 #include <vector>
14
15 #include "Date.hh"
16
17 namespace plp {
18         class Data {
19                 public:
20                         Data(int size);
21                         Data(int size, double default_value, std::string unit_param);
22                         Data(std::vector<double> *val_vector_param);
23                         Data(std::vector<double> *val_vector_param, std::string unit_param);
24                         Data(std::vector<double> *val_vector_param, plp::Date *date_param, std::string unit_param);
25                         Data(std::valarray<double> *val_arr_param, plp::Date *date_param);
26                         virtual ~Data();
27                         Data *clone();
28                         void printout();
29                         std::string to_string(int dec_precision);
30                         std::string to_string();
31                         static Data *parse_string(const std::string& data_str);
32                         plp::Date get_date();
33                         void set_date(plp::Date *date_param);
34                         std::string get_unit();
35                         std::valarray<double>   value_arr;
36                 private:
37                         plp::Date               date_time;
38                         std::string             unit;
39         };
40
41         class DataRange {
42                 public:
43                         DataRange();
44                         DataRange(Data *data);
45                         DataRange(DataRange *datarange);
46                         DataRange(int item_count_per_value, std::string unit_param);
47                         virtual ~DataRange();
48                         void add(Data *data);
49                         void add(DataRange *datarange);
50                         Data *get(int row_index);
51                         Data *get_first();
52                         Data *get_last();
53                         int get_count();
54                         int get_data_item_value_count();
55                         std::string get_unit();
56                         void printout();
57                 protected:
58                         double                          *val_matrix;
59                         std::vector<plp::Date *>        date_list;
60                         int                             row_count;
61                         int                             column_count;
62                         std::string                     unit;
63         };
64 }
65
66 #endif /* DATA_HH_ */