fwt_software/include/fgc/ui/IUserInterface.h

36 lines
1.2 KiB
C++

#pragma once
#include "fgc/ui/UiSnapshot.h"
#include <functional>
#include <string>
namespace fgc {
// Abstraction over the operator interface, wired into the Application the same
// way the motor/camera/channel backends are. It is a pure observer + command
// source: it pulls a UiSnapshot to render and pushes command strings back, but
// never touches the live logic objects.
//
// - HeadlessUi: today's line-based console (stdin -> commands, stdout logs).
// - TuiUi: FTXUI full-screen dashboard (built only when FGC_WITH_TUI).
//
// Both run on their own thread(s); start() must not block the control loop.
class IUserInterface {
public:
// Called by the UI thread when it wants the latest state to render.
using SnapshotFn = std::function<UiSnapshot()>;
// Called by the UI to enqueue a console/firmware command line.
using CommandSink = std::function<void(const std::string&)>;
virtual ~IUserInterface() = default;
// Begin interaction. Non-blocking: spawns the UI's own thread(s).
virtual void start(SnapshotFn snapshot, CommandSink sink) = 0;
// Stop and join the UI thread(s); restore the terminal if needed.
virtual void stop() = 0;
};
} // namespace fgc