21 std::string_view name_)
22 :
Command(commandController_, name_)
23 , stateChangeDistributor(stateChangeDistributor_)
24 , scheduler(scheduler_)
25 , currentResultObject(&dummyResultObject)
51[[nodiscard]]
static std::string_view getBaseName(std::string_view str)
53 auto pos = str.rfind(
"::");
54 return (pos == std::string_view::npos) ? str : str.substr(pos + 2);
57void RecordedCommand::signalStateChange(
const StateChange& event)
59 const auto* commandEvent =
dynamic_cast<const MSXCommandEvent*
>(&event);
60 if (!commandEvent)
return;
62 const auto& tokens = commandEvent->getTokens();
63 if (getBaseName(tokens[0].getString()) !=
getName())
return;
66 execute(tokens, *currentResultObject, commandEvent->getTime());
82void RecordedCommand::stopReplay(EmuTime::param )
noexcept
96template<
typename Archive>
99 ar.template serializeBase<StateChange>(*
this);
102 std::vector<std::string> str;
103 if constexpr (!Archive::IS_LOADER) {
105 tokens, [](
auto&
t) {
return std::string(
t.getString()); }));
107 ar.serialize(
"tokens", str);
108 if constexpr (Archive::IS_LOADER) {
109 assert(tokens.empty());
Assign new value to some variable and restore the original value when this object goes out of scope.
const std::string & getName() const
This class is used to for Tcl commands that directly influence the MSX state (e.g.
void serialize(Archive &ar, unsigned version)
MSXCommandEvent()=default
virtual bool needRecord(std::span< const TclObject > tokens) const
It's possible that in some cases the command doesn't need to be recorded after all (e....
virtual void execute(std::span< const TclObject > tokens, TclObject &result, EmuTime::param time)=0
This is like the execute() method of the Command class, it only has an extra time parameter.
RecordedCommand(CommandController &commandController, StateChangeDistributor &stateChangeDistributor, Scheduler &scheduler, std::string_view name)
EmuTime::param getCurrentTime() const
Get the current scheduler time.
void registerListener(StateChangeListener &listener)
(Un)registers the given object to receive state change events.
void distributeNew(EmuTime::param time, Args &&...args)
Deliver the event to all registered listeners MSX input devices should call the distributeNew() versi...
void unregisterListener(StateChangeListener &listener)
Base class for all external MSX state changing events.
This file implemented 3 utility functions:
constexpr auto transform(Range &&range, UnaryOp op)
auto to_vector(Range &&range) -> std::vector< detail::ToVectorType< T, decltype(std::begin(range))> >