forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification_emitter.h
More file actions
38 lines (28 loc) · 1.02 KB
/
Copy pathnotification_emitter.h
File metadata and controls
38 lines (28 loc) · 1.02 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
#ifndef SRC_INSPECTOR_NOTIFICATION_EMITTER_H_
#define SRC_INSPECTOR_NOTIFICATION_EMITTER_H_
#include <string>
#include <unordered_map>
#include "v8.h"
namespace node {
namespace inspector {
class NotificationEmitter {
public:
using EventKey = std::string;
using EventNotifier =
std::function<void(v8::Local<v8::Context>, v8::Local<v8::Object>)>;
NotificationEmitter();
virtual ~NotificationEmitter() = default;
void emitNotification(v8::Local<v8::Context> context,
const EventKey& event,
v8::Local<v8::Object> params);
virtual bool canEmit(const std::string& domain) = 0;
NotificationEmitter(const NotificationEmitter&) = delete;
NotificationEmitter& operator=(const NotificationEmitter&) = delete;
protected:
void addEventNotifier(const EventKey& event, EventNotifier notifier);
private:
std::unordered_map<EventKey, EventNotifier> event_notifier_map_ = {};
};
} // namespace inspector
} // namespace node
#endif // SRC_INSPECTOR_NOTIFICATION_EMITTER_H_