Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
timer.hpp
Go to the documentation of this file.
1/*
2 Copyright 2021 natinusala
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#pragma once
18
19#include <aurore/core/time.hpp>
20
21namespace aurore
22{
23
24// A Timer allows to run a callback once after a given period of time, in ms
25// Add the callback with setEndCallback(), set the duration with setDuration() then start the timer
26class Timer : public FiniteTicking
27{
28 public:
33
37 void start();
38
44
45 void onStart() override;
46 bool onUpdate(Time delta) override;
47 void onReset() override;
48 void onRewind() override;
49
50 protected:
53};
54
55// A RepeatingTimer allows to run a callback repeatedly at a given time interval, in ms
56// Add the callback with setCallback(), set the period with setPeriod() then start the timer
57class RepeatingTimer : public Ticking
58{
59 public:
64
68 void start();
69
75
82
83 void onStart() override;
84 bool onUpdate(Time delta) override;
85
86 protected:
89
91};
92
93} // namespace aurore
Definition time.hpp:205
Definition timer.hpp:58
void onStart() override
TickingGenericCallback callback
Definition timer.hpp:90
Time progress
Definition timer.hpp:88
void start(Time period)
void setCallback(TickingGenericCallback callback)
void setPeriod(Time period)
bool onUpdate(Time delta) override
Time period
Definition timer.hpp:87
Definition time.hpp:125
Definition timer.hpp:27
void setDuration(Time duration)
Time duration
Definition timer.hpp:51
void onReset() override
bool onUpdate(Time delta) override
void start(Time duration)
Time progress
Definition timer.hpp:52
void onStart() override
void onRewind() override
Definition actions.hpp:25
std::function< void()> TickingGenericCallback
Definition time.hpp:115
retro_time_t Time
Definition time.hpp:31