OXYGENHUB
◆ main openmsx / src / events / AfterCommand.hh
1.8 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef AFTERCOMMAND_HH
2
#define AFTERCOMMAND_HH
3
4
#include "Event.hh"
5
#include "EventListener.hh"
6
7
#include "Command.hh"
8
9
#include <concepts>
10
#include <vector>
11
12
namespace openmsx {
13
14
class Reactor;
15
class EventDistributor;
16
class CommandController;
17
18
class AfterCommand final : public Command, private EventListener
19
{
20
public:
21
	using Index = uint32_t; // ObjectPool<T>::Index
22
23
public:
24
	AfterCommand(Reactor& reactor,
25
	             EventDistributor& eventDistributor,
26
	             CommandController& commandController);
27
	~AfterCommand();
28
29
	void execute(std::span<const TclObject> tokens, TclObject& result) override;
30
	[[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
31
	void tabCompletion(std::vector<std::string>& tokens) const override;
32
33
private:
34
	void executeMatches(std::predicate<Index> auto pred);
35
	void executeSimpleEvents(EventType type);
36
	void afterSimpleEvent(std::span<const TclObject> tokens, TclObject& result, EventType type);
37
	void afterInputEvent(Event event,
38
	                   std::span<const TclObject> tokens, TclObject& result);
39
	void afterTclTime (int ms,
40
	                   std::span<const TclObject> tokens, TclObject& result);
41
	void afterTime    (std::span<const TclObject> tokens, TclObject& result);
42
	void afterRealTime(std::span<const TclObject> tokens, TclObject& result);
43
	void afterIdle    (std::span<const TclObject> tokens, TclObject& result);
44
	void afterInfo    (std::span<const TclObject> tokens, TclObject& result) const;
45
	void afterCancel  (std::span<const TclObject> tokens, TclObject& result);
46
47
	// EventListener
48
	bool signalEvent(const Event& event) override;
49
50
private:
51
	std::vector<Index> 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