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 "MSXCliComm.hh"
9#include "TemporaryString.hh"
10#include "hash_set.hh"
11#include "xxhash.hh"
12#include <memory>
13
14namespace openmsx {
15
16class GlobalCommandController;
17class MSXEventDistributor;
18class MSXMotherBoard;
19class Reactor;
20class Setting;
21
23 : public CommandController, private MSXEventListener
24{
25public:
28
29 MSXCommandController(GlobalCommandController& globalCommandController,
30 Reactor& reactor, MSXMotherBoard& motherboard,
31 MSXEventDistributor& msxEventDistributor,
32 const std::string& machineID);
34
36 return globalCommandController;
37 }
39 return *machineInfoCommand;
40 }
41 [[nodiscard]] MSXMotherBoard& getMSXMotherBoard() const {
42 return motherboard;
43 }
44 [[nodiscard]] const std::string& getPrefix() const {
45 return machineID;
46 }
47
48 [[nodiscard]] Command* findCommand(std::string_view name) const;
49 [[nodiscard]] Setting* findSetting(std::string_view name) const;
50
54 [[nodiscard]] bool isActive() const;
55
58 void transferSettings(const MSXCommandController& from);
59
60 [[nodiscard]] bool hasCommand(std::string_view command) const;
61
62 // CommandController
63 void registerCompleter(CommandCompleter& completer,
64 std::string_view str) override;
66 std::string_view str) override;
67 void registerCommand(Command& command,
68 zstring_view str) override;
69 void unregisterCommand(Command& command,
70 std::string_view str) override;
72 CliConnection* connection = nullptr) override;
73 void registerSetting(Setting& setting) override;
74 void unregisterSetting(Setting& setting) override;
75 [[nodiscard]] MSXCliComm& getCliComm() override;
76 [[nodiscard]] Interpreter& getInterpreter() override;
77
78private:
79 [[nodiscard]] TemporaryString getFullName(std::string_view name);
80
81 // MSXEventListener
82 void signalMSXEvent(const Event& event,
83 EmuTime::param time) noexcept override;
84
85 GlobalCommandController& globalCommandController;
86 Reactor& reactor;
87 MSXMotherBoard& motherboard;
88 MSXEventDistributor& msxEventDistributor;
89 std::string machineID;
90 std::optional<InfoCommand> machineInfoCommand;
91
92 struct NameFromCommand {
93 [[nodiscard]] const std::string& operator()(const Command* c) const {
94 return c->getName();
95 }
96 };
98
99 std::vector<Setting*> settings; // unordered
100};
101
102} // namespace openmsx
103
104#endif
BaseSetting * setting
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
Setting * findSetting(std::string_view name) const
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:72
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
This file implemented 3 utility functions:
Definition Autofire.cc:9
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:452