| 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 |
|
| 15 |
namespace openmsx { |
| 16 |
|
| 17 |
class CliListener; |
| 18 |
|
| 19 |
class GlobalCliComm final : public CliComm |
| 20 |
{ |
| 21 |
public: |
| 22 |
GlobalCliComm() = default; |
| 23 |
GlobalCliComm(const GlobalCliComm&) = delete; |
| 24 |
GlobalCliComm(GlobalCliComm&&) = delete; |
| 25 |
GlobalCliComm& operator=(const GlobalCliComm&) = delete; |
| 26 |
GlobalCliComm& operator=(GlobalCliComm&&) = delete; |
| 27 |
~GlobalCliComm(); |
| 28 |
|
| 29 |
CliListener* addListener(std::unique_ptr<CliListener> listener); |
| 30 |
std::unique_ptr<CliListener> removeListener(CliListener& listener); |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
void setAllowExternalCommands(); |
| 35 |
|
| 36 |
|
| 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 |
|
| 43 |
private: |
| 44 |
void updateHelper(UpdateType type, std::string_view machine, |
| 45 |
std::string_view name, std::string_view value); |
| 46 |
|
| 47 |
private: |
| 48 |
array_with_enum_index<CliComm::UpdateType, hash_map<std::string, std::string, XXHasher>> prevValues; |
| 49 |
|
| 50 |
std::vector<std::unique_ptr<CliListener>> listeners; |
| 51 |
std::mutex mutex; |
| 52 |
bool delivering = false; |
| 53 |
bool allowExternalCommands = false; |
| 54 |
|
| 55 |
friend class MSXCliComm; |
| 56 |
}; |
| 57 |
|
| 58 |
} |
| 59 |
|
| 60 |
#endif |