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
Contains the main loop of openMSX.
Definition: Reactor.hh:64
Definition: span.hh:34
std::shared_ptr< const Event > EventPtr
Definition: AfterCommand.hh:20
std::string help(const std::vector< std::string > &tokens) const override
Print help for this command.
void execute(span< const TclObject > tokens, TclObject &result) override
Execute this command.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
AfterCommand(Reactor &reactor, EventDistributor &eventDistributor, CommandController &commandController)
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.