openMSX
TclCallbackMessages.cc
Go to the documentation of this file.
2#include "GlobalCliComm.hh"
3
4namespace openmsx {
5
7 CommandController& controller)
8 : cliComm(cliComm_)
9 , messageCallback(
10 controller, "message_callback",
11 "Tcl proc called when a new message is available",
12 "default_message_callback",
13 Setting::SaveSetting::SAVE, // the user must be able to override
14 false) // don't print callback err on cliComm (would cause infinite loop)
15{
16 cliComm.addListener(std::unique_ptr<CliListener>(this)); // wrap in unique_ptr
17}
18
20{
21 std::unique_ptr<CliListener> ptr = cliComm.removeListener(*this);
22 (void)ptr.release();
23}
24
25void TclCallbackMessages::log(CliComm::LogLevel level, std::string_view message) noexcept
26{
27 auto levelStr = CliComm::getLevelStrings();
28 messageCallback.execute(message, levelStr[level]);
29}
30
32 CliComm::UpdateType /*type*/, std::string_view /*machine*/,
33 std::string_view /*name*/, std::string_view /*value*/) noexcept
34{
35 // ignore
36}
37
38} // namespace openmsx
static std::span< const std::string_view, NUM_LEVELS > getLevelStrings()
Definition: CliComm.hh:88
void addListener(std::unique_ptr< CliListener > listener)
std::unique_ptr< CliListener > removeListener(CliListener &listener)
void update(CliComm::UpdateType type, std::string_view machine, std::string_view name, std::string_view value) noexcept override
void log(CliComm::LogLevel level, std::string_view message) noexcept override
TclCallbackMessages(GlobalCliComm &cliComm, CommandController &controller)
This file implemented 3 utility functions:
Definition: Autofire.cc:9