MessageInput< TMessageSpec > Class Template Reference

Space-ng SDK: sol3::core::MessageInput< TMessageSpec > Class Template Reference
Space-ng SDK
sol3::core::MessageInput< TMessageSpec > Class Template Reference

#include <sol3/core/message_input.h>

Inheritance diagram for sol3::core::MessageInput< TMessageSpec >:
sol3::core::AnyMessageInput

Public Types

using TableType = typename TMessageSpec::TableType
 FlatBuffers table types derived from the message spec. More...
 
using NativeTableType = typename TableType::NativeTableType
 

Public Member Functions

 MessageInput (IBufferExchange &exchange, uint32_t component_id)
 
 MessageInput (IBufferExchange &exchange, IBufferExchange::Endpoint endpoint, uint32_t component_id)
 
 MessageInput (MessageInput &&rhs)=delete
 
MessageInputoperator= (MessageInput &&rhs)=delete
 
 MessageInput (MessageInput const &)=delete
 
MessageInputoperator= (MessageInput const &rhs)=delete
 
 ~MessageInput ()=default
 
MessageView< TMessageSpec > read (uint64_t seq, std::chrono::steady_clock::duration time_out={})
 
MessageView< TMessageSpec > readHead (std::chrono::steady_clock::duration time_out={})
 
- Public Member Functions inherited from sol3::core::AnyMessageInput
 AnyMessageInput (IBufferExchange &exchange, IBufferExchange::Endpoint endpoint, MessagePort port, MessageSchema expected_schema=MessageSchema())
 
 AnyMessageInput (IBufferExchange &exchange, MessagePort port, MessageSchema expected_schema)
 
 AnyMessageInput (AnyMessageInput &&rhs)=delete
 
AnyMessageInputoperator= (AnyMessageInput &&rhs)=delete
 
 AnyMessageInput (AnyMessageInput const &)=delete
 
AnyMessageInputoperator= (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

template<typename TMessageSpec>
class sol3::core::MessageInput< TMessageSpec >

Typed input for reading a stream of messages defined by TMessageSpec from an IBufferExchange.

This class discovers and tracks the underlying shared buffer for the computed message port, swaps in new buffers when the provider updates its UUID, and exposes MessageReader-style accessors to read the latest (head) or a specific sequence number.

Member Typedef Documentation

◆ NativeTableType

template<typename TMessageSpec >
using sol3::core::MessageInput< TMessageSpec >::NativeTableType = typename TableType::NativeTableType

◆ TableType

template<typename TMessageSpec >
using sol3::core::MessageInput< TMessageSpec >::TableType = typename TMessageSpec::TableType

FlatBuffers table types derived from the message spec.

Constructor & Destructor Documentation

◆ MessageInput() [1/4]

template<typename TMessageSpec >
sol3::core::MessageInput< TMessageSpec >::MessageInput ( IBufferExchange exchange,
uint32_t  component_id 
)
inlineexplicit

Binds to exchange on the message port computed from component_id and initializes the reader with the currently available buffer, if any. This constructor leverages resolution rules to determine the actual port that should be read from the exchange.

◆ MessageInput() [2/4]

template<typename TMessageSpec >
sol3::core::MessageInput< TMessageSpec >::MessageInput ( IBufferExchange exchange,
IBufferExchange::Endpoint  endpoint,
uint32_t  component_id 
)
inlineexplicit

Binds to exchange and a specific peer endpoint on the message port computed from component_id, and initializes with the currently available buffer, if any.

◆ MessageInput() [3/4]

template<typename TMessageSpec >
sol3::core::MessageInput< TMessageSpec >::MessageInput ( MessageInput< TMessageSpec > &&  rhs)
delete

◆ MessageInput() [4/4]

template<typename TMessageSpec >
sol3::core::MessageInput< TMessageSpec >::MessageInput ( MessageInput< TMessageSpec > const &  )
delete

◆ ~MessageInput()

template<typename TMessageSpec >
sol3::core::MessageInput< TMessageSpec >::~MessageInput ( )
default

Member Function Documentation

◆ operator=() [1/2]

template<typename TMessageSpec >
MessageInput& sol3::core::MessageInput< TMessageSpec >::operator= ( MessageInput< TMessageSpec > &&  rhs)
delete

◆ operator=() [2/2]

template<typename TMessageSpec >
MessageInput& sol3::core::MessageInput< TMessageSpec >::operator= ( MessageInput< TMessageSpec > const &  rhs)
delete

◆ read()

template<typename TMessageSpec >
MessageView<TMessageSpec> sol3::core::MessageInput< TMessageSpec >::read ( uint64_t  seq,
std::chrono::steady_clock::duration  time_out = {} 
)
inline

Returns a MessageView<TMessageSpec> 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()

template<typename TMessageSpec >
MessageView<TMessageSpec> sol3::core::MessageInput< TMessageSpec >::readHead ( std::chrono::steady_clock::duration  time_out = {})
inline

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.


The documentation for this class was generated from the following file: