Skip to content

Class jac::Router

ClassList > jac > Router

A router that can route packets from multiple data links to to consumers on specific channels.

  • #include <router.h>

Classes

Type Name
class Handle
A handle for receiving packets from a data link.

Public Functions

Type Name
Router () = default
Router (const Router &) = delete
Router (Router &&) = delete
std::unique_ptr< Packet > buildPacket (uint8_t channel, std::vector< int > links)
Build a packet for a channel and data links.
size_t maxPacketSize (uint8_t channel, std::vector< int > links)
Get the maximum packet size for a channel and data links.
Router & operator= (const Router &) = delete
Router & operator= (Router &&) = delete
void setGlobalCallback (std::function< void(int linkId, uint8_t channel, std::span< const uint8_t > data)> callback)
Set global callback which is called whenever a packet is received on any channel and data link.
void subscribeChannel (uint8_t channel, Consumer & consumer)
Subscribe a channel to a consumer.
Handle subscribeTx (int id, DataLinkTx & tx)
Subscribe a data link transmitter to the router.

Public Functions Documentation

function Router [1/3]

jac::Router::Router () = default

function Router [2/3]

jac::Router::Router (
    const Router &
) = delete

function Router [3/3]

jac::Router::Router (
    Router &&
) = delete

function buildPacket

Build a packet for a channel and data links.

inline std::unique_ptr< Packet > jac::Router::buildPacket (
    uint8_t channel,
    std::vector< int > links
) 

Parameters:

  • channel the channel
  • links the data links

Returns:

The packet

function maxPacketSize

Get the maximum packet size for a channel and data links.

inline size_t jac::Router::maxPacketSize (
    uint8_t channel,
    std::vector< int > links
) 

Parameters:

  • channel the channel
  • links the data links

Returns:

The maximum packet size

function operator=

Router & jac::Router::operator= (
    const Router &
) = delete

function operator=

Router & jac::Router::operator= (
    Router &&
) = delete

function setGlobalCallback

Set global callback which is called whenever a packet is received on any channel and data link.

inline void jac::Router::setGlobalCallback (
    std::function< void(int linkId, uint8_t channel, std::span< const uint8_t > data)> callback
) 

Parameters:

  • callback the callback

function subscribeChannel

Subscribe a channel to a consumer.

inline void jac::Router::subscribeChannel (
    uint8_t channel,
    Consumer & consumer
) 

Note:

All packets received on the channel will be passed to the consumer.

Parameters:

  • channel the channel
  • consumer the consumer

function subscribeTx

Subscribe a data link transmitter to the router.

inline Handle jac::Router::subscribeTx (
    int id,
    DataLinkTx & tx
) 

Note:

This allows router to send packets to the data link id. Reciever should be then bound to the returned handle.

Parameters:

  • id id of the data link
  • tx the transmitter

Returns:

The handle


The documentation for this class was generated from the following file src/jac/link/router.h