17 #include <core/utils.h> 34 using Action = std::function<void(float)>;
36 static constexpr
float kStartTimestamp = -1;
37 static constexpr
float kInvalidTimestamp = -2;
40 void record(
float t,
const Action& action) {
41 CHECK(timestamp_ == kInvalidTimestamp);
42 actions_.emplace(t, action);
46 current_action_ = actions_.begin();
47 timestamp_ = kStartTimestamp;
51 CHECK(timestamp_ != kInvalidTimestamp);
52 CHECK(t > timestamp_);
53 while (current_action_ != actions_.end() && current_action_->first <= t) {
54 current_action_->second(t);
62 current_action_ = actions_.end();
63 timestamp_ = kInvalidTimestamp;
67 multimap<float, Action> actions_;
68 multimap<float, Action>::const_iterator current_action_;
69 float timestamp_ = kInvalidTimestamp;
Basic action scripting.
Definition: script.h:33
Definition: accelerometer.cpp:19