273ff07a00
App now adds already constructed Timers Timer is now an Invoker that takes a weak_ptr to a steppable with a request()rather than a bool callback. should eventually be changed to composition
20 lines
333 B
C++
20 lines
333 B
C++
#ifndef INVOKER_HPP
|
|
#define INVOKER_HPP
|
|
|
|
#include "steppable.hpp"
|
|
#include <memory>
|
|
class Invoker {
|
|
public:
|
|
virtual ~Invoker() = default;
|
|
std::weak_ptr<Steppable> target;
|
|
|
|
void set_target(std::shared_ptr<Steppable> t) { target = t; }
|
|
void request() {
|
|
if (auto sp = target.lock()) {
|
|
sp->step();
|
|
}
|
|
}
|
|
};
|
|
|
|
#endif
|