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  void updateFiltered(UpdateType type, std::string_view name,
36  std::string_view value) override;
37 
38 private:
39  void updateHelper(UpdateType type, std::string_view machine,
40  std::string_view name, std::string_view value);
41 
42 private:
44 
45  std::vector<std::unique_ptr<CliListener>> listeners; // unordered
46  std::mutex mutex; // lock access to listeners member
47  bool delivering = false;
48  bool allowExternalCommands = false;
49 
50  friend class MSXCliComm;
51 };
52 
53 } // namespace openmsx
54 
55 #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)
void updateFiltered(UpdateType type, std::string_view name, std::string_view value) override
Same as update(), but checks that the value for type-name is the same as in the previous call.
This file implemented 3 utility functions:
Definition: Autofire.cc:9