Skip to content

feat(sdk): early runtime host binding for dialog + listAvailableEncodings vector helper#28

Merged
pabloinigoblasco merged 1 commit into
developmentfrom
feat/two-phase-runtime-host-binding
Apr 3, 2026
Merged

feat(sdk): early runtime host binding for dialog + listAvailableEncodings vector helper#28
pabloinigoblasco merged 1 commit into
developmentfrom
feat/two-phase-runtime-host-binding

Conversation

@pabloinigoblasco
Copy link
Copy Markdown
Collaborator

Summary

Enable plugins to query available encodings before the dialog is shown by introducing a two-phase runtime host binding pattern.

Problem

The original listAvailableEncodings() added in PR #27 was callable only after bindRuntimeHost(), which happens AFTER the dialog closes. Plugins like MQTT/ZMQ need this information to populate their encoding combo boxes during widget_data().

Solution: Two-Phase Binding

Phase 1 (before dialog): Bind minimal runtime host with registry access only

session->bindRuntimeHostForDialog();  // Only registry, no engine/dataset

Phase 2 (after dialog): Complete binding with engine and dataset

session->setupAndStart(config);  // Full binding as before

Changes

DataSourceSession

  • Add bindRuntimeHostForDialog() method for early binding
  • Only binds registry pointer; engine/dataset are set later

main_window.cpp

  • Call bindRuntimeHostForDialog() before showing the dialog
  • Remove config JSON injection approach (cleaner API)

SDK (data_source_plugin_base.hpp)

  • listAvailableEncodings() now returns std::vector<std::string> directly
  • listAvailableEncodingsJson() returns raw JSON for special cases
  • Zero-dependency JSON array parser built into pj_base

Tests

  • Updated data_source_library_test.cpp with new test cases

Usage from Plugins

// mqtt_source.cpp
PJ::Status loadConfig(std::string_view config_json) override {
  dialog_.loadConfig(config_json);
  // Runtime host is now available here (Phase 1 binding done)
  dialog_.setAvailableEncodings(runtimeHost().listAvailableEncodings());
  return PJ::okStatus();
}

Related PRs

…ings vector helper

Enable plugins to query available encodings before dialog is shown by binding
a minimal runtime host (registry only) early in the session lifecycle.

Changes:
- DataSourceSession: add bindRuntimeHostForDialog() for early binding
- main_window: call bindRuntimeHostForDialog() before showing dialog
- SDK: listAvailableEncodings() now returns std::vector<std::string>
- SDK: listAvailableEncodingsJson() returns raw JSON for special cases
- SDK: zero-dependency JSON array parser in pj_base
- Tests: updated for new API
@pabloinigoblasco pabloinigoblasco merged commit f624389 into development Apr 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant