-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger.h
More file actions
54 lines (39 loc) · 1014 Bytes
/
trigger.h
File metadata and controls
54 lines (39 loc) · 1014 Bytes
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
51
52
53
54
//
// Created by amoncusir on 04/10/23.
//
#ifndef LOGTRIGGER_SRC_TRIGGER_H
#define LOGTRIGGER_SRC_TRIGGER_H
#include "event.h"
#include "ubus.h"
#include <string>
#include <memory>
#include <vector>
#include <cstdint>
#include <ctime>
namespace Logtrigger
{
class TriggerEvent
{
private:
const EventMatcher* m_matcher {};
const char* m_script_path {};
long m_cold_down {-1};
time_t m_next_time {0};
public:
explicit TriggerEvent(EventMatcher* matcher, const char* script_path, int cool_down);
~TriggerEvent();
bool accept(ubus_log_event& event);
void run(ubus_log_event& event);
};
class TriggerHandler
{
private:
std::vector<TriggerEvent*> m_triggers {};
public:
explicit TriggerHandler() = default;
~TriggerHandler();
TriggerHandler& add_event(const Args::TriggerArgs* args);
void process(ubus_log_event& event);
};
}
#endif //LOGTRIGGER_SRC_TRIGGER_H