VLink  2.0.0
A high-performance communication middleware
flatbuffers_registry.h File Reference

Process-local lookup table for compiled-in FlatBuffers BFBS reflection blobs. More...

#include <cstddef>
#include <mutex>
#include <shared_mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include "../impl/types.h"
Include dependency graph for flatbuffers_registry.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Detailed Description

Process-local lookup table for compiled-in FlatBuffers BFBS reflection blobs.

Protobuf ships with a built-in process-wide registry of generated descriptors (google::protobuf::DescriptorPool::generated_pool()). FlatBuffers offers no such runtime pool, so VLink keeps a small singleton table that stores BFBS reflection blobs embedded inside the running binary. The schema plugin reads from this table when BagWriter or the proxy frontends need to attach FlatBuffers schemas to recorded URLs.

The registry is intentionally minimal and never touches the filesystem – it does not read VLINK_FBS_DIR / VLINK_PROTO_DIR and does not own the BFBS buffer memory. Three operations are supported:

API Purpose
register_schema<BinarySchema>(name) Register a generated *BinarySchema helper
register_schema(name, bfbs_data, bfbs_size) Register raw BFBS bytes
search_schema(name) Look up one entry by root type name
get_all_schemas() Enumerate every registered entry

Type resolution flow:

*   generated *BinarySchema  --register_schema-->  +-------------------+
*                                                  |   BFBS map        |
*                                                  | (name -> Schema)  |
*   user lookup (root type)  --search_schema--->   +-------------------+   --> SchemaData
* 
Example
#include "helloworld/fbs/User_generated.h"
// Auto-register at static initialisation time:
VLINK_REGISTER_FLATBUFFERS("Helloworld.fbs.User", Helloworld::fbs::UserBinarySchema);
void inspect() {
auto schema = vlink::FlatbuffersRegistry::get().search_schema("Helloworld.fbs.User");
if (!schema.data.empty()) {
// Use schema.data to populate bag metadata or webviz channel info.
}
}
Process-local lookup table for compiled-in FlatBuffers BFBS reflection blobs.