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  std::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)
37  ->getGlobalCommandController();
38  }
39 }
40 
42 {
44 }
45 
47 {
49 }
50 
51 // class Command
52 
53 Command::Command(CommandController& controller_, std::string_view name_)
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
openmsx::Command::Command
Command(CommandController &controller, std::string_view name)
Definition: Command.cc:53
openmsx::CommandController::getInterpreter
virtual Interpreter & getInterpreter()=0
openmsx::CommandController
Definition: CommandController.hh:17
openmsx::CommandController::registerCompleter
virtual void registerCompleter(CommandCompleter &completer, std::string_view str)=0
(Un)register a command completer, used to complete build-in Tcl cmds
openmsx::CommandController::unregisterCommand
virtual void unregisterCommand(Command &command, std::string_view str)=0
CommandController.hh
openmsx::Command::~Command
~Command()
Definition: Command.cc:61
openmsx::CommandCompleter
Definition: Command.hh:19
openmsx::CommandController::getCliComm
virtual CliComm & getCliComm()=0
openmsx::CommandController::unregisterCompleter
virtual void unregisterCompleter(CommandCompleter &completer, std::string_view str)=0
openmsx::CommandCompleter::getCliComm
CliComm & getCliComm() const
Definition: Command.cc:46
openmsx::CommandController::registerCommand
virtual void registerCommand(Command &command, const std::string &str)=0
(Un)register a command
checked_cast.hh
Command.hh
GlobalCommandController.hh
openmsx::Command::tabCompletion
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
Definition: Command.cc:66
openmsx::CliComm
Definition: CliComm.hh:10
MSXCommandController.hh
openmsx::Completer
Definition: Completer.hh:17
openmsx::CommandCompleter::CommandCompleter
CommandCompleter(const CommandCompleter &)=delete
openmsx::CommandCompleter::getGlobalCommandController
GlobalCommandController & getGlobalCommandController() const
Definition: Command.cc:30
openmsx::Interpreter
Definition: Interpreter.hh:16
openmsx::GlobalCommandController
Definition: GlobalCommandController.hh:35
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::CommandCompleter::~CommandCompleter
~CommandCompleter()
Definition: Command.cc:22
openmsx::CommandCompleter::getInterpreter
Interpreter & getInterpreter() const final
Definition: Command.cc:41
openmsx::CommandCompleter::getCommandController
CommandController & getCommandController() const
Definition: Command.hh:25
openmsx::Completer::getName
const std::string & getName() const
Definition: Completer.hh:20