openMSX
MSXCommandController.hh
Go to the documentation of this file.
1 #ifndef MSXCOMMANDCONTROLLER_HH
2 #define MSXCOMMANDCONTROLLER_HH
3 
4 #include "CommandController.hh"
5 #include "MSXEventListener.hh"
6 #include "StringMap.hh"
7 #include "noncopyable.hh"
8 #include <memory>
9 
10 namespace openmsx {
11 
12 class GlobalCommandController;
13 class Reactor;
14 class MSXMotherBoard;
15 class MSXEventDistributor;
16 class InfoCommand;
17 
19  : public CommandController, private MSXEventListener
20  , private noncopyable
21 {
22 public:
23  MSXCommandController(GlobalCommandController& globalCommandController,
24  Reactor& reactor, MSXMotherBoard& motherboard,
25  MSXEventDistributor& msxEventDistributor,
26  const std::string& machineID);
28 
30  return globalCommandController;
31  }
33  return *machineInfoCommand;
34  }
36  return motherboard;
37  }
38 
39  Command* findCommand(string_ref name) const;
40 
44  bool isActive() const;
45 
48  void transferSettings(const MSXCommandController& from);
49 
50  // CommandController
51  void registerCompleter(CommandCompleter& completer,
52  string_ref str) override;
53  void unregisterCompleter(CommandCompleter& completer,
54  string_ref str) override;
55  void registerCommand(Command& command,
56  const std::string& str) override;
57  void unregisterCommand(Command& command,
58  string_ref str) override;
59  bool hasCommand(string_ref command) const override;
60  std::string executeCommand(const std::string& command,
61  CliConnection* connection = nullptr) override;
62  std::vector<std::string> splitList(const std::string& list) override;
63  void registerSetting(Setting& setting) override;
64  void unregisterSetting(Setting& setting) override;
65  BaseSetting* findSetting(string_ref name) override;
66  void changeSetting(Setting& setting, const std::string& value) override;
67  CliComm& getCliComm() override;
68  Interpreter& getInterpreter() override;
69 
70  const BaseSetting* findSetting(string_ref setting) const;
71 
72 private:
73  std::string getFullName(string_ref name);
74 
75  // MSXEventListener
76  void signalEvent(const std::shared_ptr<const Event>& event,
77  EmuTime::param time) override;
78 
79  GlobalCommandController& globalCommandController;
80  Reactor& reactor;
81  MSXMotherBoard& motherboard;
82  MSXEventDistributor& msxEventDistributor;
83  const std::string& machineID;
84  std::unique_ptr<InfoCommand> machineInfoCommand;
85 
86  StringMap<Command*> commandMap;
87  StringMap<Setting*> settingMap;
88 };
89 
90 } // namespace openmsx
91 
92 #endif
BaseSetting * findSetting(string_ref name) override
void transferSettings(const MSXCommandController &from)
Transfer setting values from one machine to another, used for during 'reverse'.
Contains the main loop of openMSX.
Definition: Reactor.hh:62
bool isActive() const
Returns true iff the machine this controller belongs to is currently active.
void unregisterCommand(Command &command, string_ref str) override
void unregisterSetting(Setting &setting) override
GlobalCommandController & getGlobalCommandController()
Command * findCommand(string_ref name) const
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
void registerCommand(Command &command, const std::string &str) override
(Un)register a command
Interpreter & getInterpreter() override
MSXCommandController(GlobalCommandController &globalCommandController, Reactor &reactor, MSXMotherBoard &motherboard, MSXEventDistributor &msxEventDistributor, const std::string &machineID)
void registerCompleter(CommandCompleter &completer, string_ref str) override
(Un)register a command completer, used to complete build-in Tcl cmds
std::vector< std::string > splitList(const std::string &list) override
void registerSetting(Setting &setting) override
TODO.
MSXMotherBoard & getMSXMotherBoard() const
bool hasCommand(string_ref command) const override
Does a command with this name already exist?
Based on boost::noncopyable, see boost documentation: http://www.boost.org/libs/utility.
Definition: noncopyable.hh:12
void changeSetting(Setting &setting, const std::string &value) override
void unregisterCompleter(CommandCompleter &completer, string_ref str) override
std::string executeCommand(const std::string &command, CliConnection *connection=nullptr) override
Execute the given command.