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 <vector>
8 
9 namespace openmsx {
10 
11 class Reactor;
12 class EventDistributor;
13 class CommandController;
14 
15 class AfterCommand final : public Command, private EventListener
16 {
17 public:
18  using Index = uint32_t; // ObjectPool<T>::Index
19 
20 public:
21  AfterCommand(Reactor& reactor,
22  EventDistributor& eventDistributor,
23  CommandController& commandController);
24  ~AfterCommand();
25 
26  void execute(span<const TclObject> tokens, TclObject& result) override;
27  [[nodiscard]] std::string help(span<const TclObject> tokens) const override;
28  void tabCompletion(std::vector<std::string>& tokens) const override;
29 
30 private:
31  template<typename PRED> void executeMatches(PRED pred);
32  void executeSimpleEvents(EventType type);
33  void afterSimpleEvent(span<const TclObject> tokens, TclObject& result, EventType type);
34  void afterInputEvent(const Event& event,
35  span<const TclObject> tokens, TclObject& result);
36  void afterTclTime (int ms,
37  span<const TclObject> tokens, TclObject& result);
38  void afterTime (span<const TclObject> tokens, TclObject& result);
39  void afterRealTime(span<const TclObject> tokens, TclObject& result);
40  void afterIdle (span<const TclObject> tokens, TclObject& result);
41  void afterInfo (span<const TclObject> tokens, TclObject& result);
42  void afterCancel (span<const TclObject> tokens, TclObject& result);
43 
44  // EventListener
45  int signalEvent(const Event& event) noexcept override;
46 
47 private:
48  std::vector<Index> afterCmds;
49  Reactor& reactor;
50  EventDistributor& eventDistributor;
51 
52  friend class AfterCmd;
53  friend class AfterTimedCmd;
54  friend class AfterRealTimeCmd;
55 };
56 
57 } // namespace openmsx
58 
59 #endif
std::string help(span< const TclObject > tokens) const override
Print help for this command.
void execute(span< const TclObject > tokens, TclObject &result) override
Execute this command.
AfterCommand(Reactor &reactor, EventDistributor &eventDistributor, CommandController &commandController)
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
Contains the main loop of openMSX.
Definition: Reactor.hh:68
Definition: span.hh:126
This file implemented 3 utility functions:
Definition: Autofire.cc:9
EventType
Definition: Event.hh:507