blob: 8b0d7e2db09300ee26a337eb0a062e8a838e62b7 (
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
|
#ifndef hook_manager_hh_INCLUDED
#define hook_manager_hh_INCLUDED
#include "id_map.hh"
#include "utils.hh"
#include <unordered_map>
namespace Kakoune
{
class Context;
typedef std::function<void (const String&, Context&)> HookFunc;
class HookManager
{
public:
HookManager(HookManager& parent) : m_parent(&parent) {}
void add_hook(const String& hook_name, String id, HookFunc hook);
void remove_hooks(const String& id);
void run_hook(const String& hook_name, const String& param,
Context& context) const;
private:
HookManager()
: m_parent(nullptr) {}
// the only one allowed to construct a root hook manager
friend class GlobalHooks;
HookManager* m_parent;
std::unordered_map<String, id_map<HookFunc>> m_hook;
};
class GlobalHooks : public HookManager,
public Singleton<GlobalHooks>
{
};
}
#endif // hook_manager_hh_INCLUDED
|