LuaModule

class rlogic::LuaModule : public rlogic::LogicObject

LuaModule represents Lua source code in form of a reusable Lua module which can be used in Lua scripts of one or more rlogic::LuaScript instances. Lua modules can be also declared as dependency to other modules. Lua modules are expected to follow these guidelines https://www.tutorialspoint.com/lua/lua_modules.htm and have some limitations:

  • the name of the module given when creating it is only used to differentiate between LuaModule instances on Ramses logic API, not to access them from a script or to resolve a file on a filesystem

  • the module is not supposed to be resolved with the ‘require’ keyword in Lua scripts where used (due to security concerns) but must be provided explicitly when creating rlogic::LuaScript instance

  • modules are read-only in order to prevent data races when accessed from different scripts with undefined order of execution rlogic::LuaModule source code is loaded into its own Lua environment and is accessible in other rlogic::LuaScript and/or LuaModule instances in their own environments under the alias name given when creating those.

LuaModule can also be used to help provide property types for rlogic::LuaScript interface declarations, for example a module with a ‘struct’ type:

local mytypes = {}
function mytypes.mystruct()
    return Type:Struct({
        name = Type:String(),
        address = Type:Struct({
            street = Type:String(),
            number = Type:Int32()
        })
    })
end
return mytypes
And script using above module to define its interface:
modules("mytypes")  -- must declare the dependency explicitly
function interface(IN,OUT)
    IN.input_struct = mytypes.mystruct()
    OUT.output_struct = mytypes.mystruct()
end

The label ‘Type’ is a reserved keyword and must not be overwritten for other purposes (e.g. name of variable or function).

Public Functions

~LuaModule() noexcept override

Destructor of LuaModule

LuaModule(const LuaModule&) = delete

Copy Constructor of LuaModule is deleted because LuaModule is not supposed to be copied

LuaModule(LuaModule&&) = delete

Move Constructor of LuaModule is deleted because LuaModule is not supposed to be moved

LuaModule &operator=(const LuaModule&) = delete

Assignment operator of LuaModule is deleted because LuaModule is not supposed to be copied

LuaModule &operator=(LuaModule&&) = delete

Move assignment operator of LuaModule is deleted because LuaModule is not supposed to be moved

LuaModule(std::unique_ptr<internal::LuaModuleImpl> impl) noexcept

Internal constructor of LuaModule. Use rlogic::LogicEngine::createLuaModule for user code.

Parameters
  • impl: implementation details of the LuaModule

Public Members

internal::LuaModuleImpl &m_impl

Implementation detail of LuaModule