2016-05-31 03:58:58 +00:00
|
|
|
#pragma once
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
#include "modules/meta.hpp"
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00: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 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
bool update() {
|
|
|
|
m_counter++;
|
|
|
|
return true;
|
|
|
|
}
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-10-18 23:26:17 +00:00
|
|
|
bool build(builder* builder, string tag) const {
|
2016-06-15 03:32:35 +00:00
|
|
|
if (tag == TAG_COUNTER) {
|
|
|
|
builder->node(to_string(m_counter));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-19 14:41:06 +00:00
|
|
|
|
2016-06-15 03:32:35 +00:00
|
|
|
private:
|
|
|
|
static constexpr auto TAG_COUNTER = "<counter>";
|
|
|
|
|
|
|
|
int m_counter{0};
|
2016-05-19 14:41:06 +00:00
|
|
|
};
|
|
|
|
}
|
2016-06-15 03:32:35 +00:00
|
|
|
|
|
|
|
LEMONBUDDY_NS_END
|