AnyMessageInput Class Reference
|
Space-ng SDK
|
#include <sol3/core/any_message_input.h>
Public Member Functions | |
| AnyMessageInput (IBufferExchange &exchange, IBufferExchange::Endpoint endpoint, MessagePort port, MessageSchema expected_schema=MessageSchema()) | |
| AnyMessageInput (IBufferExchange &exchange, MessagePort port, MessageSchema expected_schema) | |
| AnyMessageInput (AnyMessageInput &&rhs)=delete | |
| AnyMessageInput & | operator= (AnyMessageInput &&rhs)=delete |
| AnyMessageInput (AnyMessageInput const &)=delete | |
| AnyMessageInput & | operator= (AnyMessageInput const &rhs)=delete |
| ~AnyMessageInput ()=default | |
| bool | pollForBufferUpdate () |
| Return true if the underlying buffer has been updated and is valid. More... | |
| size_t | slotCount () const |
| Number of slots in the underlying sequence ring. More... | |
| size_t | slotSize () const |
| Maximum slot size in bytes in the underlying sequence ring. More... | |
| void | reset () |
| Resets the reader and clears cached message views. More... | |
| AnyMessageView | read (uint64_t seq, std::chrono::steady_clock::duration time_out={}) |
| size_t | readInto (uint64_t seq, flatbuffers::span< uint8_t > dest, std::chrono::steady_clock::duration time_out={}) |
| size_t | readInto (uint64_t seq, IStreamWriter &stream, std::chrono::steady_clock::duration time_out={}) |
| AnyMessageView | readHead (std::chrono::steady_clock::duration time_out={}) |
| uint64_t | head () const |
| The current latest sequence number, or 0 if no messages. More... | |
| MessagePort | port () const |
| The message port associated with this input. More... | |
| IBufferExchange::Endpoint const & | endpoint () const |
| MessageSchema const & | schema () const |
| void | updateSchema (MessageSchema const &schema) |
Detailed Description
Untyped input for reading any flatbuffer messages from a specific port that are published on the IBufferExchange.
When flatbuffer's are published on IBufferExchange with MessageWriter<TMessageSpec>, the corresponding flatbuffer reflection::Schema is also published. This schema allows for messages to be read and validated and interpreted without knowing their definition at compile time.
This type erased message input class is the the base implementation for MessageInput<TMessageSpec> and is also useful for implementing framework level code such as logging, playback, and telemetry systems.
Constructor & Destructor Documentation
◆ AnyMessageInput() [1/4]
|
explicit |
This constructor takes an explicit endpoint, which will be added as a peer to the exchange if it isn't already and no resolution rules will be applied. This is for advance usage and test cases. Default to the other constructor, which uses resolution rules.
◆ AnyMessageInput() [2/4]
|
explicit |
Here, no explicit endpoint is used, so this input uses resolution rules to find message port to read from the exchange. Prefer to use inputs with resolution rules.
◆ AnyMessageInput() [3/4]
|
delete |
◆ AnyMessageInput() [4/4]
|
delete |
◆ ~AnyMessageInput()
|
default |
Member Function Documentation
◆ endpoint()
| IBufferExchange::Endpoint const& sol3::core::AnyMessageInput::endpoint | ( | ) | const |
◆ head()
| uint64_t sol3::core::AnyMessageInput::head | ( | ) | const |
The current latest sequence number, or 0 if no messages.
◆ operator=() [1/2]
|
delete |
◆ operator=() [2/2]
|
delete |
◆ pollForBufferUpdate()
| bool sol3::core::AnyMessageInput::pollForBufferUpdate | ( | ) |
Return true if the underlying buffer has been updated and is valid.
◆ port()
| MessagePort sol3::core::AnyMessageInput::port | ( | ) | const |
The message port associated with this input.
◆ read()
| AnyMessageView sol3::core::AnyMessageInput::read | ( | uint64_t | seq, |
| std::chrono::steady_clock::duration | time_out = {} |
||
| ) |
Returns a AnyMessageView at the given sequence index. If the given index has not been read, bytes are copied out of the underlying shared sequence ring memory, and these copied bytes are referenced by the view. The view will remain valid, as long as another call to read with a modulo equivalent index ( old_seq % slot_count == new_seq % slot_count ) does not invalidate the view. If the given index has already been read, this will return a cached view.
◆ readHead()
| AnyMessageView sol3::core::AnyMessageInput::readHead | ( | std::chrono::steady_clock::duration | time_out = {} | ) |
Returns a view to the latest message (head).
If no buffer is yet available, this will attempt to discover one by periodically calling pollForBufferUpdate() until time_out elapses. Any remaining time is then passed to the underlying MessageReader::readHead.
◆ readInto() [1/2]
| size_t sol3::core::AnyMessageInput::readInto | ( | uint64_t | seq, |
| flatbuffers::span< uint8_t > | dest, | ||
| std::chrono::steady_clock::duration | time_out = {} |
||
| ) |
Copy the message at seq into dest, returning bytes copied. Returns 0 if the read times out or the slot is not readable. Prefer this over read() when you need ownership or stable bytes beyond the slot cache lifetime, or when streaming into a preallocated buffer to avoid view invalidation from ring overwrites.
◆ readInto() [2/2]
| size_t sol3::core::AnyMessageInput::readInto | ( | uint64_t | seq, |
| IStreamWriter & | stream, | ||
| std::chrono::steady_clock::duration | time_out = {} |
||
| ) |
Copy the message at seq into an append-only stream. Returns bytes written, or 0 if the read times out or the slot is dirty.
◆ reset()
| void sol3::core::AnyMessageInput::reset | ( | ) |
Resets the reader and clears cached message views.
◆ schema()
| MessageSchema const& sol3::core::AnyMessageInput::schema | ( | ) | const |
◆ slotCount()
| size_t sol3::core::AnyMessageInput::slotCount | ( | ) | const |
Number of slots in the underlying sequence ring.
◆ slotSize()
| size_t sol3::core::AnyMessageInput::slotSize | ( | ) | const |
Maximum slot size in bytes in the underlying sequence ring.
◆ updateSchema()
| void sol3::core::AnyMessageInput::updateSchema | ( | MessageSchema const & | schema | ) |
The documentation for this class was generated from the following file:
- /workspaces/astro/sol3-sdk/cpp/sol3/core/any_message_input.h
Generated by