chore: Add course material
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// ======================================================
|
||||
//
|
||||
// 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
|
||||
Reference in New Issue
Block a user