VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
bag_writer.h 文件参考

Abstract base class for VLink bag file recording with split, compression and global writer support. 更多...

#include <chrono>
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <string_view>
#include <unordered_set>
#include "../base/bytes.h"
#include "../base/macros.h"
#include "../base/message_loop.h"
#include "../impl/types.h"
bag_writer.h 的引用(Include)关系图:
此图展示该文件被哪些文件直接或间接地引用了:

浏览该文件的源代码.

 Abstract asynchronous message recorder backed by a MessageLoop event queue. 更多...
 Configuration for recording behaviour, splitting, compression, and limits. 更多...

命名空间

详细描述

Abstract base class for VLink bag file recording with split, compression and global writer support.

BagWriter is an abstract MessageLoop-based recorder that captures VLink messages (URL + serialisation type + payload) to a bag file. Concrete implementations are DatabaseWriter (SQLite-backed) and McapWriter (MCAP-format).

Key features:

  • Asynchronous recording via the inherited MessageLoop queue.
  • Pluggable compression: none, auto, Zstd, LZ4, LZAV.
  • File splitting by size or by time, with optional time-stamped names.
  • WAL (Write-Ahead Log) mode for crash resilience.
  • Global singleton writer activated by the VLINK_BAG_PATH environment variable.
  • Schema embedding for offline introspection.
Creating a writer
auto writer = vlink::BagWriter::create("/data/log.vdb");
writer->async_run();
writer->push("dds://my/topic", "demo.proto.PointCloud", vlink::SchemaType::kProtobuf,
Global writer
// Set VLINK_BAG_PATH=/data/log.vdb before launching the process.
// Then retrieve the global instance anywhere:
if (gw) {
gw->push("intra://my/topic", "raw", vlink::SchemaType::kRaw, vlink::ActionType::kPublish, data);
}
注解
  • create() selects the concrete implementation based on the file extension (.vcap / .vcapx -> McapWriter, otherwise -> DatabaseWriter).
  • push() is thread-safe and non-blocking; recording is done on the loop thread.
  • The immediate flag bypasses the task queue and writes synchronously (use with care).