Chrysalis - Hooks
Toggle main menu visibility
Loading...
Searching...
No Matches
HookHandle.h
Go to the documentation of this file.
1
#ifndef CHRYSALIS_HOOKHANDLE_H
2
#define CHRYSALIS_HOOKHANDLE_H
3
4
#include <list>
5
#include <functional>
6
7
#include "
HooksLibraryExport.h
"
8
9
// =============================================================================
10
// HookHandle
11
// Must be defined before hook_detail so the Before/After/Replace std::function
12
// signatures that reference it can be fully formed.
13
//
14
// Returned to the caller when registering a before/after/replace callback.
15
// Calling remove() schedules the callback for deletion on the next hook
16
// invocation — deletion is deferred so it is safe to call remove() from
17
// inside the callback itself without invalidating the iterator mid-loop.
18
// =============================================================================
19
class
HOOKS
HookHandle {
20
friend
class
HooksManager
;
21
explicit
HookHandle(std::list<std::function<
void
()>>& executeLater, std::function<
void
()> remover);
22
public
:
23
// Schedule this callback for removal. Safe to call from inside the callback.
24
void
remove
()
const
;
25
private
:
26
// Raw pointer is intentional: the list is an instance member of HookBase
27
// and outlives every HookHandle created during a single hook invocation.
28
std::list<std::function<void()>>* executeLater_;
29
std::function<void()> remover_;
30
};
31
32
#endif
// CHRYSALIS_HOOKHANDLE_H
HooksLibraryExport.h
HOOKS
#define HOOKS
Definition
HooksLibraryExport.h:11
HookHandle::HooksManager
friend class HooksManager
Definition
HookHandle.h:20
HookHandle::remove
void remove() const
Definition
HookHandle.cpp:6
integrations
hooks
include
HookHandle.h
Generated by
1.17.0