Skip to content

Modules

CVEDIA-RT features are extensible through Modules (also called Plugins), these are loaded dynamically when an instance starts from the Plugins folder and provide an interface to be used in Managed and Scripting approaches.

Lua Interface

A module interface method api.factory.[MODULE_NAME].(create/get/delete) will be created for each loaded module that registers himself with CVEDIART.

To use a module, declare an instance for it inside the global scope:

instance = api.thread.getCurrentInstance()

---@class writedatamanaged
 writeInst = api.factory.writedata.create(instance, "WriteData")

and afterwards it can be used by calling its available methods:

writeInst:appendStructuredData("textfile.txt", "data text content" .. "\n")

More Info

Module are DLL/So files that live inside the Plugins folders and implement a basic C interface:

const char pluginName[] = "MQTT";

extern "C" EXPORT void logInit(plog::Severity severity, plog::IAppender * appender)
{
    plog::init(severity, appender); // Initialize the shared library logger.
}

extern "C" EXPORT const char* PluginName() {
    return pluginName;
}

extern "C" EXPORT void Instantiate(PluginInit * init) {
    init->instance = std::static_pointer_cast<Plugin>(std::make_shared<ManagedMQTT>(init->state, init->instanceName, init->className));
}

Modules are discovered through CVEDIA-RT’s auto-discovery mechanism and do not require any additional setup. Module dependencies (system libraries, etc.) should be present in the folder from which CVEDIART is ran.

Modules generally export 3 different levels of integration:

Low-level interface

Managed interface

Lua interface

Low-level interface

This interface provides the core of a Module functionality and should be able to run outside of CVEDIA-RT. Integration would be done by including its header and cpp files directly in your project.

Managed Interface

This interface encapsulates the low-level interface and adds on top awareness of server instances by exposing the state dictionary and RTAPI.

Lua interface

Interaction with the Module directly through Lua scripting by exposing an API that encapsulates the managed interface.