Goby3  3.1.5a
2024.05.23
goby::middleware::Subscriber< Data > Class Template Reference

Class that holds additional metadata and callback functions related to a subscription (and is optionally provided as a parameter to StaticTransporterInterface::subscribe). Use of this class is generally unnecessary on interprocess and inner layers. More...

#include <goby/middleware/transport/subscriber.h>

Public Types

using group_func_type = std::function< Group(const Data &)>
 
using subscribed_func_type = typename Publisher< intervehicle::protobuf::Subscription >::acked_func_type
 
using subscribe_expired_func_type = typename Publisher< intervehicle::protobuf::Subscription >::expired_func_type
 
using set_link_data_func_type = std::function< void(Data &, const intervehicle::protobuf::Header &)>
 

Public Member Functions

 Subscriber (const goby::middleware::protobuf::TransporterConfig &cfg=goby::middleware::protobuf::TransporterConfig(), group_func_type group_func=group_func_type(), subscribed_func_type subscribed_func=subscribed_func_type(), subscribe_expired_func_type subscribe_expired_func=subscribe_expired_func_type(), set_link_data_func_type set_link_data_func=set_link_data_func_type())
 Construct a Subscriber with all available metadata and callbacks. More...
 
 Subscriber (const goby::middleware::protobuf::TransporterConfig &cfg, subscribed_func_type subscribed_func, subscribe_expired_func_type subscribe_expired_func=subscribe_expired_func_type(), set_link_data_func_type set_link_data_func=set_link_data_func_type())
 Construct a Subscriber but without the group_func callback. More...
 
 ~Subscriber ()
 
const goby::middleware::protobuf::TransporterConfigcfg () const
 
Group group (const Data &data) const
 
subscribed_func_type subscribed_func () const
 
subscribe_expired_func_type subscribe_expired_func () const
 
bool has_group_func () const
 
void set_link_data (Data &data, const intervehicle::protobuf::Header &header) const
 Sets the link data in the message using the set_link_data_func. Only intended to be called by the various transporters. More...
 

Detailed Description

template<typename Data>
class goby::middleware::Subscriber< Data >

Class that holds additional metadata and callback functions related to a subscription (and is optionally provided as a parameter to StaticTransporterInterface::subscribe). Use of this class is generally unnecessary on interprocess and inner layers.

Definition at line 36 of file subscriber.h.

Member Typedef Documentation

◆ group_func_type

template<typename Data >
using goby::middleware::Subscriber< Data >::group_func_type = std::function<Group(const Data&)>

Definition at line 39 of file subscriber.h.

◆ set_link_data_func_type

template<typename Data >
using goby::middleware::Subscriber< Data >::set_link_data_func_type = std::function<void(Data&, const intervehicle::protobuf::Header&)>

Definition at line 45 of file subscriber.h.

◆ subscribe_expired_func_type

template<typename Data >
using goby::middleware::Subscriber< Data >::subscribe_expired_func_type = typename Publisher<intervehicle::protobuf::Subscription>::expired_func_type

Definition at line 43 of file subscriber.h.

◆ subscribed_func_type

template<typename Data >
using goby::middleware::Subscriber< Data >::subscribed_func_type = typename Publisher<intervehicle::protobuf::Subscription>::acked_func_type

Definition at line 41 of file subscriber.h.

Constructor & Destructor Documentation

◆ Subscriber() [1/2]

Construct a Subscriber with all available metadata and callbacks.

Parameters
cfgAdditional metadata for this subscribe
group_funcCallback function for retrieving the group from a given data type if not provided in the parameters to the subscribe call. This is typically used when the group is defined or inferred from data in the message itself, and thus using this callback avoids duplicated data on the slow links used in the intervehicle and outer layers.
subscribed_funcCallback function for when a subscription request reaches a publisher for this data type
subscribe_expired_funcCallback function for when a subscription request expires without reaching any publishers (either because none exist or because the link(s) failed to transfer the request within the time to live).

Definition at line 53 of file subscriber.h.

◆ Subscriber() [2/2]

template<typename Data >
goby::middleware::Subscriber< Data >::Subscriber ( const goby::middleware::protobuf::TransporterConfig cfg,
subscribed_func_type  subscribed_func,
subscribe_expired_func_type  subscribe_expired_func = subscribe_expired_func_type(),
set_link_data_func_type  set_link_data_func = set_link_data_func_type() 
)
inline

Construct a Subscriber but without the group_func callback.

Definition at line 68 of file subscriber.h.

◆ ~Subscriber()

template<typename Data >
goby::middleware::Subscriber< Data >::~Subscriber ( )
inline

Definition at line 77 of file subscriber.h.

Member Function Documentation

◆ cfg()

template<typename Data >
const goby::middleware::protobuf::TransporterConfig& goby::middleware::Subscriber< Data >::cfg ( ) const
inline
Returns
the metadata configuration

Definition at line 80 of file subscriber.h.

◆ group()

template<typename Data >
Group goby::middleware::Subscriber< Data >::group ( const Data &  data) const
inline
Returns
the group for this subscribe call using the group_func. Only intended to be called by the various transporters.

Definition at line 83 of file subscriber.h.

◆ has_group_func()

template<typename Data >
bool goby::middleware::Subscriber< Data >::has_group_func ( ) const
inline

Definition at line 96 of file subscriber.h.

◆ set_link_data()

template<typename Data >
void goby::middleware::Subscriber< Data >::set_link_data ( Data &  data,
const intervehicle::protobuf::Header header 
) const
inline

Sets the link data in the message using the set_link_data_func. Only intended to be called by the various transporters.

Definition at line 99 of file subscriber.h.

◆ subscribe_expired_func()

template<typename Data >
subscribe_expired_func_type goby::middleware::Subscriber< Data >::subscribe_expired_func ( ) const
inline
Returns
the subscription request expired callback (or an empty function if none is set)

Definition at line 94 of file subscriber.h.

◆ subscribed_func()

template<typename Data >
subscribed_func_type goby::middleware::Subscriber< Data >::subscribed_func ( ) const
inline
Returns
the subscription successful callback (or an empty function if none is set)

Definition at line 92 of file subscriber.h.


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