1141cc406Sopenharmony_ci/* sane - Scanner Access Now Easy. 2141cc406Sopenharmony_ci 3141cc406Sopenharmony_ci Copyright (C) 2019 Povilas Kanapickas <povilas@radix.lt> 4141cc406Sopenharmony_ci 5141cc406Sopenharmony_ci This file is part of the SANE package. 6141cc406Sopenharmony_ci 7141cc406Sopenharmony_ci This program is free software; you can redistribute it and/or 8141cc406Sopenharmony_ci modify it under the terms of the GNU General Public License as 9141cc406Sopenharmony_ci published by the Free Software Foundation; either version 2 of the 10141cc406Sopenharmony_ci License, or (at your option) any later version. 11141cc406Sopenharmony_ci 12141cc406Sopenharmony_ci This program is distributed in the hope that it will be useful, but 13141cc406Sopenharmony_ci WITHOUT ANY WARRANTY; without even the implied warranty of 14141cc406Sopenharmony_ci MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15141cc406Sopenharmony_ci General Public License for more details. 16141cc406Sopenharmony_ci 17141cc406Sopenharmony_ci You should have received a copy of the GNU General Public License 18141cc406Sopenharmony_ci along with this program. If not, see <https://www.gnu.org/licenses/>. 19141cc406Sopenharmony_ci*/ 20141cc406Sopenharmony_ci 21141cc406Sopenharmony_ci#define DEBUG_DECLARE_ONLY 22141cc406Sopenharmony_ci 23141cc406Sopenharmony_ci#include "settings.h" 24141cc406Sopenharmony_ci#include "utilities.h" 25141cc406Sopenharmony_ci#include <iomanip> 26141cc406Sopenharmony_ci 27141cc406Sopenharmony_cinamespace genesys { 28141cc406Sopenharmony_ci 29141cc406Sopenharmony_cistd::ostream& operator<<(std::ostream& out, const Genesys_Settings& settings) 30141cc406Sopenharmony_ci{ 31141cc406Sopenharmony_ci StreamStateSaver state_saver{out}; 32141cc406Sopenharmony_ci 33141cc406Sopenharmony_ci out << "Genesys_Settings{\n" 34141cc406Sopenharmony_ci << " xres: " << settings.xres << " yres: " << settings.yres << '\n' 35141cc406Sopenharmony_ci << " lines: " << settings.lines << '\n' 36141cc406Sopenharmony_ci << " pixels per line (actual): " << settings.pixels << '\n' 37141cc406Sopenharmony_ci << " pixels per line (requested): " << settings.requested_pixels << '\n' 38141cc406Sopenharmony_ci << " depth: " << settings.depth << '\n'; 39141cc406Sopenharmony_ci auto prec = out.precision(); 40141cc406Sopenharmony_ci out.precision(3); 41141cc406Sopenharmony_ci out << " tl_x: " << settings.tl_x << " tl_y: " << settings.tl_y << '\n'; 42141cc406Sopenharmony_ci out.precision(prec); 43141cc406Sopenharmony_ci out << " scan_mode: " << settings.scan_mode << '\n' 44141cc406Sopenharmony_ci << '}'; 45141cc406Sopenharmony_ci return out; 46141cc406Sopenharmony_ci} 47141cc406Sopenharmony_ci 48141cc406Sopenharmony_cistd::ostream& operator<<(std::ostream& out, const SetupParams& params) 49141cc406Sopenharmony_ci{ 50141cc406Sopenharmony_ci StreamStateSaver state_saver{out}; 51141cc406Sopenharmony_ci 52141cc406Sopenharmony_ci bool reverse = has_flag(params.flags, ScanFlag::REVERSE); 53141cc406Sopenharmony_ci 54141cc406Sopenharmony_ci out << "SetupParams{\n" 55141cc406Sopenharmony_ci << " xres: " << params.xres 56141cc406Sopenharmony_ci << " startx: " << params.startx 57141cc406Sopenharmony_ci << " pixels per line (actual): " << params.pixels 58141cc406Sopenharmony_ci << " pixels per line (requested): " << params.requested_pixels << '\n' 59141cc406Sopenharmony_ci 60141cc406Sopenharmony_ci << " yres: " << params.yres 61141cc406Sopenharmony_ci << " lines: " << params.lines 62141cc406Sopenharmony_ci << " starty: " << params.starty << (reverse ? " (reverse)" : "") << '\n' 63141cc406Sopenharmony_ci 64141cc406Sopenharmony_ci << " depth: " << params.depth << '\n' 65141cc406Sopenharmony_ci << " channels: " << params.channels << '\n' 66141cc406Sopenharmony_ci << " scan_mode: " << params.scan_mode << '\n' 67141cc406Sopenharmony_ci << " color_filter: " << params.color_filter << '\n' 68141cc406Sopenharmony_ci << " contrast_adjustment: " << params.contrast_adjustment << '\n' 69141cc406Sopenharmony_ci << " brightness_adjustment: " << params.brightness_adjustment << '\n' 70141cc406Sopenharmony_ci << " flags: " << params.flags << '\n' 71141cc406Sopenharmony_ci << "}"; 72141cc406Sopenharmony_ci return out; 73141cc406Sopenharmony_ci} 74141cc406Sopenharmony_ci 75141cc406Sopenharmony_cibool ScanSession::operator==(const ScanSession& other) const 76141cc406Sopenharmony_ci{ 77141cc406Sopenharmony_ci return params == other.params && 78141cc406Sopenharmony_ci computed == other.computed && 79141cc406Sopenharmony_ci full_resolution == other.full_resolution && 80141cc406Sopenharmony_ci optical_resolution == other.optical_resolution && 81141cc406Sopenharmony_ci optical_pixels == other.optical_pixels && 82141cc406Sopenharmony_ci optical_pixels_raw == other.optical_pixels_raw && 83141cc406Sopenharmony_ci optical_line_count == other.optical_line_count && 84141cc406Sopenharmony_ci output_resolution == other.output_resolution && 85141cc406Sopenharmony_ci output_startx == other.output_startx && 86141cc406Sopenharmony_ci output_pixels == other.output_pixels && 87141cc406Sopenharmony_ci output_channel_bytes == other.output_channel_bytes && 88141cc406Sopenharmony_ci output_line_bytes == other.output_line_bytes && 89141cc406Sopenharmony_ci output_line_bytes_raw == other.output_line_bytes_raw && 90141cc406Sopenharmony_ci output_line_bytes_requested == other.output_line_bytes_requested && 91141cc406Sopenharmony_ci output_line_count == other.output_line_count && 92141cc406Sopenharmony_ci output_total_bytes_raw == other.output_total_bytes_raw && 93141cc406Sopenharmony_ci output_total_bytes == other.output_total_bytes && 94141cc406Sopenharmony_ci num_staggered_lines == other.num_staggered_lines && 95141cc406Sopenharmony_ci max_color_shift_lines == other.max_color_shift_lines && 96141cc406Sopenharmony_ci color_shift_lines_r == other.color_shift_lines_r && 97141cc406Sopenharmony_ci color_shift_lines_g == other.color_shift_lines_g && 98141cc406Sopenharmony_ci color_shift_lines_b == other.color_shift_lines_b && 99141cc406Sopenharmony_ci stagger_x == other.stagger_x && 100141cc406Sopenharmony_ci stagger_y == other.stagger_y && 101141cc406Sopenharmony_ci segment_count == other.segment_count && 102141cc406Sopenharmony_ci pixel_startx == other.pixel_startx && 103141cc406Sopenharmony_ci pixel_endx == other.pixel_endx && 104141cc406Sopenharmony_ci pixel_count_ratio == other.pixel_count_ratio && 105141cc406Sopenharmony_ci conseq_pixel_dist == other.conseq_pixel_dist && 106141cc406Sopenharmony_ci output_segment_pixel_group_count == other.output_segment_pixel_group_count && 107141cc406Sopenharmony_ci output_segment_start_offset == other.output_segment_start_offset && 108141cc406Sopenharmony_ci shading_pixel_offset == other.shading_pixel_offset && 109141cc406Sopenharmony_ci buffer_size_read == other.buffer_size_read && 110141cc406Sopenharmony_ci enable_ledadd == other.enable_ledadd && 111141cc406Sopenharmony_ci use_host_side_calib == other.use_host_side_calib && 112141cc406Sopenharmony_ci use_host_side_gray == other.use_host_side_gray; 113141cc406Sopenharmony_ci} 114141cc406Sopenharmony_ci 115141cc406Sopenharmony_cistd::ostream& operator<<(std::ostream& out, const ScanSession& session) 116141cc406Sopenharmony_ci{ 117141cc406Sopenharmony_ci out << "ScanSession{\n" 118141cc406Sopenharmony_ci << " computed: " << session.computed << '\n' 119141cc406Sopenharmony_ci << " full_resolution: " << session.full_resolution << '\n' 120141cc406Sopenharmony_ci << " optical_resolution: " << session.optical_resolution << '\n' 121141cc406Sopenharmony_ci << " optical_pixels: " << session.optical_pixels << '\n' 122141cc406Sopenharmony_ci << " optical_pixels_raw: " << session.optical_pixels_raw << '\n' 123141cc406Sopenharmony_ci << " optical_line_count: " << session.optical_line_count << '\n' 124141cc406Sopenharmony_ci << " output_resolution: " << session.output_resolution << '\n' 125141cc406Sopenharmony_ci << " output_startx: " << session.output_startx << '\n' 126141cc406Sopenharmony_ci << " output_pixels: " << session.output_pixels << '\n' 127141cc406Sopenharmony_ci << " output_line_bytes: " << session.output_line_bytes << '\n' 128141cc406Sopenharmony_ci << " output_line_bytes_raw: " << session.output_line_bytes_raw << '\n' 129141cc406Sopenharmony_ci << " output_line_count: " << session.output_line_count << '\n' 130141cc406Sopenharmony_ci << " num_staggered_lines: " << session.num_staggered_lines << '\n' 131141cc406Sopenharmony_ci << " color_shift_lines_r: " << session.color_shift_lines_r << '\n' 132141cc406Sopenharmony_ci << " color_shift_lines_g: " << session.color_shift_lines_g << '\n' 133141cc406Sopenharmony_ci << " color_shift_lines_b: " << session.color_shift_lines_b << '\n' 134141cc406Sopenharmony_ci << " max_color_shift_lines: " << session.max_color_shift_lines << '\n' 135141cc406Sopenharmony_ci << " enable_ledadd: " << session.enable_ledadd << '\n' 136141cc406Sopenharmony_ci << " stagger_x: " << session.stagger_x << '\n' 137141cc406Sopenharmony_ci << " stagger_y: " << session.stagger_y << '\n' 138141cc406Sopenharmony_ci << " segment_count: " << session.segment_count << '\n' 139141cc406Sopenharmony_ci << " pixel_startx: " << session.pixel_startx << '\n' 140141cc406Sopenharmony_ci << " pixel_endx: " << session.pixel_endx << '\n' 141141cc406Sopenharmony_ci << " pixel_count_ratio: " << session.pixel_count_ratio << '\n' 142141cc406Sopenharmony_ci << " conseq_pixel_dist: " << session.conseq_pixel_dist << '\n' 143141cc406Sopenharmony_ci << " output_segment_pixel_group_count: " 144141cc406Sopenharmony_ci << session.output_segment_pixel_group_count << '\n' 145141cc406Sopenharmony_ci << " shading_pixel_offset: " << session.shading_pixel_offset << '\n' 146141cc406Sopenharmony_ci << " buffer_size_read: " << session.buffer_size_read << '\n' 147141cc406Sopenharmony_ci << " enable_ledadd: " << session.enable_ledadd << '\n' 148141cc406Sopenharmony_ci << " use_host_side_calib: " << session.use_host_side_calib << '\n' 149141cc406Sopenharmony_ci << " use_host_side_gray: " << session.use_host_side_gray << '\n' 150141cc406Sopenharmony_ci << " params: " << format_indent_braced_list(4, session.params) << '\n' 151141cc406Sopenharmony_ci << "}"; 152141cc406Sopenharmony_ci return out; 153141cc406Sopenharmony_ci} 154141cc406Sopenharmony_ci 155141cc406Sopenharmony_cistd::ostream& operator<<(std::ostream& out, const SANE_Parameters& params) 156141cc406Sopenharmony_ci{ 157141cc406Sopenharmony_ci out << "SANE_Parameters{\n" 158141cc406Sopenharmony_ci << " format: " << static_cast<unsigned>(params.format) << '\n' 159141cc406Sopenharmony_ci << " last_frame: " << params.last_frame << '\n' 160141cc406Sopenharmony_ci << " bytes_per_line: " << params.bytes_per_line << '\n' 161141cc406Sopenharmony_ci << " pixels_per_line: " << params.pixels_per_line << '\n' 162141cc406Sopenharmony_ci << " lines: " << params.lines << '\n' 163141cc406Sopenharmony_ci << " depth: " << params.depth << '\n' 164141cc406Sopenharmony_ci << '}'; 165141cc406Sopenharmony_ci return out; 166141cc406Sopenharmony_ci} 167141cc406Sopenharmony_ci 168141cc406Sopenharmony_ci} // namespace genesys 169