CommRaT 2.0.0
C++20 Real-Time Messaging Framework
Loading...
Searching...
No Matches
commrat::RegistryMailbox< Registry > Class Template Reference

Mailbox that takes a MessageRegistry and exposes payload-only interface. More...

#include <commrat/mailbox/registry_mailbox.hpp>

Public Member Functions

 RegistryMailbox (const MailboxConfig &config)
 
 ~RegistryMailbox ()=default
 
 RegistryMailbox (const RegistryMailbox &)=delete
 
RegistryMailboxoperator= (const RegistryMailbox &)=delete
 
 RegistryMailbox (RegistryMailbox &&) noexcept=default
 
RegistryMailboxoperator= (RegistryMailbox &&) noexcept=default
 
auto start () -> MailboxResult< void >
 
void stop ()
 
bool is_running () const
 
uint32_t mailbox_id () const
 
template<typename PayloadT >
requires is_registered<PayloadT>
auto send (PayloadT &payload, uint32_t dest_mailbox) -> MailboxResult< void >
 Send a message payload to a destination mailbox.
 
template<typename PayloadT >
requires is_registered<PayloadT>
auto send (PayloadT &payload, uint32_t dest_mailbox, uint64_t timestamp) -> MailboxResult< void >
 Send a message payload with explicit timestamp (Phase 6.10)
 
template<typename PayloadT >
requires is_registered<PayloadT>
auto receive () -> MailboxResult< TimsMessage< PayloadT > >
 Receive a message of specific payload type (blocking)
 
template<typename PayloadT >
requires is_registered<PayloadT>
auto try_receive () -> MailboxResult< TimsMessage< PayloadT > >
 Try to receive a message (non-blocking)
 
template<typename PayloadT >
requires is_registered<PayloadT>
auto receive_for (std::chrono::milliseconds timeout) -> MailboxResult< TimsMessage< PayloadT > >
 Receive with timeout.
 
template<typename Visitor >
auto receive_any (Visitor &&visitor) -> MailboxResult< void >
 Receive any registered message type using visitor pattern.
 
template<typename Visitor >
auto try_receive_any (Visitor &&visitor) -> MailboxResult< void >
 
template<typename Visitor >
auto receive_any_for (std::chrono::milliseconds timeout, Visitor &&visitor) -> MailboxResult< void >
 
UnderlyingMailbox & underlying ()
 
const UnderlyingMailbox & underlying () const
 

Static Public Member Functions

static constexpr size_t num_message_types ()
 

Static Public Attributes

template<typename PayloadT >
static constexpr bool is_registered = Registry::template is_registered<PayloadT>
 

Detailed Description

template<typename Registry>
class commrat::RegistryMailbox< Registry >

Mailbox that takes a MessageRegistry and exposes payload-only interface.

Users define their MessageRegistry once with all MessageDefinitions, then use this mailbox with payload types only. No need to repeat MessageDefinition in every send/receive call.

Example:

// Define registry once:
using MyRegistry = MessageRegistry<
>;
// Use mailbox with payload types only:
mbx.start();
StatusData status{.status_code = 100};
mbx.send(status, dest_id); // Payload type only!
auto result = mbx.receive<StatusData>(); // Payload type only!
Compile-time message type registry using MessageDefinition templates.
Mailbox that takes a MessageRegistry and exposes payload-only interface.
Message definition with compile-time ID assignment.

Definition at line 39 of file registry_mailbox.hpp.

Constructor & Destructor Documentation

◆ RegistryMailbox() [1/3]

template<typename Registry >
commrat::RegistryMailbox< Registry >::RegistryMailbox ( const MailboxConfig config)
inlineexplicit

Definition at line 54 of file registry_mailbox.hpp.

◆ ~RegistryMailbox()

template<typename Registry >
commrat::RegistryMailbox< Registry >::~RegistryMailbox ( )
default

◆ RegistryMailbox() [2/3]

template<typename Registry >
commrat::RegistryMailbox< Registry >::RegistryMailbox ( const RegistryMailbox< Registry > &  )
delete

◆ RegistryMailbox() [3/3]

template<typename Registry >
commrat::RegistryMailbox< Registry >::RegistryMailbox ( RegistryMailbox< Registry > &&  )
defaultnoexcept

Member Function Documentation

◆ is_running()

template<typename Registry >
bool commrat::RegistryMailbox< Registry >::is_running ( ) const
inline

Definition at line 77 of file registry_mailbox.hpp.

◆ mailbox_id()

◆ num_message_types()

template<typename Registry >
static constexpr size_t commrat::RegistryMailbox< Registry >::num_message_types ( )
inlinestaticconstexpr

