Class DefaultScriptProvider
Defined in File default_script_provider.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public ros2_medkit_gateway::ScriptProvider(Class ScriptProvider)
Class Documentation
-
class DefaultScriptProvider : public ros2_medkit_gateway::ScriptProvider
Built-in ScriptProvider that loads manifest entries and supports filesystem CRUD for uploaded scripts. Includes POSIX subprocess execution with timeout support.
Public Functions
-
explicit DefaultScriptProvider(const ScriptsConfig &config)
-
~DefaultScriptProvider() override
-
virtual tl::expected<std::vector<ScriptInfo>, ScriptBackendErrorInfo> list_scripts(const std::string &entity_id) override
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) override
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) override
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) override
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) override
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) override
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) override
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) override
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.
-
explicit DefaultScriptProvider(const ScriptsConfig &config)