Goby3  3.1.4
2024.02.22
goby::middleware::Publisher< Data > Class Template Reference

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

#include <goby/middleware/transport/intervehicle/driver_thread.h>

Public Types

using set_group_func_type = std::function< void(Data &, const Group &)>
 
using acked_func_type = std::function< void(const Data &, const intervehicle::protobuf::AckData &)>
 
using expired_func_type = std::function< void(const Data &, const intervehicle::protobuf::ExpireData &)>
 

Public Member Functions

 Publisher (const goby::middleware::protobuf::TransporterConfig &cfg=goby::middleware::protobuf::TransporterConfig(), set_group_func_type set_group_func=set_group_func_type(), acked_func_type acked_func=acked_func_type(), expired_func_type expired_func=expired_func_type())
 Construct a Publisher with all available metadata and callbacks. More...
 
 Publisher (const goby::middleware::protobuf::TransporterConfig &cfg, acked_func_type acked_func, expired_func_type expired_func=expired_func_type())
 Construct a Publisher but without the set_group_func callback. More...
 
 ~Publisher ()
 
const goby::middleware::protobuf::TransporterConfigcfg () const
 Returns the metadata configuration. More...
 
void set_group (Data &data, const Group &group) const
 Sets the group using the set_group_func. Only intended to be called by the various transporters. More...
 
acked_func_type acked_func () const
 Returns the acked data callback (or an empty function if none is set) More...
 
expired_func_type expired_func () const
 Returns the expired data callback (or an empty function if none is set) More...
 
bool has_set_group_func () const
 

Detailed Description

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

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

Definition at line 69 of file driver_thread.h.

Member Typedef Documentation

◆ acked_func_type

template<typename Data >
using goby::middleware::Publisher< Data >::acked_func_type = std::function<void(const Data&, const intervehicle::protobuf::AckData&)>

Definition at line 44 of file publisher.h.

◆ expired_func_type

template<typename Data >
using goby::middleware::Publisher< Data >::expired_func_type = std::function<void(const Data&, const intervehicle::protobuf::ExpireData&)>

Definition at line 46 of file publisher.h.

◆ set_group_func_type

template<typename Data >
using goby::middleware::Publisher< Data >::set_group_func_type = std::function<void(Data&, const Group&)>

Definition at line 42 of file publisher.h.

Constructor & Destructor Documentation

◆ Publisher() [1/2]

Construct a Publisher with all available metadata and callbacks.

Parameters
cfgAdditional metadata for all publish calls for which this Publisher is provided
set_group_funcCallback function for setting the group for a given data type if not provided in the parameters to the publish 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 by setting the group value in the message contents itself (as opposed to transmitted in the header).
acked_funcCallback function for when data is acknowledged by subscribers to this publication
expired_funcCallback function for when data expires without reaching any subscribers (either because none exist or because the link(s) failed to transfer the data within the time to live).

Definition at line 54 of file publisher.h.

◆ Publisher() [2/2]

template<typename Data >
goby::middleware::Publisher< Data >::Publisher ( const goby::middleware::protobuf::TransporterConfig cfg,
acked_func_type  acked_func,
expired_func_type  expired_func = expired_func_type() 
)
inline

Construct a Publisher but without the set_group_func callback.

Definition at line 72 of file publisher.h.

◆ ~Publisher()

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

Definition at line 78 of file publisher.h.

Member Function Documentation

◆ acked_func()

template<typename Data >
acked_func_type goby::middleware::Publisher< Data >::acked_func ( ) const
inline

Returns the acked data callback (or an empty function if none is set)

Definition at line 91 of file publisher.h.

◆ cfg()

template<typename Data >
const goby::middleware::protobuf::TransporterConfig& goby::middleware::Publisher< Data >::cfg ( ) const
inline

Returns the metadata configuration.

Definition at line 81 of file publisher.h.

◆ expired_func()

template<typename Data >
expired_func_type goby::middleware::Publisher< Data >::expired_func ( ) const
inline

Returns the expired data callback (or an empty function if none is set)

Definition at line 93 of file publisher.h.

◆ has_set_group_func()

template<typename Data >
bool goby::middleware::Publisher< Data >::has_set_group_func ( ) const
inline

Definition at line 95 of file publisher.h.

◆ set_group()

template<typename Data >
void goby::middleware::Publisher< Data >::set_group ( Data &  data,
const Group group 
) const
inline

Sets the group using the set_group_func. Only intended to be called by the various transporters.

Definition at line 84 of file publisher.h.


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