Class GatewayPlugin
Defined in File gateway_plugin.hpp
Nested Relationships
Nested Types
Class Documentation
-
class GatewayPlugin
Base class for all gateway plugins.
Plugins are loaded as shared libraries (.so) via dlopen/dlsym. Each .so must export two extern “C” functions: int plugin_api_version(); // must return PLUGIN_API_VERSION GatewayPlugin* create_plugin(); // factory
Plugins implement this base class plus one or more provider interfaces (UpdateProvider, IntrospectionProvider) via multiple inheritance.
See also
PluginManager for loading and lifecycle orchestration
See also
UpdateProvider, IntrospectionProvider for typed interfaces
Public Functions
-
virtual ~GatewayPlugin() = default
-
virtual std::string name() const = 0
Unique name for this plugin.
- Returns:
Plugin name (e.g., “systemd”, “procfs”, “mender_ota”)
-
virtual void configure(const nlohmann::json &config) = 0
Configure the plugin.
Called once after loading with per-plugin config from YAML.
- Parameters:
config – JSON configuration object
-
inline virtual void set_context(PluginContext&)
Receive gateway context.
Called after configure(). Provides access to the ROS 2 node, entity cache, fault data, and HTTP handler utilities. Store the reference if needed during runtime.
- Parameters:
context – Gateway plugin context (outlives this plugin)
-
inline virtual void register_routes(httplib::Server&, const std::string&)
Optionally register custom REST routes.
Called once during REST server setup. Plugins can register vendor-specific endpoints (e.g., /x-medkit/my-feature).
- Parameters:
server – httplib server instance
api_prefix – API path prefix (e.g., “/api/v1”)
-
inline virtual std::vector<RouteDescription> get_route_descriptions() const
Describe routes registered by this plugin.
Used by handle_root to dynamically include plugin endpoints in the API root listing. Patterns should be relative to api_prefix (e.g. “apps/{app_id}/x-medkit-topic-beacon”).
- Returns:
Route descriptions for all endpoints this plugin registers
-
inline virtual void shutdown()
Shutdown hook for cleanup.
Called before the plugin is destroyed. Use for releasing resources, closing connections, etc.
Protected Functions
-
inline void log_info(const std::string &msg) const
Log an informational message (routed to gateway’s ROS 2 logger)
-
inline void log_warn(const std::string &msg) const
Log a warning message.
-
inline void log_error(const std::string &msg) const
Log an error message.
-
struct RouteDescription
Describes a single REST route registered by a plugin (for handle_root auto-registration)
-
virtual ~GatewayPlugin() = default