Class ScriptProvider
Defined in File script_provider.hpp
Inheritance Relationships
Derived Type
public ros2_medkit_gateway::DefaultScriptProvider(Class DefaultScriptProvider)
Class Documentation
-
class ScriptProvider
Abstract interface for script storage and execution backends.
Implementations are provided by the built-in DefaultScriptProvider or by external plugins via dlopen. The ScriptManager wraps this interface with null-safety, exception isolation, and logging.
See also
ScriptManager for the subsystem that uses this
See also
DefaultScriptProvider for the built-in implementation
- Thread Safety
All methods may be called concurrently from multiple HTTP handler threads. Implementations MUST be thread-safe. The gateway does not serialize calls to the provider. The ScriptManager’s try/catch wrapper ensures that exceptions thrown by implementations do not crash the gateway.
Subclassed by ros2_medkit_gateway::DefaultScriptProvider
Public Functions
-
virtual ~ScriptProvider() = default
-
virtual tl::expected<std::vector<ScriptInfo>, ScriptBackendErrorInfo> list_scripts(const std::string &entity_id) = 0
List scripts available for a given entity.
- Parameters:
entity_id – The entity to list scripts for.
- Returns:
A vector of ScriptInfo on success, or ScriptBackendErrorInfo on failure.
-
virtual tl::expected<ScriptInfo, ScriptBackendErrorInfo> get_script(const std::string &entity_id, const std::string &script_id) = 0
Get metadata for a specific script.
- Parameters:
entity_id – The entity that owns the script.
script_id – The script identifier.
- Returns:
ScriptInfo on success, or ScriptBackendErrorInfo on failure.
-
virtual tl::expected<ScriptUploadResult, ScriptBackendErrorInfo> upload_script(const std::string &entity_id, const std::string &filename, const std::string &content, const std::optional<nlohmann::json> &metadata) = 0
Upload a new script file with optional metadata.
- Parameters:
entity_id – The entity to associate the script with.
filename – Original filename (used for format detection).
content – Raw script file content.
metadata – Optional JSON metadata (name, description, parameters_schema).
- Returns:
ScriptUploadResult with the generated ID, or ScriptBackendErrorInfo on failure.
-
virtual tl::expected<void, ScriptBackendErrorInfo> delete_script(const std::string &entity_id, const std::string &script_id) = 0
Delete an uploaded script. Manifest-managed scripts cannot be deleted.
- Parameters:
entity_id – The entity that owns the script.
script_id – The script identifier.
- Returns:
void on success, or ScriptBackendErrorInfo on failure.
-
virtual tl::expected<ExecutionInfo, ScriptBackendErrorInfo> start_execution(const std::string &entity_id, const std::string &script_id, const ExecutionRequest &request) = 0
Start executing a script as a subprocess.
- Parameters:
entity_id – The entity context for execution.
script_id – The script to execute.
request – Execution parameters (type, input parameters, proximity proof).
- Returns:
ExecutionInfo with initial status, or ScriptBackendErrorInfo on failure.
-
virtual tl::expected<ExecutionInfo, ScriptBackendErrorInfo> get_execution(const std::string &entity_id, const std::string &script_id, const std::string &execution_id) = 0
Get the current status of a script execution.
- Parameters:
entity_id – The entity context.
script_id – The script that was executed.
execution_id – The execution identifier.
- Returns:
ExecutionInfo with current status, or ScriptBackendErrorInfo on failure.
-
virtual tl::expected<ExecutionInfo, ScriptBackendErrorInfo> control_execution(const std::string &entity_id, const std::string &script_id, const std::string &execution_id, const std::string &action) = 0
Control a running execution (stop or force-terminate).
- Parameters:
entity_id – The entity context.
script_id – The script that was executed.
execution_id – The execution identifier.
action – The control action (“stop” or “forced_termination”).
- Returns:
Updated ExecutionInfo, or ScriptBackendErrorInfo on failure.
-
virtual tl::expected<void, ScriptBackendErrorInfo> delete_execution(const std::string &entity_id, const std::string &script_id, const std::string &execution_id) = 0
Delete a completed execution record. Running executions cannot be deleted.
- Parameters:
entity_id – The entity context.
script_id – The script that was executed.
execution_id – The execution identifier.
- Returns:
void on success, or ScriptBackendErrorInfo on failure.