openMSX
AfterCommand.hh
Go to the documentation of this file.
1 #ifndef AFTERCOMMAND_HH
2 #define AFTERCOMMAND_HH
3 
4 #include "Command.hh"
5 #include "EventListener.hh"
6 #include "Event.hh"
7 #include <memory>
8 #include <vector>
9 
10 namespace openmsx {
11 
12 class Reactor;
13 class EventDistributor;
14 class CommandController;
15 class AfterCmd;
16 
17 class AfterCommand final : public Command, private EventListener
18 {
19 public:
20  using EventPtr = std::shared_ptr<const Event>;
21 
22  AfterCommand(Reactor& reactor,
23  EventDistributor& eventDistributor,
24  CommandController& commandController);
25  ~AfterCommand();
26 
27  void execute(span<const TclObject> tokens, TclObject& result) override;
28  std::string help(const std::vector<std::string>& tokens) const override;
29  void tabCompletion(std::vector<std::string>& tokens) const override;
30 
31 private:
32  template<typename PRED> void executeMatches(PRED pred);
33  template<EventType T> void executeEvents();
34  template<EventType T> void afterEvent(
35  span<const TclObject> tokens, TclObject& result);
36  void afterInputEvent(const EventPtr& event,
37  span<const TclObject> tokens, TclObject& result);
38  void afterTclTime (int ms,
39  span<const TclObject> tokens, TclObject& result);
40  void afterTime (span<const TclObject> tokens, TclObject& result);
41  void afterRealTime(span<const TclObject> tokens, TclObject& result);
42  void afterIdle (span<const TclObject> tokens, TclObject& result);
43  void afterInfo (span<const TclObject> tokens, TclObject& result);
44  void afterCancel (span<const TclObject> tokens, TclObject& result);
45 
46  // EventListener
47  int signalEvent(const std::shared_ptr<const Event>& event) override;
48 
49  using AfterCmds = std::vector<std::unique_ptr<AfterCmd>>;
50  AfterCmds afterCmds;
51  Reactor& reactor;
52  EventDistributor& eventDistributor;
53 
54  friend class AfterCmd;
55  friend class AfterTimedCmd;
56  friend class AfterRealTimeCmd;
57 };
58 
59 } // namespace openmsx
60 
61 #endif
openmsx::CommandController
Definition: CommandController.hh:18
EventListener.hh
openmsx::AfterCommand::AfterCommand
AfterCommand(Reactor &reactor, EventDistributor &eventDistributor, CommandController &commandController)
Definition: AfterCommand.cc:119
openmsx::EventDistributor
Definition: EventDistributor.hh:17
span
Definition: span.hh:126
openmsx::Reactor
Contains the main loop of openMSX.
Definition: Reactor.hh:67
openmsx::AfterCommand::~AfterCommand
~AfterCommand()
Definition: AfterCommand.cc:162
openmsx::AfterCommand::EventPtr
std::shared_ptr< const Event > EventPtr
Definition: AfterCommand.hh:20
openmsx::AfterCommand
Definition: AfterCommand.hh:18
openmsx::EventListener
Definition: EventListener.hh:11
openmsx::AfterRealTimeCmd
Definition: AfterCommand.cc:108
openmsx::AfterTimedCmd
Definition: AfterCommand.cc:49
Command.hh
openmsx::Command
Definition: Command.hh:41
openmsx::AfterCommand::tabCompletion
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
Definition: AfterCommand.cc:372
Event.hh
openmsx::TclObject
Definition: TclObject.hh:22
openmsx::AfterCmd
Definition: AfterCommand.cc:30
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::AfterCommand::execute
void execute(span< const TclObject > tokens, TclObject &result) override
Execute this command.
Definition: AfterCommand.cc:198
openmsx::AfterCommand::help
std::string help(const std::vector< std::string > &tokens) const override
Print help for this command.
Definition: AfterCommand.cc:359