Class PluginManager

Nested Relationships

Nested Types

Class Documentation

class PluginManager

Orchestrates loading, lifecycle, and dispatch of gateway plugins.

Owns all plugin instances and dlopen handles. Subsystem managers receive non-owning pointers via get_update_provider() / get_introspection_providers().

Provider discovery uses extern “C” query functions from loaded .so files (avoiding RTTI across dlopen boundary). For compile-time plugins added via add_plugin(), dynamic_cast is used (safe within the same binary).

Error isolation: every call to plugin code is wrapped in try/catch. A failing plugin is disabled but does not crash the gateway.

IMPORTANT: PluginManager must outlive all subsystem managers that hold non-owning provider pointers (e.g. UpdateManager). In GatewayNode, declare plugin_mgr_ BEFORE update_mgr_ so that destruction order is safe.

Public Functions

PluginManager() = default
~PluginManager()
PluginManager(const PluginManager&) = delete
PluginManager &operator=(const PluginManager&) = delete
void add_plugin(std::unique_ptr<GatewayPlugin> plugin)

Add a plugin directly (for testing with compile-time plugins)

Uses dynamic_cast for provider discovery (safe within same binary).

Parameters:

plugin – Plugin instance

size_t load_plugins(const std::vector<PluginConfig> &configs)

Load plugins from shared library paths.

Parameters:

configs – Plugin configurations with paths and per-plugin config

Returns:

Number of successfully loaded plugins

void configure_plugins()

Configure all loaded plugins.

Calls configure() on each plugin with its per-plugin config. Plugins that throw are disabled.

void set_context(PluginContext &context)

Set plugin context on all plugins.

Passes the gateway context (entity cache, faults, ROS 2 node, HTTP utils) to each plugin via set_context(). Replaces the old set_node() method.

Parameters:

context – Plugin context (must outlive all plugins)

void register_routes(httplib::Server &server, const std::string &api_prefix)

Register custom REST routes from all plugins.

Parameters:
  • server – httplib server instance

  • api_prefix – API path prefix (e.g., “/api/v1”)

void register_resource_sampler(const std::string &collection, ResourceSamplerFn fn)

Register a resource sampler for a vendor collection (must start with “x-”)

void register_transport(std::unique_ptr<SubscriptionTransportProvider> provider)

Register a custom transport provider.

void set_registries(ResourceSamplerRegistry &samplers, TransportRegistry &transports)

Set registries (called during gateway init)

void shutdown_all()

Shutdown all plugins.

UpdateProvider *get_update_provider() const

Get the update provider (first plugin implementing UpdateProvider)

Returns:

Non-owning pointer, or nullptr if no UpdateProvider plugin loaded

std::vector<IntrospectionProvider*> get_introspection_providers() const

Get all introspection providers.

Returns:

Non-owning pointers to all IntrospectionProvider plugins

LogProvider *get_log_provider() const

Get the first plugin implementing LogProvider, or nullptr if none loaded.

ScriptProvider *get_script_provider() const

Get the first plugin implementing ScriptProvider, or nullptr if none loaded.

std::vector<LogProvider*> get_log_observers() const

Get all plugins implementing LogProvider (for observer notifications)

std::vector<std::pair<std::string, IntrospectionProvider*>> get_named_introspection_providers() const

Get all introspection providers with their plugin names.

Returns:

(plugin_name, provider) pairs for all IntrospectionProvider plugins

std::vector<openapi::RouteDescriptions> collect_route_descriptions() const

Collect OpenAPI route descriptions from all loaded plugins. Uses dlsym to check for optional “describe_plugin_routes” export.

inline PluginContext *get_context() const

Get plugin context (for capability queries from discovery handlers)

std::vector<GatewayPlugin::RouteDescription> get_all_route_descriptions() const

Collect route descriptions from all active plugins.

Returns:

Combined route descriptions from all plugins

bool has_plugins() const
std::vector<std::string> plugin_names() const