Plugins
Covers Engine Plugin SDK 2.0.0 · Interface Plugin SDK 0.2.0
TaskRuntime
Live task context passed to plugin task lifecycle callbacks.
Runtime context values persist for the lifetime of one task runtime and can be used to share plugin-owned state between start, task, end, and cleanup callbacks.
Declaration
class TaskRuntime {
public:
virtual ~TaskRuntime() = default;
virtual const std::string& getTaskName() const = 0;
virtual const std::string& getTaskType() const = 0;
virtual const nlohmann::json& getMetadata() const = 0;
virtual const nlohmann::json& getArguments() const = 0;
virtual double getElapsedSeconds() const = 0;
virtual bool isStopRequested() const = 0;
virtual void setRuntimeContext(const std::string& key, std::shared_ptr<void> value) = 0;
virtual std::shared_ptr<void> getRuntimeContext(const std::string& key) const = 0;
virtual void removeRuntimeContext(const std::string& key) = 0;
virtual void clearRuntimeContext() = 0;
// Keep new virtual functions appended so plugins built against the previous
// TaskRuntime vtable retain the indices of all existing functions.
virtual void setFixedInputChannels(std::vector<std::string> channels) = 0;
virtual void recordWorkerCycle() = 0;
template <typename T>
void setTypedRuntimeContext(const std::string& key, const std::shared_ptr<T>& value) {
setRuntimeContext(key, std::static_pointer_cast<void>(value));
}
template <typename T>
std::shared_ptr<T> getTypedRuntimeContext(const std::string& key) const {
return std::static_pointer_cast<T>(getRuntimeContext(key));
}
};