openMSX
GlobalCliComm.hh
Go to the documentation of this file.
1 #ifndef GLOBALCLICOMM_HH
2 #define GLOBALCLICOMM_HH
3 
4 #include "CliComm.hh"
5 #include "hash_map.hh"
6 #include "xxhash.hh"
7 #include <memory>
8 #include <mutex>
9 #include <vector>
10 
11 namespace openmsx {
12 
13 class CliListener;
14 
15 class GlobalCliComm final : public CliComm
16 {
17 public:
18  GlobalCliComm(const GlobalCliComm&) = delete;
19  GlobalCliComm& operator=(const GlobalCliComm&) = delete;
20 
21  GlobalCliComm() = default;
23 
24  void addListener(std::unique_ptr<CliListener> listener);
25  std::unique_ptr<CliListener> removeListener(CliListener& listener);
26 
27  // Before this method has been called commands send over external
28  // connections are not yet processed (but they keep pending).
30 
31  // CliComm
32  void log(LogLevel level, std::string_view message) override;
33  void update(UpdateType type, std::string_view name,
34  std::string_view value) override;
35 
36 private:
37  void updateHelper(UpdateType type, std::string_view machine,
38  std::string_view name, std::string_view value);
39 
41 
42  std::vector<std::unique_ptr<CliListener>> listeners; // unordered
43  std::mutex mutex; // lock access to listeners member
44  bool delivering = false;
45  bool allowExternalCommands = false;
46 
47  friend class MSXCliComm;
48 };
49 
50 } // namespace openmsx
51 
52 #endif
void addListener(std::unique_ptr< CliListener > listener)
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
std::unique_ptr< CliListener > removeListener(CliListener &listener)
void log(LogLevel level, std::string_view message) override
GlobalCliComm & operator=(const GlobalCliComm &)=delete