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 <array>
8#include <memory>
9#include <mutex>
10#include <vector>
11
12namespace openmsx {
13
14class CliListener;
15
16class GlobalCliComm final : public CliComm
17{
18public:
19 GlobalCliComm(const GlobalCliComm&) = delete;
21
22 GlobalCliComm() = default;
24
25 CliListener* addListener(std::unique_ptr<CliListener> listener);
26 std::unique_ptr<CliListener> removeListener(CliListener& listener);
27
28 // Before this method has been called commands send over external
29 // connections are not yet processed (but they keep pending).
31
32 // CliComm
33 void log(LogLevel level, std::string_view message, float fraction) override;
34 void update(UpdateType type, std::string_view name,
35 std::string_view value) override;
36 void updateFiltered(UpdateType type, std::string_view name,
37 std::string_view value) override;
38
39private:
40 void updateHelper(UpdateType type, std::string_view machine,
41 std::string_view name, std::string_view value);
42
43private:
44 std::array<hash_map<std::string, std::string, XXHasher>, NUM_UPDATES> prevValues;
45
46 std::vector<std::unique_ptr<CliListener>> listeners; // unordered
47 std::mutex mutex; // lock access to listeners member
48 bool delivering = false;
49 bool allowExternalCommands = false;
50
51 friend class MSXCliComm;
52};
53
54} // namespace openmsx
55
56#endif
CliListener * addListener(std::unique_ptr< CliListener > listener)
void log(LogLevel level, std::string_view message, float fraction) override
Log a message with a certain priority level.
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