RumPi Linux Client 1.0
A wxWidgets desktop dashboard that visualizes a RumPi robot's live sensor data as a condition-reactive scene
LoggerEventForwarder.h
Go to the documentation of this file.
1#pragma once
2#include <wx/event.h>
3#include <wx/thread.h>
4#include <RumPi/AlertManager.h>
5
7wxDECLARE_EVENT(wxEVT_RUMPI_LOGGER_UPDATE, wxThreadEvent);
8
18{
19protected:
20 wxEvtHandler* myWxEventHandler;
21
23 std::size_t mySubscriptionId;
24
25public:
39 LoggerEventForwarder(wxEvtHandler* handler);
40
41 //Owns an AlertManager subscription (unsubscribed in the destructor), so a copy would double-unsubscribe and tear
42 //down the original's live subscription. Non-copyable.
45
57
71 void HandleLoggerEvent(const RumPi::AlertEvent& loggerEvent);
72};
wxDECLARE_EVENT(wxEVT_RUMPI_LOGGER_UPDATE, wxThreadEvent)
Custom event used to carry a finished log line from the AlertManager (worker thread) to the UI (main ...
Bridges the library's AlertManager to the wxWidgets event system: it subscribes to the AlertManager o...
Definition: LoggerEventForwarder.h:18
std::size_t mySubscriptionId
Handle for the AlertManager subscription, so the destructor can unsubscribe.
Definition: LoggerEventForwarder.h:23
LoggerEventForwarder & operator=(const LoggerEventForwarder &)=delete
wxEvtHandler * myWxEventHandler
The UI event handler that receives forwarded log events.
Definition: LoggerEventForwarder.h:20
void HandleLoggerEvent(const RumPi::AlertEvent &loggerEvent)
Builds a log line (pure data) from the alert and queues it to the UI handler as a wxEVT_RUMPI_LOGGER_...
Definition: LoggerEventForwarder.cpp:63
LoggerEventForwarder(wxEvtHandler *handler)
Subscribes to the AlertManager and stores the given UI handler so every alert is forwarded to it.
Definition: LoggerEventForwarder.cpp:21
~LoggerEventForwarder()
Unsubscribes from the AlertManager so a later alert can't call into a destroyed forwarder.
Definition: LoggerEventForwarder.cpp:44
LoggerEventForwarder(const LoggerEventForwarder &)=delete