1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include "Service/Service.hpp"
#include <module-db/queries/calendar/QueryEventsEdit.hpp>
#include <module-sys/Service/Timer.hpp>
namespace stm
{
class TimeEvents
{
private:
bool timersProcessingStarted = false;
std::unique_ptr<sys::Timer> fireEventTimer = nullptr;
sys::Service *serv = nullptr;
std::unique_ptr<sys::Timer> &timer();
protected:
sys::Service *service()
{
return serv;
};
virtual const std::string timerName() = 0;
void stopTimer();
void recreateTimer(uint32_t interval);
virtual void fireEventTimerCallback();
virtual uint32_t calcToNextEventInterval(std::unique_ptr<db::QueryResult> nextEventQueryResult) = 0;
virtual bool sendNextEventQuery() = 0;
virtual bool sendEventFiredQuery() = 0;
virtual void invokeEvent(){};
public:
TimeEvents() = delete;
TimeEvents(sys::Service *service);
~TimeEvents();
/// startProcessing - starts processing of events
void startProcessing();
/// stopProcessing - stops processing of events
void stopProcessing();
/// isStarted - returns events' processing state
bool isStarted()
{
return timersProcessingStarted;
};
/// processNextEvent - starts next event query
void processNextEvent();
/// receiveNextEventQuery - receives result of next event query
virtual bool receiveNextEventQuery(std::unique_ptr<db::QueryResult> nextEventQueryResult);
};
} // namespace stm