VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::SchemaPluginManager类 参考final

Singleton manager that owns and provides access to the SchemaPluginInterface. 更多...

#include <schema_plugin_manager.h>

vlink::SchemaPluginManager 的协作图:

Public 成员函数

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

静态 Public 成员函数

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

详细描述

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);
}
注解
  • 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.

成员函数说明

◆ 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.

参数
schema_plugin_pathPath to the plugin shared library. Empty = use env var.
返回
Reference to the singleton.

◆ get_interface()

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

Returns the loaded SchemaPluginInterface instance.

返回
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.

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

该类的文档由以下文件生成: