feat(sdk): add on_data_changed hook to toolbox vtable#63
Merged
Conversation
Mirrors the on_time_changed SDK hook pattern for data-change events: - PJ_toolbox_vtable_t gains a new slot on_data_changed(void* ctx) at the end of the struct. - ToolboxPluginBase exposes a virtual onDataChanged() with a no-op default; subclasses override it to react to appended data (e.g., recompute a transform on only the newly committed points). - trampoline_on_data_changed catches exceptions across the C ABI boundary. - Host side: ToolboxHandle.onDataChanged() forwards through the vtable when the slot is set; null-check protects older plugins. Opt-in: plugins that don't override the virtual pay no cost; the host never calls the slot for them. Tests and mock_toolbox cover the wiring.
Add a notifyDataChanged counter to MockToolbox and extend toolbox_plugin_test.cpp with cases that exercise the new hook through the C ABI: direct invocation, no-op when plugin doesn't override, and correct forwarding from ToolboxHandle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an optional
on_data_changed(void* ctx)hook at the end ofPJ_toolbox_vtable_t. Mirrors the existingon_time_changedhook pattern for data-change events.What
PJ_toolbox_vtable_tgains a new sloton_data_changedat the end of the struct (opt-in; host NULL-checks before calling).ToolboxPluginBaseexposes a virtualonDataChanged()with a no-op default. Subclasses override it to react to newly appended data (e.g. recompute a transform over just the delta).trampoline_on_data_changedcatches exceptions across the C ABI boundary.ToolboxHandle::onDataChanged()forwards through the vtable; safe no-op when the plugin doesn't set the slot.Opt-in
Plugins that don't override the virtual pay no cost and the host never invokes the slot. Backward compatible with plugins compiled against the prior vtable.
Test plan
toolbox_plugin_testcovers direct invocation through the ABI, no-op path when not overridden, and correct forwarding fromToolboxHandle.pj_plugins/examples/mock_toolbox.cpp) gains aonDataChangedcounter for testing.Downstream
An incoming follow-up on
pj-official-pluginsuses this hook in the Quaternion toolbox to re-apply the RPY transform only over newly appended samples (matching PJ 3.x's reactive behaviour).