Files
2026-10-05 11:27:21 +02:00

35 lines
605 B
C++

// ======================================================
// Timer.h
//
// A general-purpose countdown timer
// To use this class, specialize it
// and override tick()
//
// ======================================================
#ifndef timer_H
#define timer_H
#include <ctime>
#include <functional>
class Timer {
public:
Timer(std::function<void(void)> action);
void timeoutRequest(int seconds);
// template method
void tick();
protected:
bool isExpired();
private:
std::function<void(void)> doExpired;
int timeToGo;
};
#endif