openMSX
MSXCliComm.cc
Go to the documentation of this file.
1 #include "MSXCliComm.hh"
2 #include "GlobalCliComm.hh"
3 #include "MSXMotherBoard.hh"
4 
5 namespace openmsx {
6 
8  : motherBoard(motherBoard_)
9  , cliComm(cliComm_)
10 {
11 }
12 
13 void MSXCliComm::log(LogLevel level, std::string_view message)
14 {
15  cliComm.log(level, message);
16 }
17 
18 void MSXCliComm::update(UpdateType type, std::string_view name, std::string_view value)
19 {
20  assert(type < NUM_UPDATES);
21  if (auto v = lookup(prevValues[type], name)) {
22  if (*v == value) {
23  return;
24  }
25  *v = std::string(value);
26  } else {
27  prevValues[type].emplace_noDuplicateCheck(name, value);
28  }
29  cliComm.updateHelper(type, motherBoard.getMachineID(), name, value);
30 }
31 
32 } // namespace openmsx
std::string_view getMachineID() const
const Value * lookup(const hash_map< Key, Value, Hasher, Equal > &map, const Key2 &key)
Definition: hash_map.hh:91
void log(LogLevel level, std::string_view message) override
Definition: MSXCliComm.cc:13
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void update(UpdateType type, std::string_view name, std::string_view value) override
Definition: MSXCliComm.cc:18
MSXCliComm(MSXMotherBoard &motherBoard, GlobalCliComm &cliComm)
Definition: MSXCliComm.cc:7
iterator emplace_noDuplicateCheck(Args &&... args)
Definition: hash_set.hh:468
void log(LogLevel level, std::string_view message) override