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  [[nodiscard]] 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) noexcept override;
48 
49 private:
50  using AfterCmds = std::vector<std::unique_ptr<AfterCmd>>;
51  AfterCmds afterCmds;
52  Reactor& reactor;
53  EventDistributor& eventDistributor;
54 
55  friend class AfterCmd;
56  friend class AfterTimedCmd;
57  friend class AfterRealTimeCmd;
58 };
59 
60 } // namespace openmsx
61 
62 #endif
std::shared_ptr< const Event > EventPtr
Definition: AfterCommand.hh:20
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.
std::string help(const std::vector< std::string > &tokens) const override
Print help for this command.
Contains the main loop of openMSX.
Definition: Reactor.hh:67
Definition: span.hh:126
This file implemented 3 utility functions:
Definition: Autofire.cc:5