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 namespace openmsx {
8 
9 // class CommandCompleter
10 
12  std::string_view name_)
13  : Completer(name_)
14  , commandController(controller_)
15 {
17 }
18 
20 {
22 }
23 
24 // TODO: getCommandController(), getGlobalCommandController() and
25 // getInterpreter() occur both here and in Setting.
26 
28 {
29  if (auto* globalCommandController =
30  dynamic_cast<GlobalCommandController*>(&commandController)) {
31  return *globalCommandController;
32  } else {
33  return checked_cast<MSXCommandController*>(&commandController)
34  ->getGlobalCommandController();
35  }
36 }
37 
39 {
41 }
42 
44 {
46 }
47 
48 // class Command
49 
50 Command::Command(CommandController& controller_, std::string_view name_)
51  : CommandCompleter(controller_, name_)
52  , allowInEmptyMachine(true)
53  , token(nullptr)
54 {
56 }
57 
59 {
61 }
62 
63 void Command::tabCompletion(std::vector<std::string>& /*tokens*/) const
64 {
65  // do nothing
66 }
67 
68 } // namespace openmsx
CliComm & getCliComm() const
Definition: Command.cc:43
CommandCompleter(const CommandCompleter &)=delete
CommandController & getCommandController() const
Definition: Command.hh:25
Interpreter & getInterpreter() const final
Definition: Command.cc:38
GlobalCommandController & getGlobalCommandController() const
Definition: Command.cc:27
virtual void registerCommand(Command &command, zstring_view str)=0
(Un)register a command
virtual void unregisterCommand(Command &command, std::string_view str)=0
virtual void registerCompleter(CommandCompleter &completer, std::string_view str)=0
(Un)register a command completer, used to complete build-in Tcl cmds
virtual CliComm & getCliComm()=0
virtual void unregisterCompleter(CommandCompleter &completer, std::string_view str)=0
virtual Interpreter & getInterpreter()=0
Command(CommandController &controller, std::string_view name)
Definition: Command.cc:50
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
Definition: Command.cc:63
const std::string & getName() const
Definition: Completer.hh:23
This file implemented 3 utility functions:
Definition: Autofire.cc:9