openMSX
TclCallbackMessages.cc
Go to the documentation of this file.
1 #include "TclCallbackMessages.hh"
2 #include "GlobalCliComm.hh"
3 
4 namespace 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  false, // don't print callback err on cliComm (would cause infinite loop)
13  false) // don't save setting
14 {
15  cliComm.addListener(std::unique_ptr<CliListener>(this)); // wrap in unique_ptr
16 }
17 
19 {
20  std::unique_ptr<CliListener> ptr = cliComm.removeListener(*this);
21  ptr.release();
22 }
23 
24 void TclCallbackMessages::log(CliComm::LogLevel level, std::string_view message) noexcept
25 {
26  auto levelStr = CliComm::getLevelStrings();
27  messageCallback.execute(message, levelStr[level]);
28 }
29 
31  CliComm::UpdateType /*type*/, std::string_view /*machine*/,
32  std::string_view /*name*/, std::string_view /*value*/) noexcept
33 {
34  // ignore
35 }
36 
37 } // namespace openmsx
static span< const char *const > getLevelStrings()
Definition: CliComm.hh:82
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