VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
vlink::SchemaPluginManager Class Referencefinal

Singleton manager that owns and provides access to the SchemaPluginInterface. More...

#include <schema_plugin_manager.h>

Collaboration diagram for vlink::SchemaPluginManager:

Public Member Functions

bool is_valid () const
 Returns true if a SchemaPluginInterface was successfully loaded.
std::shared_ptr< SchemaPluginInterfaceget_interface () const
 Returns the loaded SchemaPluginInterface instance.

Static Public Member Functions

static SchemaPluginManager & get (const std::string &schema_plugin_path="")
 Returns the process-global SchemaPluginManager singleton.

Detailed Description

Singleton manager that owns and provides access to the SchemaPluginInterface.

SchemaPluginManager is a process-level singleton that loads and holds a single SchemaPluginInterface plugin. The plugin path is resolved in the following order:

  1. The schema_plugin_path argument passed to get() on first call.
  2. The VLINK_SCHEMA_PLUGIN environment variable if schema_plugin_path is empty.
  3. No plugin loaded (the manager is invalid) if neither is set.
Usage
// Load by environment variable VLINK_SCHEMA_PLUGIN:
// Or explicitly (first call wins):
auto& mgr = vlink::SchemaPluginManager::get("/path/to/my_schema_plugin.so");
if (mgr.is_valid()) {
auto iface = mgr.get_interface();
auto schema = iface->search_schema("my_pkg.MyMessage", SchemaType::kProtobuf);
}
Note
  • get() creates the singleton on first call; subsequent calls ignore schema_plugin_path.
  • is_valid() returns false when no plugin was loaded.
  • The plugin interface is released before the Plugin loader on destruction, ensuring safe unloading.

Member Function Documentation

◆ get()

SchemaPluginManager & vlink::SchemaPluginManager::get ( const std::string & schema_plugin_path = "")
staticnodiscard

Returns the process-global SchemaPluginManager singleton.

On the first call, loads the plugin from schema_plugin_path if non-empty, or from the VLINK_SCHEMA_PLUGIN environment variable. Subsequent calls return the same singleton regardless of schema_plugin_path.

Parameters
schema_plugin_pathPath to the plugin shared library. Empty = use env var.
Returns
Reference to the singleton.

◆ get_interface()

std::shared_ptr< SchemaPluginInterface > vlink::SchemaPluginManager::get_interface ( ) const
nodiscard

Returns the loaded SchemaPluginInterface instance.

Returns
Shared pointer to the interface, or nullptr if not loaded.

◆ is_valid()

bool vlink::SchemaPluginManager::is_valid ( ) const
nodiscard

Returns true if a SchemaPluginInterface was successfully loaded.

Returns
true if get_interface() will return a non-null pointer.

The documentation for this class was generated from the following file: