-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.h
61 lines (42 loc) · 1.5 KB
/
data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
================================================================================
DREAM core / Data module
--------------------------------------------------------------------------------
A module of the Data class that can store and process a set of Value objects.
--------------------------------------------------------------------------------
Copyright © 2019-2022 Dmytro Obukhov (DeLy Dreamer)
License: https://www.gnu.org/licenses/gpl-3.0.html
================================================================================
*/
#pragma once
#include <Arduino.h>
#include <vector>
#include "value.h"
#include "null_defines.h"
namespace dream
{
class Data
{
public:
// VALUES
std::vector<Value> values;
Data() {}
// Add one value to values list
void addValue(Value value);
// Add list of values to values list
void addValues(std::vector<Value> values);
// Erase values from array
void eraseValues();
// Find first value that match the template
Value* find(String type, String unit = NULL_STR, String sensor = NULL_STR);
// Check if values array contains specific value
bool contains(String type, String unit = NULL_STR, String sensor = NULL_STR) const;
// Print list of values to string
String toString() const;
// Calculate AVG values from array of Data
static Data calculateAvg(std::vector<Data> data_arr);
private:
// Find first value that match the template and return index
int indexOf(String type, String unit = NULL_STR, String sensor = NULL_STR);
};
}