forked from zeek/zeek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventRegistry.h
48 lines (36 loc) · 1.17 KB
/
EventRegistry.h
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
// Each event raised/handled by Bro is registered in the EventRegistry.
#ifndef EVENT_REGISTRY
#define EVENT_REGISTRY
#include "Func.h"
#include "List.h"
#include "Dict.h"
#include "EventHandler.h"
// The registry keeps track of all events that we provide or handle.
class EventRegistry {
public:
EventRegistry() { }
~EventRegistry() { }
void Register(EventHandlerPtr handler);
// Return nil if unknown.
EventHandler* Lookup(const char* name);
// Returns a list of all local handlers that match the given pattern.
// Passes ownership of list.
typedef const char constchar; // PList doesn't like "const char"
declare(PList, constchar);
typedef PList(constchar) string_list;
string_list* Match(RE_Matcher* pattern);
// Marks a handler as handling errors. Error handler will not be called
// recursively to avoid infinite loops in case they trigger an error
// themselves.
void SetErrorHandler(const char* name);
string_list* UnusedHandlers();
string_list* UsedHandlers();
string_list* AllHandlers();
void PrintDebug();
private:
declare(PDict, EventHandler);
typedef PDict(EventHandler) handler_map;
handler_map handlers;
};
extern EventRegistry* event_registry;
#endif