diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-01-19 22:52:52 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-01-21 13:34:12 -0800 |
commit | 6d6619cc5f4f04710dd7dfccce713385924b3b06 (patch) | |
tree | 3012928a23a09910d0439ab51f90920282e62463 /src/til_stream.h | |
parent | 9c5d17309be237f799105e252a26e2c32c2d9c50 (diff) |
til_stream: introduce til_stream_hooks_t et al
There needs to be a way for a meta module like rocket to take
ownership of pipes immediately upon instantiation. Since the
pipes are created on demand as they become tapped by the modules
using htem, the simplest way to do this is to register some
callbacks with the ability to intercept the pipe creation in
terms of ownership and driving tap control etc.
This commit forms a minimal implementation of that, with the
ability to have a single intercepter hooked into a given stream.
It's a first-come-first-served situation, but that should suffice
for now since the rocket meta module would be the entrypoint for
such constructions. It then calls into another module to produce
on the stream, after it'll already have its hooks registered.
There might be a need for stacking hooks to let multiple modules
control pipes. GNU Rocket for instance only deals with
floats/doubles, and doesn't make it particularly easy to work on
higher order concepts like say orbiting a vector around a point
spatially. It might make sense to allow compositing of editors
where there's rocket controlling the simple floats, and another
doing dimensional/spatial stuff, with separate stacked meta
modules accomodating those editors. But that's putting the cart
before the horse, let's do the stupid simple thing for now and
see what this is like.
Diffstat (limited to 'src/til_stream.h')
-rw-r--r-- | src/til_stream.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/til_stream.h b/src/til_stream.h index 3e83c7d..3f0a618 100644 --- a/src/til_stream.h +++ b/src/til_stream.h @@ -32,8 +32,19 @@ typedef struct til_tap_t til_tap_t; */ typedef int (til_stream_iter_func_t)(void *context, til_stream_pipe_t *pipe, const void *owner, const void *owner_foo, const til_tap_t *driving_tap); +/* this provides a way to intercept pipe creations/deletions when they occur, + * allowing another module to snipe ownership when they appear and cleanup + * its resources when they disappear. + */ +typedef struct til_stream_hooks_t { + int (*pipe_ctor)(void *context, til_stream_t *stream, const void *owner, const void *owner_foo, const char *parent_path, uint32_t parent_hash, const til_tap_t *tap, const void **res_owner, const void **res_owner_foo, const til_tap_t **res_tap); /* called immediately *before* pipe would be created by tap using these parameters, return <0 on error, 0 on unhandled by hook, 1 on handled with desired owner/owner_foo/tap stored in res_* */ + int (*pipe_dtor)(void *context, til_stream_t *stream, const void *owner, const void *owner_foo, const char *parent_path, const til_tap_t *tap); /* called immediately *after* pipe "destroyed" (withdrawn from stream) */ +} til_stream_hooks_t; + til_stream_t * til_stream_new(void); til_stream_t * til_stream_free(til_stream_t *stream); +int til_stream_set_hooks(til_stream_t *stream, const til_stream_hooks_t *hooks, void *context); +int til_stream_unset_hooks(til_stream_t *stream, const til_stream_hooks_t *hooks); /* bare interface for non-module-context owned taps */ int til_stream_tap(til_stream_t *stream, const void *owner, const void *owner_foo, const char *parent_path, uint32_t parent_hash, const til_tap_t *tap); |