blob: 035e448610f35f2a62bce33b4824784b990fb9ed (
plain)
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
|
/*
* Copyright (C) 2015-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "events/IEvent.h"
#include "threads/CriticalSection.h"
#include <map>
#include <string>
#include <vector>
#define NOTIFICATION_DISPLAY_TIME 5000
#define NOTIFICATION_MESSAGE_TIME 1000
typedef std::vector<EventPtr> Events;
class CEventLog
{
public:
CEventLog() = default;
CEventLog(const CEventLog&) = delete;
CEventLog& operator=(CEventLog const&) = delete;
~CEventLog() = default;
Events Get() const;
Events Get(EventLevel level, bool includeHigherLevels = false) const;
EventPtr Get(const std::string& eventIdentifier) const;
void Add(const EventPtr& event);
void Add(const EventPtr& event, bool withNotification, bool withSound = true);
void AddWithNotification(const EventPtr& event,
unsigned int displayTime = NOTIFICATION_DISPLAY_TIME,
unsigned int messageTime = NOTIFICATION_MESSAGE_TIME,
bool withSound = true);
void AddWithNotification(const EventPtr& event, bool withSound);
void Remove(const EventPtr& event);
void Remove(const std::string& eventIdentifier);
void Clear();
void Clear(EventLevel level, bool includeHigherLevels = false);
bool Execute(const std::string& eventIdentifier);
static std::string EventLevelToString(EventLevel level);
static EventLevel EventLevelFromString(const std::string& level);
void ShowFullEventLog(EventLevel level = EventLevel::Basic, bool includeHigherLevels = true);
private:
void SendMessage(const EventPtr& event, int message);
typedef std::vector<EventPtr> EventsList;
typedef std::map<std::string, EventPtr> EventsMap;
EventsList m_events;
EventsMap m_eventsMap;
mutable CCriticalSection m_critical;
};
|