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;
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 
40 private:
42 
43  std::vector<std::unique_ptr<CliListener>> listeners; // unordered
44  std::mutex mutex; // lock access to listeners member
45  bool delivering = false;
46  bool allowExternalCommands = false;
47 
48  friend class MSXCliComm;
49 };
50 
51 } // namespace openmsx
52 
53 #endif
void addListener(std::unique_ptr< CliListener > listener)
void log(LogLevel level, std::string_view message) override
void update(UpdateType type, std::string_view name, std::string_view value) override
GlobalCliComm(const GlobalCliComm &)=delete
GlobalCliComm & operator=(const GlobalCliComm &)=delete
std::unique_ptr< CliListener > removeListener(CliListener &listener)
This file implemented 3 utility functions:
Definition: Autofire.cc:9