MessageOutput< TMessageSpec > Class Template Reference
|
Space-ng SDK
|
#include <sol3/core/message_output.h>
Public Types | |
| using | TableType = typename TMessageSpec::TableType |
| using | NativeTableType = typename TableType::NativeTableType |
| using | Builder = typename TableType::Builder |
Public Member Functions | |
| MessageOutput (IBufferExchange &exchange, uint32_t component_id, size_t slot_count, size_t slot_size) | |
| msg::MessageHeaderT const & | header () const |
| NativeTableType & | payload () |
| Mutable access to the native FlatBuffers payload. More... | |
| NativeTableType const & | payload () const |
| TableType const * | payloadRoot () const |
| void | addStamp (msg::Stamp const &stamp) |
| Append a timestamp to the header. More... | |
| uint64_t | write () |
| template<typename TBuilderFunction > | |
| uint64_t | write (TBuilderFunction &&builder_function) |
Public Member Functions inherited from sol3::core::AnyMessageOutput | |
| AnyMessageOutput (IBufferExchange &exchange, MessagePort port, MessageSchema schema, size_t slot_count, size_t slot_size) | |
| ~AnyMessageOutput () | |
| Unregisters the output buffer from the exchange. More... | |
| AnyMessageOutput (AnyMessageOutput &&rhs)=delete | |
| AnyMessageOutput & | operator= (AnyMessageOutput &&rhs)=delete |
| AnyMessageOutput (AnyMessageOutput const &)=delete | |
| AnyMessageOutput & | operator= (AnyMessageOutput const &rhs)=delete |
| MessagePort const & | port () const |
| Destination message port. More... | |
| flatbuffers::span< uint8_t const > | headerSpan () const |
| flatbuffers::span< uint8_t const > | payloadSpan () const |
| uint64_t | write (flatbuffers::span< uint8_t const > header_span, flatbuffers::span< uint8_t const > payload_span) |
| Returns the sequence number of the slot written to. More... | |
| msg::MessageHeader const * | headerRoot () const |
| template<typename TTableType > | |
| TTableType const * | payloadRoot () const |
| MessageSchema | schema () const |
Detailed Description
template<typename TMessageSpec>
class sol3::core::MessageOutput< TMessageSpec >
Typed output writer for publishing messages defined by MessageSpec<TableType, kInterfaceType, kInterfaceId> into an IBufferExchange as a sequence ring.
Constructs and registers a shared-memory buffer sized for the requested number of slots and slot size. On destruction, unregisters the buffer.
Member Typedef Documentation
◆ Builder
| using sol3::core::MessageOutput< TMessageSpec >::Builder = typename TableType::Builder |
◆ NativeTableType
| using sol3::core::MessageOutput< TMessageSpec >::NativeTableType = typename TableType::NativeTableType |
◆ TableType
| using sol3::core::MessageOutput< TMessageSpec >::TableType = typename TMessageSpec::TableType |
Constructor & Destructor Documentation
◆ MessageOutput()
|
inline |
Creates and registers an output buffer for component component with slot_count slots of size slot_size bytes each.
The buffer is advertised on the message port derived from TMessageSpec::makeMessagePort(component) and becomes discoverable by readers via the exchange.
Member Function Documentation
◆ addStamp()
|
inline |
Append a timestamp to the header.
◆ header()
|
inline |
◆ payload() [1/2]
|
inline |
Mutable access to the native FlatBuffers payload.
◆ payload() [2/2]
|
inline |
◆ payloadRoot()
|
inline |
◆ write() [1/2]
|
inline |
Takes the current value of payload(), which is a flatbuffer NativeTableType, and packs it into FlatBuffers buffer, stamps the header, and writes header+payload into the next ring slot. Returns the sequence number of the slot written to.
After this function returns the headSpan and payloadSpan will contained the serialized flatbuffer data that was copied to the sequence ring slot
The following should be true: reader.read(writer.write()).payloadSpan() == writer.payloadSpan()
◆ write() [2/2]
|
inline |
Performant alternative to the payload() mutate then write() pattern, this allows use of the flatbuffer typed builder interface, and bypasses the payload NativeTableType interface altogether. Avoids a packing from the payload object into the buffer builder, and an additional copy/serialization step. Call this instead of write().
Expects a function with signature: Usage example:
writer.write([i](flatbuffers::FlatBufferBuilder& fbb) -> flatbuffers::Offset<msg::Text> { auto offset = fbb.CreateString(fmt::format("Hello {}", i)); msg::TextBuilder builder(fbb); builder.add_data(offset); return builder.Finish() });
Returns message sequence number
The documentation for this class was generated from the following file:
- /workspaces/astro/sol3-sdk/cpp/sol3/core/message_output.h
Generated by
Public Member Functions inherited from