source: DataSource, Frame, SourceConfig and the registry (unused yet)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
71b904a93b
commit
3896f404a9
11 files changed
+445
-3
No files matched your search
@@ -0,0 +1,64 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-FileCopyrightText: 2026 Martino Ferrari
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "source/data_source.hpp"
|
||||
#include "source/source_config.hpp"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
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<GtkWidget*> 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<void(const SourceConfig&)> write;
|
||||
/// The widgets as a `SourceConfig`.
|
||||
std::function<SourceConfig()> read;
|
||||
/// Whether the form is complete enough to connect.
|
||||
std::function<bool()> valid;
|
||||
/// Calls `fn` whenever any widget changes.
|
||||
std::function<void(std::function<void()>)> 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;
|
||||
std::string icon; ///< icon name for the tab, may be empty
|
||||
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<DataSource> 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<SourcePanel> 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
|
||||
Reference in new issue
Block a user