9 std::vector<std::shared_ptr<Macro>> macros;
10 std::map<std::shared_ptr<Macro>, std::chrono::steady_clock::time_point>
20 std::array<uint8_t, 8>
22 const std::function<std::array<uint8_t, 8>(std::array<uint8_t, 8>,
23 std::array<uint8_t, 8>)>
26 std::array<uint8_t, 8> res = intitial;
27 if (activeMacros.size()) {
28 auto now = std::chrono::steady_clock::now();
29 std::vector<std::shared_ptr<Macro>> toAdd;
30 std::vector<std::shared_ptr<Macro>> toRemove;
32 for (
auto it : activeMacros) {
33 auto diff = now - it.second;
34 uint64_t time =
static_cast<uint64_t
>(
35 std::chrono::duration_cast<std::chrono::milliseconds>(diff)
37 if (
auto data = it.first->getDataframe(time)) {
38 res = mergeFunction(res, data.value());
40 toAdd.push_back(it.first->getNextMacro());
41 toRemove.push_back(it.first);
45 for (
auto m : toRemove)
46 activeMacros.erase(m);
50 activeMacros.insert({m, std::chrono::steady_clock::now()});
55 for (
auto m : macros) {
56 if (activeMacros.find(m) == activeMacros.end() && m->active()) {
57 activeMacros.insert({m, std::chrono::steady_clock::now()});
64 macros.push_back(macro);
Definition: MacroCollection.h:7
bool isMacroActive() const
Definition: MacroCollection.h:61
MacroCollection(const MacroCollection &other)=delete
MacroCollection & operator=(MacroCollection &&other)=default
void deactivateMacros()
Definition: MacroCollection.h:62
MacroCollection(const std::vector< std::shared_ptr< Macro > > ¯os)
Definition: MacroCollection.h:14
std::array< uint8_t, 8 > getData(std::array< uint8_t, 8 > intitial, const std::function< std::array< uint8_t, 8 >(std::array< uint8_t, 8 >, std::array< uint8_t, 8 >)> mergeFunction)
Definition: MacroCollection.h:21
void pushBackMacro(std::shared_ptr< Macro > macro)
Definition: MacroCollection.h:63
MacroCollection(MacroCollection &&other)=default
void activateMacros()
Definition: MacroCollection.h:54