Skip to content
API Documentation
BastionGuard™
LiveScanDialog.hpp
Go to the documentation of this file.
1/*
2 * BastionGuard™
3 * Copyright (C) 2025–2026 Calogero Scarnà
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 *
17 * BastionGuard™ is a trademark of Calogero Scarnà.
18 * The BastionGuard™ name and branding are not licensed under the GPL.
19 */
20
21#pragma once
22#include <gtkmm.h>
23#include <atomic>
24#include <memory>
25#include <mutex>
26#include <vector>
27
28#include "../LifetimeGuard.hpp"
29
30class LiveScanDialog : public Gtk::Window {
31public:
32 LiveScanDialog(Gtk::Window* parent, const std::string& path);
33 ~LiveScanDialog() override;
34
35 void append_output(const std::string& line);
36 void mark_finished();
37 bool cancelled() const { return cancelled_.load(); }
38 std::string get_full_output() const;
39
40private:
41 void flush_output_idle();
42
43 Gtk::Box root_;
44 Gtk::ProgressBar progress_;
45 Gtk::ScrolledWindow scroller_;
46 Gtk::TextView text_view_;
47 Gtk::Button btn_cancel_;
48
49 std::atomic<bool> finished_{false};
50 std::atomic<bool> cancelled_{false};
51 std::atomic<bool> flush_pending_{false};
52
53 mutable std::mutex mtx_;
54 std::vector<std::string> pending_lines_;
55 std::string full_output_;
56
57 // Alive flag condiviso: i lambda asincroni catturano una copia di questo
58 // shared_ptr; se l'oggetto viene distrutto prima che il lambda giri,
59 // il flag diventa false e il lambda fa early-return senza toccare `this`.
61};
std::vector< std::string > pending_lines_
std::string full_output_
LiveScanDialog(Gtk::Window *parent, const std::string &path)
Gtk::Button btn_cancel_
std::atomic< bool > flush_pending_
Gtk::TextView text_view_
bool cancelled() const
Gtk::ProgressBar progress_
BastionGuard::AliveFlag alive_
void append_output(const std::string &line)
std::atomic< bool > finished_
std::string get_full_output() const
std::atomic< bool > cancelled_
Gtk::ScrolledWindow scroller_
std::shared_ptr< std::atomic< bool > > AliveFlag