include/entropic/core/hook_registry.h¶
include/entropic/core/hook_registry.h
entropic::HookEntry
A single registered hook entry.
entropic_hook_callback_t entropic::HookEntry::callback
Function pointer.
void* entropic::HookEntry::user_data
Opaque consumer data.
int entropic::HookEntry::priority
Execution order (ascending)
entropic::HookRegistry
Thread-safe hook registration and dispatch.
entropic_error_t entropic::HookRegistry::register_hook(entropic_hook_point_t point, entropic_hook_callback_t callback, void *user_data, int priority)
Register a hook callback at a hook point.
- Parameters
point— Hook point enum value.callback— Function pointer.user_data— Opaque consumer data.priority— Execution order (0 = first, ascending).point— Hook point.user_data— Opaque pointer.priority— Execution order (ascending).
- Returns
- ENTROPIC_OK or ENTROPIC_ERROR_INVALID_CONFIG.
- threadsafety
- Write-locks the hook point's mutex.
entropic_error_t entropic::HookRegistry::deregister_hook(entropic_hook_point_t point, entropic_hook_callback_t callback, void *user_data)
Deregister a hook callback.
Matches on (point, callback, user_data) triple. Idempotent — returns ENTROPIC_OK if no match found.
- Parameters
point— Hook point.callback— Callback to remove.user_data— user_data from registration.callback— Callback to match.user_data— user_data to match.
- Returns
- ENTROPIC_OK or ENTROPIC_ERROR_INVALID_CONFIG.
- ENTROPIC_OK (idempotent).
- threadsafety
- Write-locks the hook point's mutex.
int entropic::HookRegistry::fire_pre(entropic_hook_point_t point, const char *context_json, char **out_json)
Fire pre-hooks.
Fire pre-hooks with modification chaining and cancellation. Returns modified context or cancellation.
- Parameters
point— The hook point.context_json— Input context JSON.out_json— Output: modified JSON (caller frees), or NULL.point— Hook point.out_json— Output: accumulated modified JSON, or NULL.
- Returns
- 0 = proceed, non-zero = cancelled.
- threadsafety
- Read-locks, then dispatches on snapshot.
void entropic::HookRegistry::fire_post(entropic_hook_point_t point, const char *context_json, char **out_json)
Fire post-hooks.
Fire post-hooks with result transformation chaining. Returns transformed result.
- Parameters
point— The hook point.context_json— Input result JSON.out_json— Output: transformed JSON (caller frees), or NULL.point— Hook point.out_json— Output: accumulated transformed JSON, or NULL.
- threadsafety
- Read-locks, then dispatches on snapshot.
void entropic::HookRegistry::fire_info(entropic_hook_point_t point, const char *context_json)
Fire informational hooks (no modify, no cancel).
- Parameters
point— The hook point.context_json— Context JSON.point— Hook point.
- threadsafety
- Read-locks, then dispatches on snapshot.
size_t entropic::HookRegistry::hook_count(entropic_hook_point_t point) const
Get the number of registered hooks for a point.
- Parameters
point— Hook point.
- Returns
- Entry count, or 0 if invalid point.
- Entry count.
- threadsafety
- Read-locks the hook point's mutex.