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