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:
26 MSXCommandController(GlobalCommandController& globalCommandController,
27 Reactor& reactor, MSXMotherBoard& motherboard,
28 MSXEventDistributor& msxEventDistributor,
29 const std::string& machineID);
35
37 return globalCommandController;
38 }
40 return *machineInfoCommand;
41 }
42 [[nodiscard]] MSXMotherBoard& getMSXMotherBoard() const {
43 return motherboard;
44 }
45 [[nodiscard]] const std::string& getPrefix() const {
46 return machineID;
47 }
48
49 [[nodiscard]] Command* findCommand(std::string_view name) const;
50 [[nodiscard]] Setting* findSetting(std::string_view name) const;
51
55 [[nodiscard]] bool isActive() const;
56
59 void transferSettings(const MSXCommandController& from);
60
61 [[nodiscard]] bool hasCommand(std::string_view command) const;
62
63 // CommandController
64 void registerCompleter(CommandCompleter& completer,
65 std::string_view str) override;
67 std::string_view str) override;
68 void registerCommand(Command& command,
69 zstring_view str) override;
70 void unregisterCommand(Command& command,
71 std::string_view str) override;
73 CliConnection* connection = nullptr) override;
74 void registerSetting(Setting& setting) override;
75 void unregisterSetting(Setting& setting) override;
76 [[nodiscard]] MSXCliComm& getCliComm() override;
77 [[nodiscard]] Interpreter& getInterpreter() override;
78
79private:
80 [[nodiscard]] TemporaryString getFullName(std::string_view name);
81
82 // MSXEventListener
83 void signalMSXEvent(const Event& event,
84 EmuTime::param time) noexcept override;
85
86 GlobalCommandController& globalCommandController;
87 Reactor& reactor;
88 MSXMotherBoard& motherboard;
89 MSXEventDistributor& msxEventDistributor;
90 std::string machineID;
91 std::optional<InfoCommand> machineInfoCommand;
92
93 struct NameFromCommand {
94 [[nodiscard]] const std::string& operator()(const Command* c) const {
95 return c->getName();
96 }
97 };
99
100 std::vector<Setting*> settings; // unordered
101};
102
103} // namespace openmsx
104
105#endif
BaseSetting * setting
TemporaryString.
const std::string & getName() const
Definition Completer.hh:27
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
MSXCommandController(MSXCommandController &&)=delete
GlobalCommandController & getGlobalCommandController()
MSXCommandController & operator=(MSXCommandController &&)=delete
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:75
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:11
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, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:445