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 "Command.hh"
6 #include "MSXEventListener.hh"
7 #include "Setting.hh"
8 #include "hash_set.hh"
9 #include "noncopyable.hh"
10 #include "xxhash.hh"
11 #include <memory>
12 
13 namespace openmsx {
14 
15 class GlobalCommandController;
16 class Reactor;
17 class MSXMotherBoard;
18 class MSXEventDistributor;
19 class InfoCommand;
20 
22  : public CommandController, private MSXEventListener
23  , private noncopyable
24 {
25 public:
26  MSXCommandController(GlobalCommandController& globalCommandController,
27  Reactor& reactor, MSXMotherBoard& motherboard,
28  MSXEventDistributor& msxEventDistributor,
29  const std::string& machineID);
31 
33  return globalCommandController;
34  }
36  return *machineInfoCommand;
37  }
39  return motherboard;
40  }
41 
42  Command* findCommand(string_ref name) const;
43 
47  bool isActive() const;
48 
51  void transferSettings(const MSXCommandController& from);
52 
53  // CommandController
54  void registerCompleter(CommandCompleter& completer,
55  string_ref str) override;
56  void unregisterCompleter(CommandCompleter& completer,
57  string_ref str) override;
58  void registerCommand(Command& command,
59  const std::string& str) override;
60  void unregisterCommand(Command& command,
61  string_ref str) override;
62  bool hasCommand(string_ref command) const override;
63  TclObject executeCommand(const std::string& command,
64  CliConnection* connection = nullptr) override;
65  void registerSetting(Setting& setting) override;
66  void unregisterSetting(Setting& setting) override;
67  BaseSetting* findSetting(string_ref name) override;
68  void changeSetting(Setting& setting, const TclObject& value) override;
69  CliComm& getCliComm() override;
70  Interpreter& getInterpreter() override;
71 
72  const BaseSetting* findSetting(string_ref setting) const;
73 
74 private:
75  std::string getFullName(string_ref name);
76 
77  // MSXEventListener
78  void signalEvent(const std::shared_ptr<const Event>& event,
79  EmuTime::param time) override;
80 
81  GlobalCommandController& globalCommandController;
82  Reactor& reactor;
83  MSXMotherBoard& motherboard;
84  MSXEventDistributor& msxEventDistributor;
85  std::string machineID;
86  std::unique_ptr<InfoCommand> machineInfoCommand;
87 
88  struct NameFromCommand {
89  const std::string& operator()(const Command* c) const {
90  return c->getName();
91  }
92  };
94 
95  struct NameFromSetting {
96  const std::string& operator()(const Setting* s) const {
97  return s->getName();
98  }
99  };
101 };
102 
103 } // namespace openmsx
104 
105 #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
void changeSetting(Setting &setting, const TclObject &value) override
TclObject executeCommand(const std::string &command, CliConnection *connection=nullptr) override
Execute the given command.
bool isActive() const
Returns true iff the machine this controller belongs to is currently active.
void unregisterCommand(Command &command, string_ref str) override
const std::string & getName() const
Definition: Completer.hh:17
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)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void registerCompleter(CommandCompleter &completer, string_ref str) override
(Un)register a command completer, used to complete build-in Tcl cmds
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 unregisterCompleter(CommandCompleter &completer, string_ref str) override