2016-05-30 23:58:58 -04:00
|
|
|
#pragma once
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
#include "modules/meta.hpp"
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
LEMONBUDDY_NS
|
|
|
|
|
|
|
|
using namespace drawtypes;
|
|
|
|
|
|
|
|
namespace modules {
|
|
|
|
class counter_module : public timer_module<counter_module> {
|
|
|
|
public:
|
|
|
|
using timer_module::timer_module;
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
m_interval = chrono::duration<double>(m_conf.get<float>(name(), "interval", 1));
|
|
|
|
m_formatter->add(DEFAULT_FORMAT, TAG_COUNTER, {TAG_COUNTER});
|
|
|
|
}
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
bool update() {
|
|
|
|
m_counter++;
|
|
|
|
return true;
|
|
|
|
}
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
bool build(builder* builder, string tag) {
|
|
|
|
if (tag == TAG_COUNTER) {
|
|
|
|
builder->node(to_string(m_counter));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
private:
|
|
|
|
static constexpr auto TAG_COUNTER = "<counter>";
|
|
|
|
|
|
|
|
int m_counter{0};
|
2016-05-19 10:41:06 -04:00
|
|
|
};
|
|
|
|
}
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
LEMONBUDDY_NS_END
|