Skip to content

Commit ca7e0c7

Browse files
feat(toolbox): add remove_data_source runtime-host slot; release 0.7.0
Add an optional tail slot remove_data_source(handle) to PJ_toolbox_runtime_host_vtable_t so a toolbox can ask the host to drop a data source it created via create_data_source — its derived topics leave the catalog, enabling a clean reset that leaves no residue. Mirrors the existing notify_data_changed control-plane callback. ABI: slot is tail-appended after notify_data_changed and marked OPTIONAL; hosts may omit it. ToolboxRuntimeHostView::removeDataSource() guards the read with PJ_HAS_TAIL_SLOT (struct_size + nullability), so a new plugin on an older host no-ops, and an older plugin never calls it. ABI-appendable → backward compatible, no recompile needed for existing plugins. toolbox_plugin_test: the runtime-host vtable initializer gains .remove_data_source = nullptr (the test does not exercise it). Release: MINOR bump 0.6.0 -> 0.7.0 (version in conanfile.py and CMakeLists.txt PJ_PACKAGE_VERSION, plus the conanfile docstring example). abi/baseline.abi is unchanged (it moves only on MAJOR); CI's abidiff must confirm additions-only against the existing baseline.
1 parent 90133ad commit ca7e0c7

5 files changed

Lines changed: 25 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ endif()
111111
if(PJ_INSTALL_SDK)
112112
include(CMakePackageConfigHelpers)
113113

114-
set(PJ_PACKAGE_VERSION "0.6.0")
114+
set(PJ_PACKAGE_VERSION "0.7.0")
115115
set(PJ_PACKAGE_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/plotjuggler_sdk)
116116

117117
install(EXPORT plotjuggler_sdkTargets

conanfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
plugin_sdk — umbrella for plugin authors (base + dialog SDK + parser SDK)
77
plugin_host — umbrella for host loaders (data_source/parser/toolbox/dialog)
88
9-
A consuming Conan recipe declares e.g. `plotjuggler_sdk/0.6.0` and then:
9+
A consuming Conan recipe declares e.g. `plotjuggler_sdk/0.7.0` and then:
1010
1111
find_package(plotjuggler_sdk REQUIRED COMPONENTS plugin_sdk)
1212
target_link_libraries(my_plugin PRIVATE plotjuggler_sdk::plugin_sdk)
@@ -30,7 +30,7 @@
3030

3131
class PlotjugglerSdkConan(ConanFile):
3232
name = "plotjuggler_sdk"
33-
version = "0.6.0"
33+
version = "0.7.0"
3434
# Apache-2.0 covers the whole SDK (pj_base + pj_plugins). See LICENSE.
3535
license = "Apache-2.0"
3636
url = "https://github.com/PlotJuggler/plotjuggler_sdk"

pj_base/include/pj_base/sdk/toolbox_plugin_base.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ class ToolboxRuntimeHostView {
5656
}
5757
}
5858

59+
/// Ask the host to remove a data source this toolbox created (its derived
60+
/// topics leave the catalog). No-op on hosts that predate this slot.
61+
void removeDataSource(PJ_data_source_handle_t handle) const {
62+
if (valid() && PJ_HAS_TAIL_SLOT(PJ_toolbox_runtime_host_vtable_t, host_.vtable, remove_data_source)) {
63+
host_.vtable->remove_data_source(host_.ctx, handle);
64+
}
65+
}
66+
5967
[[nodiscard]] const PJ_toolbox_runtime_host_t& raw() const {
6068
return host_;
6169
}

pj_base/include/pj_base/toolbox_protocol.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ typedef struct PJ_toolbox_runtime_host_vtable_t {
7474

7575
/** [thread-safe] Notify the host that data has been modified; host refreshes UI. */
7676
void (*notify_data_changed)(void* ctx) PJ_NOEXCEPT;
77+
78+
/* ====================================================================
79+
* Tail slots beyond here are OPTIONAL (added after v4.0). Plugins MUST
80+
* guard reads via PJ_HAS_TAIL_SLOT(struct_size + nullability).
81+
* ==================================================================== */
82+
83+
/** [thread-safe] Remove a data source the toolbox previously created via the
84+
* write host's create_data_source, so its derived topics disappear from the
85+
* host catalog — a clean reset that leaves no residue. The host tombstones
86+
* the data source's topics; cached reader handles are not invalidated.
87+
* Optional tail slot: hosts may omit it, so plugins guard with
88+
* PJ_HAS_TAIL_SLOT(PJ_toolbox_runtime_host_vtable_t, vtable, remove_data_source). */
89+
void (*remove_data_source)(void* ctx, PJ_data_source_handle_t handle) PJ_NOEXCEPT;
7790
} PJ_toolbox_runtime_host_vtable_t;
7891

7992
typedef struct {

pj_plugins/tests/toolbox_plugin_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ PJ_toolbox_runtime_host_t makeRuntimeHost(RuntimeState* state) {
103103
.struct_size = sizeof(PJ_toolbox_runtime_host_vtable_t),
104104
.report_message = rhReportMessage,
105105
.notify_data_changed = rhNotifyDataChanged,
106+
.remove_data_source = nullptr,
106107
};
107108
return PJ_toolbox_runtime_host_t{.ctx = state, .vtable = &vtable};
108109
}

0 commit comments

Comments
 (0)