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  private noncopyable
20 {
21 public:
22  MSXCommandController(GlobalCommandController& globalCommandController,
23  Reactor& reactor, MSXMotherBoard& motherboard,
24  MSXEventDistributor& msxEventDistributor,
25  const std::string& machineID);
27 
29  return globalCommandController;
30  }
32  return *machineInfoCommand;
33  }
35  return motherboard;
36  }
37 
38  Command* findCommand(string_ref name) const;
39 
43  bool isActive() const;
44 
47  void transferSettings(const MSXCommandController& from);
48 
49  // CommandController
50  virtual void registerCompleter(CommandCompleter& completer,
51  string_ref str);
52  virtual void unregisterCompleter(CommandCompleter& completer,
53  string_ref str);
54  virtual void registerCommand(Command& command,
55  const std::string& str);
56  virtual void unregisterCommand(Command& command,
57  string_ref str);
58  virtual bool hasCommand(string_ref command) const;
59  virtual std::string executeCommand(const std::string& command,
60  CliConnection* connection = nullptr);
61  virtual std::vector<std::string> splitList(const std::string& list);
62  virtual void registerSetting(Setting& setting);
63  virtual void unregisterSetting(Setting& setting);
64  virtual BaseSetting* findSetting(string_ref name);
65  virtual void changeSetting(Setting& setting, const std::string& value);
66  virtual CliComm& getCliComm();
67  virtual Interpreter& getInterpreter();
68 
69  const BaseSetting* findSetting(string_ref setting) const;
70 
71 private:
72  std::string getFullName(string_ref name);
73 
74  // MSXEventListener
75  virtual void signalEvent(const std::shared_ptr<const Event>& event,
76  EmuTime::param time);
77 
78  GlobalCommandController& globalCommandController;
79  Reactor& reactor;
80  MSXMotherBoard& motherboard;
81  MSXEventDistributor& msxEventDistributor;
82  const std::string& machineID;
83  std::unique_ptr<InfoCommand> machineInfoCommand;
84 
85  StringMap<Command*> commandMap;
86  StringMap<Setting*> settingMap;
87 };
88 
89 } // namespace openmsx
90 
91 #endif
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
virtual BaseSetting * findSetting(string_ref name)
bool isActive() const
Returns true iff the machine this controller belongs to is currently active.
virtual bool hasCommand(string_ref command) const
Does a command with this name already exist?
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
virtual std::vector< std::string > splitList(const std::string &list)
virtual void registerCompleter(CommandCompleter &completer, string_ref str)
(Un)register a command completer, used to complete build-in Tcl cmds
MSXCommandController(GlobalCommandController &globalCommandController, Reactor &reactor, MSXMotherBoard &motherboard, MSXEventDistributor &msxEventDistributor, const std::string &machineID)
virtual void registerCommand(Command &command, const std::string &str)
(Un)register a command
virtual void unregisterCompleter(CommandCompleter &completer, string_ref str)
virtual Interpreter & getInterpreter()
virtual void unregisterCommand(Command &command, string_ref str)
virtual void unregisterSetting(Setting &setting)
virtual std::string executeCommand(const std::string &command, CliConnection *connection=nullptr)
Execute the given command.
MSXMotherBoard & getMSXMotherBoard() const
Based on boost::noncopyable, see boost documentation: http://www.boost.org/libs/utility.
Definition: noncopyable.hh:12
virtual void registerSetting(Setting &setting)
TODO.
virtual void changeSetting(Setting &setting, const std::string &value)