64#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
90 int64_t
get(uint8_t clock_id)
const {
91 return ( clock_id<
static_cast<uint8_t
>(
CLOCKS_SIZE) ? clocks(clock_id) : -1 );
95 void set(
int clock_id, int64_t value) { set_clocks(value, clock_id); }
98 void reset(
int clock_id) { set_clocks(get_utime(), clock_id); }
101 int64_t
time(
int clock_id) {
return get_utime() - clocks(clock_id); }
104 int64_t
time_ms(
int clock_id) {
return (get_utime() - clocks(clock_id))/1000; }
106#ifdef WHITEBOARD_POSTER_STRING_CONVERSION
113 std::ostringstream ss;
117 ss<< (first ?
"" :
",") << i <<
"=" << clocks(i) ;
127 std::vector<std::string> msg;
128 std::vector<std::string> kv;
129 std::vector<std::string>::const_iterator it;
131 msg = components_of_string_separated(str,
',',
true);
132 for (it = msg.begin(); it!=msg.end(); ++it) {
133 kv = components_of_string_separated(*it,
'=',
true);
135 set_clocks(atoll(kv[1].c_str()), atoi(kv[0].c_str()));
Class for working with timing and clock messages.
void reset(int clock_id)
reset a clock counter to the current time
int64_t get(uint8_t clock_id) const
clock counter getter
int64_t time_ms(int clock_id)
time since last reset in ms
void set(int clock_id, int64_t value)
clock counter setter
Clocks(const std::string &state)
string constructor
void from_string(const std::string &str)
convert from a string
int64_t time(int clock_id)
get the current time since last reset of a given clock
std::string description() const
convert to a string
#define CLOCKS_SIZE
clocks available
#define VALID_KEYVALUE(v)