Plugin Dependencies

Specifying plugin initialisation order

For plugins that require functionality from another plugin, the dependency system can be used to ensure that all dependencies are initialised before this plugin. They do this by implementing VRPDepends (native) or depends() (lua).

Plugin dependencies can be specified simply by naming the plugin that this plugin depends on. This can be in the form of the name reported by the other plugin (from its VRPName function), or in the form of the file name (e.g. someplugin(.lua)).

For Lua plugins, the use of require can be used to load external Lua libraries, but should not be used to require other Lua plugins loaded into the application. Instead, use the dependency system, which loads and initialises the required plugins in the correct order.

Example

Consider two plugins, Plugin A and Plugin B. In order to make Plugin B be loaded before Plugin A, A specifies a dependency.

#include <vrtree_api.h>

// Implement the standard API functions for application hook registration
VRPLUGIN_API_IMPL;

PLUGIN_ENTRY_POINT const char* VRTREE_APIENTRY VRPName()
{
  return "Plugin A";
}

PLUGIN_ENTRY_POINT const char* VRTREE_APIENTRY VRPVersion()
{
  return "1.0.0";
}

// Implement VRPInit to respond to application startup
PLUGIN_ENTRY_POINT int VRTREE_APIENTRY VRPInit()
{
  VRPLUGIN_LOADVRTREE;

  if (s_logFunc)
    s_logFunc(LOG_INFO, "Plugin A initialising!");

  return 0;
}

PLUGIN_ENTRY_POINT int VRTREE_APIENTRY VRPCleanup()
{
  return 0;
}

PLUGIN_ENTRY_POINT const char* VRTREE_APIENTRY VRPDepends()
{
  return "Plugin B";
}
local modname = ...
local _G = _G
module(modname)

function name()
  return "Plugin A"
end

function version()
  return "1.0.0"
end

function init()
  _G.print("Plugin A initialising!")
end

function depends()
  return "Plugin B"
end
To specify multiple dependencies, separate each with a comma. For native plugins this should result in a comma separated string. For Lua plugins, the depends function can just return multiple strings:

PLUGIN_ENTRY_POINT const char* VRTREE_APIENTRY VRPDepends()
{
  return "Plugin B, Plugin C";
}
function depends()
  return "Plugin B", "Plugin C"
end


No Results.

Getting StartedArchitectureBest PracticesHow ToAdvanced TopicsChangelogvrtree_cppCoreForeign Function InterfaceMetanodesMigrationsObserversPropertiesTreeUtilitiesAPI DefinitionsVR ExchangePluginsLua API