maliput
|
This document aims to explain the plugin architecture that Maliput provides.
The main objective of the plugin architecture is to hand out an architecture that allows users to customize certain systems implementations in an easy and effective way.
Maliput defines maliput::plugin::MaliputPlugin class which is in charge of providing an interface to interact with a given dynamic library.
To be considered a maliput plugin, the following two functions must be defined:
The MaliputPlugin
type that are currently supported are listed at the enum
named maliput::plugin::MaliputPluginType.
maliput::plugin::MaliputPluginManager manages the lifecycle of MaliputPlugin
s. It will try to load all the available plugins in the path(MALIPUT_PLUGIN_PATH
) and make them available via maliput::plugin::MaliputPluginManager::GetPlugin().
The MaliputPlugin's discovery process consists on retrieving all the MaliputPlugins that are located as the MALIPUT_PLUGIN_PATH
environment variable points to.
To extend the discovery process to other locations simply extend the MALIPUT_PLUGIN_PATH
environment variable.
Maliput clients may opt to use the plugin architecture to load at runtime specific backends. That simplifies the linkage process and reduces the number of compile time dependencies. See maliput::plugin::RoadNetworkLoader class which offers a unified interface for maliput users to load a maliput::api::RoadNetwork.
Maliput backend implementations must use REGISTER_ROAD_NETWORK_LOADER_PLUGIN()
macro to instantiate the necessary entry points of the plugin. Those symbols are required by the plugin architecture discovery phase. Refer to the following code snippet for a usage example:
As it can be seen:
RoadNetworkLoader
class inherits from maliput::plugin::RoadNetworkLoader and the operator()
calls into the specific maliput backend load procedure.Note: MALIPUT_PLUGIN_PATH
must contain the path to the installed plugin shared library in order to make maliput::plugin::MaliputPluginManager aware of its existence and load it.
After the creation of the maliput::plugin::MaliputPlugin that implements a maliput::plugin::RoadNetworkLoader and the correct set up of the MALIPUT_PLUGIN_PATH
discovery path, the use of this plugin is quite straightforward:
For convenience, maliput offers a helper method for loading a maliput::api::RoadNetwork from a plugin, which is a shortcut to the above code snippet.
maliput
backends that already have implemented their maliput::plugin::RoadNetworkLoader plugin:
maliput_py
package for further information.