// SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2026 Martino Ferrari #pragma once #include "source/data_source.hpp" #include "source/source_config.hpp" #include #include #include #include #include namespace udpscope { /// A kind's configuration UI, as pieces the chooser places in its own group. The widgets are /// floating `AdwPreferencesRow`s; the closures capture them, so a form must not outlive its rows /// (the chooser drops the form when it removes the rows). struct ConfigForm { std::vector rows; /// Shown under the group's title; empty for none. std::string description; /// The widget that takes focus when the form is shown; may be null. GtkWidget* focus = nullptr; /// Puts `cfg` into the widgets (absent keys leave the kind's defaults). std::function write; /// The widgets as a `SourceConfig`. std::function read; /// Whether the form is complete enough to connect. std::function valid; /// Calls `fn` whenever any widget changes. std::function)> on_change; }; /// A capability panel (signal generator, digital I/O, ...) for the side area. struct SourcePanel { std::string id; ///< stack page name std::string title; GtkWidget* widget = nullptr; }; /// One plugin type: its identity, factory and UI. class SourceKind { public: virtual ~SourceKind() = default; virtual std::string id() const = 0; ///< short, `[a-z0-9]+`; the CLI and session name virtual std::string display_name() const = 0; /// A stable, human-readable name for one configured source (`host:port`, a serial number). virtual std::string identity(const SourceConfig& cfg) const = 0; virtual std::unique_ptr make(const SourceConfig& cfg) const = 0; virtual ConfigForm make_config_form() const = 0; /// Panels for a live source. The widgets must reach the source only through `post()`. virtual std::vector make_panels(DataSource& source) const { (void)source; return {}; } /// Whether the source reports raw datagrams (enables the packet-capture UI). virtual bool has_datagrams() const { return false; } }; } // namespace udpscope