Definition at line 92 of file registry_mailbox.hpp.

◆ operator=() [1/2]

template<typename Registry >
RegistryMailbox & commrat::RegistryMailbox< Registry >::operator= ( const RegistryMailbox< Registry > &  )
delete

◆ operator=() [2/2]

template<typename Registry >
RegistryMailbox & commrat::RegistryMailbox< Registry >::operator= ( RegistryMailbox< Registry > &&  )
defaultnoexcept

◆ receive()

template<typename Registry >
template<typename PayloadT >
requires is_registered<PayloadT>
auto commrat::RegistryMailbox< Registry >::receive ( ) -> MailboxResult<TimsMessage<PayloadT>>
inline

Receive a message of specific payload type (blocking)

Definition at line 166 of file registry_mailbox.hpp.

◆ receive_any()

template<typename Registry >
template<typename Visitor >
auto commrat::RegistryMailbox< Registry >::receive_any ( Visitor &&  visitor) -> MailboxResult<void>
inline

Receive any registered message type using visitor pattern.

Visitor receives payload types only.

Definition at line 194 of file registry_mailbox.hpp.

◆ receive_any_for()

template<typename Registry >
template<typename Visitor >
auto commrat::RegistryMailbox< Registry >::receive_any_for ( std::chrono::milliseconds  timeout,
Visitor &&  visitor 
) -> MailboxResult<void>
inline

◆ receive_for()

template<typename Registry >
template<typename PayloadT >
requires is_registered<PayloadT>
auto commrat::RegistryMailbox< Registry >::receive_for ( std::chrono::milliseconds  timeout) -> MailboxResult<TimsMessage<PayloadT>>
inline

Receive with timeout.

Definition at line 184 of file registry_mailbox.hpp.

◆ send() [1/2]

template<typename Registry >
template<typename PayloadT >
requires is_registered<PayloadT>
auto commrat::RegistryMailbox< Registry >::send ( PayloadT &  payload,
uint32_t  dest_mailbox 
) -> MailboxResult<void>
inline

Send a message payload to a destination mailbox.

Message ID is automatically determined from the registry.

Template Parameters
PayloadTPayload type (must be registered)
Parameters
payloadPayload to send
dest_mailboxDestination mailbox ID
Returns
Success or error

Definition at line 112 of file registry_mailbox.hpp.

References commrat::TimsMessage< PayloadT >::header, and commrat::TimsHeader::msg_type.

◆ send() [2/2]

template<typename Registry >
template<typename PayloadT >
requires is_registered<PayloadT>
auto commrat::RegistryMailbox< Registry >::send ( PayloadT &  payload,
uint32_t  dest_mailbox,
uint64_t  timestamp 
) -> MailboxResult<void>
inline

Send a message payload with explicit timestamp (Phase 6.10)

Use this for timestamp propagation in message chains.

Template Parameters
PayloadTPayload type (must be registered)
Parameters
payloadPayload to send
dest_mailboxDestination mailbox ID
timestampTimestamp to set in header (nanoseconds since epoch)
Returns
Success or error

Definition at line 141 of file registry_mailbox.hpp.

References commrat::TimsMessage< PayloadT >::header, and commrat::TimsHeader::msg_type.

◆ start()

◆ stop()

template<typename Registry >
void commrat::RegistryMailbox< Registry >::stop ( )
inline

◆ try_receive()

template<typename Registry >
template<typename PayloadT >
requires is_registered<PayloadT>
auto commrat::RegistryMailbox< Registry >::try_receive ( ) -> MailboxResult<TimsMessage<PayloadT>>
inline

Try to receive a message (non-blocking)

Definition at line 175 of file registry_mailbox.hpp.

◆ try_receive_any()

template<typename Registry >
template<typename Visitor >
auto commrat::RegistryMailbox< Registry >::try_receive_any ( Visitor &&  visitor) -> MailboxResult<void>
inline

Definition at line 199 of file registry_mailbox.hpp.

◆ underlying() [1/2]

template<typename Registry >
UnderlyingMailbox & commrat::RegistryMailbox< Registry >::underlying ( )
inline

Definition at line 236 of file registry_mailbox.hpp.

◆ underlying() [2/2]

template<typename Registry >
const UnderlyingMailbox & commrat::RegistryMailbox< Registry >::underlying ( ) const
inline

Definition at line 237 of file registry_mailbox.hpp.

Member Data Documentation

◆ is_registered

template<typename Registry >
template<typename PayloadT >
constexpr bool commrat::RegistryMailbox< Registry >::is_registered = Registry::template is_registered<PayloadT>
staticconstexpr

Definition at line 90 of file registry_mailbox.hpp.


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