10 Macro(
const std::vector<Action> &actionVector,
11 const std::function<
bool()> &activateEvent,
12 const std::function<std::weak_ptr<Macro>()> &decider)
13 : actionVector(actionVector), activateEvent(activateEvent),
22 return decider ? decider().lock() :
nullptr;
25 std::optional<std::array<uint8_t, 8>>
getDataframe(uint64_t time)
const {
26 if (actionVector.size() == 0 || time >= actionVector.back().time) {
30 Action searchAction = {time, {}};
32 return a.
time < b.time;
35 auto res = std::upper_bound(actionVector.begin(), actionVector.end(),
36 searchAction, predicate);
40 bool active()
const {
return activateEvent ? activateEvent() :
false; }
43 std::vector<Action> actionVector;
44 std::function<bool()> activateEvent;
45 std::function<std::weak_ptr<Macro>()> decider;
std::shared_ptr< Macro > getNextMacro() const
Definition: Macro.h:21
Macro(const Macro &other)=delete
Macro(const std::vector< Action > &actionVector, const std::function< bool()> &activateEvent, const std::function< std::weak_ptr< Macro >()> &decider)
Definition: Macro.h:10
bool active() const
Definition: Macro.h:40
std::optional< std::array< uint8_t, 8 > > getDataframe(uint64_t time) const
Definition: Macro.h:25
Macro()
Definition: Macro.h:9
Macro & operator=(Macro &&other)=default
Macro(Macro &&other)=default
uint64_t time
Definition: Action.h:7