1 /* sane - Scanner Access Now Easy.
2 
3    Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt>
4 
5    This file is part of the SANE package.
6 
7    This program is free software; you can redistribute it and/or
8    modify it under the terms of the GNU General Public License as
9    published by the Free Software Foundation; either version 2 of the
10    License, or (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef BACKEND_GENESYS_CALIBRATION_H
22 #define BACKEND_GENESYS_CALIBRATION_H
23 
24 #include "sensor.h"
25 #include "settings.h"
26 #include <ctime>
27 
28 namespace genesys {
29 
30 struct Genesys_Calibration_Cache
31 {
32     Genesys_Calibration_Cache() = default;
33     ~Genesys_Calibration_Cache() = default;
34 
35     // used to check if entry is compatible
36     SetupParams params;
37 
38     std::time_t last_calibration = 0;
39 
40     Genesys_Frontend frontend;
41     Genesys_Sensor sensor;
42 
43     ScanSession session;
44     size_t average_size = 0;
45     std::vector<std::uint16_t> white_average_data;
46     std::vector<std::uint16_t> dark_average_data;
47 
operator ==genesys::Genesys_Calibration_Cache48     bool operator==(const Genesys_Calibration_Cache& other) const
49     {
50         return params == other.params &&
51             last_calibration == other.last_calibration &&
52             frontend == other.frontend &&
53             sensor == other.sensor &&
54             session == other.session &&
55             average_size == other.average_size &&
56             white_average_data == other.white_average_data &&
57             dark_average_data == other.dark_average_data;
58     }
59 };
60 
61 template<class Stream>
serialize(Stream& str, Genesys_Calibration_Cache& x)62 void serialize(Stream& str, Genesys_Calibration_Cache& x)
63 {
64     serialize(str, x.params);
65     serialize_newline(str);
66     serialize(str, x.last_calibration);
67     serialize_newline(str);
68     serialize(str, x.frontend);
69     serialize_newline(str);
70     serialize(str, x.sensor);
71     serialize_newline(str);
72     serialize(str, x.session);
73     serialize(str, x.average_size);
74     serialize_newline(str);
75     serialize(str, x.white_average_data);
76     serialize_newline(str);
77     serialize(str, x.dark_average_data);
78 }
79 
80 } // namespace genesys
81 
82 #endif // BACKEND_GENESYS_CALIBRATION_H
83