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 #define DEBUG_DECLARE_ONLY
22
23 #include "settings.h"
24 #include "utilities.h"
25 #include <iomanip>
26
27 namespace genesys {
28
operator <<(std::ostream& out, const Genesys_Settings& settings)29 std::ostream& operator<<(std::ostream& out, const Genesys_Settings& settings)
30 {
31 StreamStateSaver state_saver{out};
32
33 out << "Genesys_Settings{\n"
34 << " xres: " << settings.xres << " yres: " << settings.yres << '\n'
35 << " lines: " << settings.lines << '\n'
36 << " pixels per line (actual): " << settings.pixels << '\n'
37 << " pixels per line (requested): " << settings.requested_pixels << '\n'
38 << " depth: " << settings.depth << '\n';
39 auto prec = out.precision();
40 out.precision(3);
41 out << " tl_x: " << settings.tl_x << " tl_y: " << settings.tl_y << '\n';
42 out.precision(prec);
43 out << " scan_mode: " << settings.scan_mode << '\n'
44 << '}';
45 return out;
46 }
47
operator <<(std::ostream& out, const SetupParams& params)48 std::ostream& operator<<(std::ostream& out, const SetupParams& params)
49 {
50 StreamStateSaver state_saver{out};
51
52 bool reverse = has_flag(params.flags, ScanFlag::REVERSE);
53
54 out << "SetupParams{\n"
55 << " xres: " << params.xres
56 << " startx: " << params.startx
57 << " pixels per line (actual): " << params.pixels
58 << " pixels per line (requested): " << params.requested_pixels << '\n'
59
60 << " yres: " << params.yres
61 << " lines: " << params.lines
62 << " starty: " << params.starty << (reverse ? " (reverse)" : "") << '\n'
63
64 << " depth: " << params.depth << '\n'
65 << " channels: " << params.channels << '\n'
66 << " scan_mode: " << params.scan_mode << '\n'
67 << " color_filter: " << params.color_filter << '\n'
68 << " contrast_adjustment: " << params.contrast_adjustment << '\n'
69 << " brightness_adjustment: " << params.brightness_adjustment << '\n'
70 << " flags: " << params.flags << '\n'
71 << "}";
72 return out;
73 }
74
operator ==(const ScanSession& other) const75 bool ScanSession::operator==(const ScanSession& other) const
76 {
77 return params == other.params &&
78 computed == other.computed &&
79 full_resolution == other.full_resolution &&
80 optical_resolution == other.optical_resolution &&
81 optical_pixels == other.optical_pixels &&
82 optical_pixels_raw == other.optical_pixels_raw &&
83 optical_line_count == other.optical_line_count &&
84 output_resolution == other.output_resolution &&
85 output_startx == other.output_startx &&
86 output_pixels == other.output_pixels &&
87 output_channel_bytes == other.output_channel_bytes &&
88 output_line_bytes == other.output_line_bytes &&
89 output_line_bytes_raw == other.output_line_bytes_raw &&
90 output_line_bytes_requested == other.output_line_bytes_requested &&
91 output_line_count == other.output_line_count &&
92 output_total_bytes_raw == other.output_total_bytes_raw &&
93 output_total_bytes == other.output_total_bytes &&
94 num_staggered_lines == other.num_staggered_lines &&
95 max_color_shift_lines == other.max_color_shift_lines &&
96 color_shift_lines_r == other.color_shift_lines_r &&
97 color_shift_lines_g == other.color_shift_lines_g &&
98 color_shift_lines_b == other.color_shift_lines_b &&
99 stagger_x == other.stagger_x &&
100 stagger_y == other.stagger_y &&
101 segment_count == other.segment_count &&
102 pixel_startx == other.pixel_startx &&
103 pixel_endx == other.pixel_endx &&
104 pixel_count_ratio == other.pixel_count_ratio &&
105 conseq_pixel_dist == other.conseq_pixel_dist &&
106 output_segment_pixel_group_count == other.output_segment_pixel_group_count &&
107 output_segment_start_offset == other.output_segment_start_offset &&
108 shading_pixel_offset == other.shading_pixel_offset &&
109 buffer_size_read == other.buffer_size_read &&
110 enable_ledadd == other.enable_ledadd &&
111 use_host_side_calib == other.use_host_side_calib &&
112 use_host_side_gray == other.use_host_side_gray;
113 }
114
operator <<(std::ostream& out, const ScanSession& session)115 std::ostream& operator<<(std::ostream& out, const ScanSession& session)
116 {
117 out << "ScanSession{\n"
118 << " computed: " << session.computed << '\n'
119 << " full_resolution: " << session.full_resolution << '\n'
120 << " optical_resolution: " << session.optical_resolution << '\n'
121 << " optical_pixels: " << session.optical_pixels << '\n'
122 << " optical_pixels_raw: " << session.optical_pixels_raw << '\n'
123 << " optical_line_count: " << session.optical_line_count << '\n'
124 << " output_resolution: " << session.output_resolution << '\n'
125 << " output_startx: " << session.output_startx << '\n'
126 << " output_pixels: " << session.output_pixels << '\n'
127 << " output_line_bytes: " << session.output_line_bytes << '\n'
128 << " output_line_bytes_raw: " << session.output_line_bytes_raw << '\n'
129 << " output_line_count: " << session.output_line_count << '\n'
130 << " num_staggered_lines: " << session.num_staggered_lines << '\n'
131 << " color_shift_lines_r: " << session.color_shift_lines_r << '\n'
132 << " color_shift_lines_g: " << session.color_shift_lines_g << '\n'
133 << " color_shift_lines_b: " << session.color_shift_lines_b << '\n'
134 << " max_color_shift_lines: " << session.max_color_shift_lines << '\n'
135 << " enable_ledadd: " << session.enable_ledadd << '\n'
136 << " stagger_x: " << session.stagger_x << '\n'
137 << " stagger_y: " << session.stagger_y << '\n'
138 << " segment_count: " << session.segment_count << '\n'
139 << " pixel_startx: " << session.pixel_startx << '\n'
140 << " pixel_endx: " << session.pixel_endx << '\n'
141 << " pixel_count_ratio: " << session.pixel_count_ratio << '\n'
142 << " conseq_pixel_dist: " << session.conseq_pixel_dist << '\n'
143 << " output_segment_pixel_group_count: "
144 << session.output_segment_pixel_group_count << '\n'
145 << " shading_pixel_offset: " << session.shading_pixel_offset << '\n'
146 << " buffer_size_read: " << session.buffer_size_read << '\n'
147 << " enable_ledadd: " << session.enable_ledadd << '\n'
148 << " use_host_side_calib: " << session.use_host_side_calib << '\n'
149 << " use_host_side_gray: " << session.use_host_side_gray << '\n'
150 << " params: " << format_indent_braced_list(4, session.params) << '\n'
151 << "}";
152 return out;
153 }
154
operator <<(std::ostream& out, const SANE_Parameters& params)155 std::ostream& operator<<(std::ostream& out, const SANE_Parameters& params)
156 {
157 out << "SANE_Parameters{\n"
158 << " format: " << static_cast<unsigned>(params.format) << '\n'
159 << " last_frame: " << params.last_frame << '\n'
160 << " bytes_per_line: " << params.bytes_per_line << '\n'
161 << " pixels_per_line: " << params.pixels_per_line << '\n'
162 << " lines: " << params.lines << '\n'
163 << " depth: " << params.depth << '\n'
164 << '}';
165 return out;
166 }
167
168 } // namespace genesys
169