-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.h
More file actions
71 lines (56 loc) · 1.54 KB
/
event.h
File metadata and controls
71 lines (56 loc) · 1.54 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <iostream>
#include <queue>
#include "database.h"
#include "Poco/BasicEvent.h"
#include "Poco/Delegate.h"
#include "Poco/Mutex.h"
#include "Poco/Thread.h"
class BaseEvent
{
public:
virtual ~BaseEvent() = default;
std::string event_name;
};
class ParkingLotIn_DBEvent : public BaseEvent
{
public:
Database::parking_lot_t park_lot_event_in_data_;
ParkingLotIn_DBEvent(const Database::parking_lot_t& data)
: park_lot_event_in_data_(data)
{
event_name = "ParkingLotIn_DBEvent";
}
};
class ParkingLotOut_DBEvent : public BaseEvent
{
public:
Database::parking_lot_t park_lot_event_out_data_;
ParkingLotOut_DBEvent(const Database::parking_lot_t& data)
: park_lot_event_out_data_(data)
{
event_name = "ParkingLotOut_DBEvent";
}
};
class EventManager : public Poco::Runnable
{
public:
virtual void run();
static EventManager* getInstance();
void FnStartEventThread();
void FnStopEventThread();
void FnEnqueueEvent(BaseEvent* event);
EventManager(EventManager& eventManager) = delete;
void operator=(const EventManager&) = delete;
private:
static EventManager* eventManager_;
static Poco::Mutex singletonEventMutex_;
std::queue<BaseEvent*> eventQueue_;
Poco::Mutex queueMutex_;
Poco::Thread eventThread_;
bool stopThread_;
EventManager();
void processEventFromQueue();
void handleParkInEvent(const Database::parking_lot_t& parkInInfo);
void handleParkOutEvent(const Database::parking_lot_t& parkOutInfo);
};