openMSX
Command.cc
Go to the documentation of this file.
1 #include "Command.hh"
2 #include "CommandController.hh"
5 #include "checked_cast.hh"
6 
7 using std::vector;
8 using std::string;
9 
10 namespace openmsx {
11 
12 // class CommandCompleter
13 
15  string_view name_)
16  : Completer(name_)
17  , commandController(controller_)
18 {
20 }
21 
23 {
25 }
26 
27 // TODO: getCommandController(), getGlobalCommandController() and
28 // getInterpreter() occur both here and in Setting.
29 
31 {
32  if (auto globalCommandController =
33  dynamic_cast<GlobalCommandController*>(&commandController)) {
34  return *globalCommandController;
35  } else {
36  return checked_cast<MSXCommandController*>(&commandController)
38  }
39 }
40 
42 {
44 }
45 
47 {
49 }
50 
51 // class Command
52 
54  : CommandCompleter(controller_, name_)
55  , allowInEmptyMachine(true)
56  , token(nullptr)
57 {
59 }
60 
62 {
64 }
65 
66 void Command::tabCompletion(vector<string>& /*tokens*/) const
67 {
68  // do nothing
69 }
70 
71 } // namespace openmsx
GlobalCommandController & getGlobalCommandController() const
Definition: Command.cc:30
virtual void registerCommand(Command &command, const std::string &str)=0
(Un)register a command
CommandCompleter(const CommandCompleter &)=delete
const std::string & getName() const
Definition: Completer.hh:19
virtual void registerCompleter(CommandCompleter &completer, string_view str)=0
(Un)register a command completer, used to complete build-in Tcl cmds
virtual Interpreter & getInterpreter()=0
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
virtual void unregisterCommand(Command &command, string_view str)=0
CommandController & getCommandController() const
Definition: Command.hh:25
Command(CommandController &controller, string_view name)
Definition: Command.cc:53
This class implements a (close approximation) of the std::string_view class.
Definition: string_view.hh:16
Interpreter & getInterpreter() const final
Definition: Command.cc:41
virtual CliComm & getCliComm()=0
CliComm & getCliComm() const
Definition: Command.cc:46
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
Definition: Command.cc:66
virtual void unregisterCompleter(CommandCompleter &completer, string_view str)=0