feat(message): Add FlatBuffers zero-copy message support alongside Protobuf#54
feat(message): Add FlatBuffers zero-copy message support alongside Protobuf#54Copilot wants to merge 5 commits intofastdds-tagfrom
Conversation
38 improve py proto library
Co-authored-by: daohu527 <10419854+daohu527@users.noreply.github.com>
|
@copilot continue |
…ystem Co-authored-by: daohu527 <10419854+daohu527@users.noreply.github.com>
Completed in commit
|
Introduces
FlatBufferMessage— a zero-copy message type for Cyber RT's transport layer — and a FlatBuffers-based Chatter talker/listener pair as a reference implementation.FlatBufferMessageis fully integrated into the Cyber RT message traits system, enabling it to work with the SHM transmitter/receiver and transport layer out of the box. Existing Protobuf infrastructure is untouched.Core additions
cyber/message/flatbuffers_message.h—FlatBufferMessageclass implementing the standard Cyber RT message interface. The key primitive isGetRoot<T>(), which returns a typed pointer directly into the internal buffer viaflatbuffers::GetRoot<T>(buf)— zero copies, zero allocations on the receive path. IncludesSetTypeName()forHasSetTypetrait detection (allows the transport layer'sParseFromHCto propagate type info) andset_type_name()for conventional C++ usage.cyber/message/flatbuffers_traits.h— Inline overloads forByteSize,SerializeToArray, andParseFromArrayforFlatBufferMessage, following the same pattern asraw_message_traits.handpy_message_traits.h. TheByteSizeoverload is essential for the SHM transmitter (message::ByteSize(msg)would otherwise return -1 for types withoutByteSizeLong()).cyber/message/message_traits.h— Now includesflatbuffers_traits.halongside the other traits headers, soFlatBufferMessageworks everywhere message traits are used.cyber/message/flatbuffers_message_test.cc— Unit tests for construction, zero-copyGetRoot, serialize/parse round-trips (array + string), edge cases, and copy semantics.cyber/message/message_traits_test.cc—FlatBufferMessagecoverage added to all existing test cases:type_trait,byte_size,serialize_to_array,serialize_to_string,parse_from_array,parse_from_string,message_type, anddescriptor.Schema & generated code
cyber/examples/proto/examples.fbs— FlatBuffers schema mirroringexamples.proto(Chattertable with identical fields).cyber/examples/proto/examples_generated.h— Pre-generated FlatBuffers C++ header committed directly; no build-timeflatcinvocation required.Build system
bazel/flatbuffers.bzl— Module extension creating a@flatbufferslocal repository that symlinks the system-installed headers (/usr/include/flatbuffers). FlatBuffers C++ runtime is header-only; no linking needed.MODULE.bazel— Registersflatbuffers_extension; exposes@flatbuffers//:flatbuffersto all targets.cyber/message/BUILD— Addsflatbuffers_message,flatbuffers_traits, and their test targets;flatbuffers_traitsis wired intomessage_traitsdependencies.cyber/examples/proto/BUILD— Addsexamples_fbscc_library wrapping the generated header.cyber/examples/BUILD— Addstalker_fbandlistener_fbbinary targets.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.