openMSX
MSXCommandController.hh
Go to the documentation of this file.
1#ifndef MSXCOMMANDCONTROLLER_HH
2#define MSXCOMMANDCONTROLLER_HH
3
5#include "Command.hh"
6#include "InfoCommand.hh"
7#include "MSXEventListener.hh"
8#include "TemporaryString.hh"
9#include "hash_set.hh"
10#include "xxhash.hh"
11#include <memory>
12
13namespace openmsx {
14
15class GlobalCommandController;
16class MSXEventDistributor;
17class MSXMotherBoard;
18class Reactor;
19class Setting;
20
22 : public CommandController, private MSXEventListener
23{
24public:
27
28 MSXCommandController(GlobalCommandController& globalCommandController,
29 Reactor& reactor, MSXMotherBoard& motherboard,
30 MSXEventDistributor& msxEventDistributor,
31 const std::string& machineID);
33
35 return globalCommandController;
36 }
38 return *machineInfoCommand;
39 }
40 [[nodiscard]] MSXMotherBoard& getMSXMotherBoard() const {
41 return motherboard;
42 }
43 [[nodiscard]] const std::string& getPrefix() const {
44 return machineID;
45 }
46
47 [[nodiscard]] Command* findCommand(std::string_view name) const;
48
52 [[nodiscard]] bool isActive() const;
53
56 void transferSettings(const MSXCommandController& from);
57
58 [[nodiscard]] bool hasCommand(std::string_view command) const;
59
60 // CommandController
61 void registerCompleter(CommandCompleter& completer,
62 std::string_view str) override;
64 std::string_view str) override;
65 void registerCommand(Command& command,
66 zstring_view str) override;
67 void unregisterCommand(Command& command,
68 std::string_view str) override;
70 CliConnection* connection = nullptr) override;
71 void registerSetting(Setting& setting) override;
72 void unregisterSetting(Setting& setting) override;
73 [[nodiscard]] CliComm& getCliComm() override;
74 [[nodiscard]] Interpreter& getInterpreter() override;
75
76private:
77 [[nodiscard]] TemporaryString getFullName(std::string_view name);
78
79 // MSXEventListener
80 void signalMSXEvent(const Event& event,
81 EmuTime::param time) noexcept override;
82
83 GlobalCommandController& globalCommandController;
84 Reactor& reactor;
85 MSXMotherBoard& motherboard;
86 MSXEventDistributor& msxEventDistributor;
87 std::string machineID;
88 std::optional<InfoCommand> machineInfoCommand;
89
90 struct NameFromCommand {
91 [[nodiscard]] const std::string& operator()(const Command* c) const {
92 return c->getName();
93 }
94 };
96
97 std::vector<Setting*> settings; // unordered
98};
99
100} // namespace openmsx
101
102#endif
BaseSetting * setting
Definition: Interpreter.cc:28
TemporaryString.
const std::string & getName() const
Definition: Completer.hh:23
bool hasCommand(std::string_view command) const
MSXMotherBoard & getMSXMotherBoard() const
Interpreter & getInterpreter() override
void registerCompleter(CommandCompleter &completer, std::string_view str) override
(Un)register a command completer, used to complete build-in Tcl cmds
GlobalCommandController & getGlobalCommandController()
TclObject executeCommand(zstring_view command, CliConnection *connection=nullptr) override
Execute the given command.
void unregisterCompleter(CommandCompleter &completer, std::string_view str) override
void registerCommand(Command &command, zstring_view str) override
(Un)register a command
void transferSettings(const MSXCommandController &from)
Transfer setting values from one machine to another, used for during 'reverse'.
void unregisterSetting(Setting &setting) override
const std::string & getPrefix() const
bool isActive() const
Returns true iff the machine this controller belongs to is currently active.
MSXCommandController(const MSXCommandController &)=delete
MSXCommandController & operator=(const MSXCommandController &)=delete
void unregisterCommand(Command &command, std::string_view str) override
void registerSetting(Setting &setting) override
TODO.
Command * findCommand(std::string_view name) const
Contains the main loop of openMSX.
Definition: Reactor.hh:68
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
Definition: zstring_view.hh:22
This file implemented 3 utility functions:
Definition: Autofire.cc:9