1 #ifndef VTESTBED_GUI_TESTBEDPIPELINE_HH 2 #define VTESTBED_GUI_TESTBEDPIPELINE_HH 9 #include <vtestbed/core/testbed.hh> 10 #include <vtestbed/gui/types.hh> 23 using time_point = clock_type::time_point;
24 using duration = clock_type::duration;
29 using Record =
typename statistics_type::Record;
37 enum class state_type {initial, started, stopped};
47 T _min_time_step{T{1} / T{60}};
48 T _max_time_step{T{1} / T{5}};
61 inline void stop() { this->_state = state_type::stopped; }
66 if (this->_thread.joinable()) {
71 inline bool initial()
const {
return this->_state == state_type::initial; }
72 inline bool stopped()
const {
return this->_state == state_type::stopped; }
73 inline bool started()
const {
return this->_state == state_type::started; }
78 inline testbed_type* testbed() {
return &this->_testbed; }
80 inline T min_time_step()
const {
return this->_min_time_step; }
81 inline void min_time_step(T rhs) { this->_min_time_step = rhs; }
82 inline T max_time_step()
const {
return this->_max_time_step; }
83 inline void max_time_step(T rhs) { this->_max_time_step = rhs; }
84 inline T speed()
const {
return this->_speed; }
85 inline void speed(T rhs) { this->_speed = rhs; }
86 inline T time_step()
const {
return this->_dt_accumulator; }
87 inline void fixed_time_step(
bool rhs) { this->_fixed_time_step = rhs; }
88 inline bool fixed_time_step()
const {
return this->_fixed_time_step; }
92 auto len = time_step();
93 return len == T{} ? T{0} : (T{1} / len);
100 const T w2 = T{1} - w1;
101 _dt_accumulator = w1*dt + w2*_dt_accumulator;
114 template <
class Callback>
118 this->_callbacks.emplace_back(std::move(cb));
130 template <
class Callback>
133 this->_gui_callbacks.emplace_back(std::move(cb));
136 void do_gui_callbacks();
149 #endif // vim:filetype=cpp
void call(Callback &&cb)
Insert computational callback.
void gui_call(Callback &&cb)
Insert computational and graphical callbacks.
Main class for interacting with virtual testbed via GUI.
void accumulate_dt(T dt)
Accumulate FPS using exponential moving average.