Goby3  3.1.5a
2024.05.23
goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter > Class Template Reference

Defines the common interface for publishing and subscribing data using static (constexpr) groups on Goby transporters. More...

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

Inheritance diagram for goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >:
goby::middleware::InnerTransporterInterface< Transporter, InnerTransporter >

Public Member Functions

template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>()>
void publish (const Data &data, const Publisher< Data > &publisher=Publisher< Data >())
 Publish a message (const reference variant) More...
 
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>()>
void publish (std::shared_ptr< const Data > data, const Publisher< Data > &publisher=Publisher< Data >())
 Publish a message (shared pointer to const data variant) More...
 
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>()>
void publish (std::shared_ptr< Data > data, const Publisher< Data > &publisher=Publisher< Data >())
 Publish a message (shared pointer to mutable data variant) More...
 
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>(), Necessity necessity = Necessity::OPTIONAL>
void subscribe (std::function< void(const Data &)> f, const Subscriber< Data > &subscriber=Subscriber< Data >())
 Subscribe to a specific group and data type (const reference variant) More...
 
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>(), Necessity necessity = Necessity::OPTIONAL>
void subscribe (std::function< void(std::shared_ptr< const Data >)> f, const Subscriber< Data > &subscriber=Subscriber< Data >())
 Subscribe to a specific group and data type (shared pointer variant) More...
 
template<const Group & group, Necessity necessity = Necessity::OPTIONAL, typename Func >
void subscribe (Func f)
 Simplified version of subscribe() that can deduce Data from the first argument of the function (lambda, function pointer, etc.) passed to it. More...
 
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>()>
void unsubscribe (const Subscriber< Data > &subscriber=Subscriber< Data >())
 Unsubscribe to a specific group and data type. More...
 
void unsubscribe_all ()
 Unsubscribe to all messages that this transporter has subscribed to. More...
 
- Public Member Functions inherited from goby::middleware::InnerTransporterInterface< Transporter, InnerTransporter >
InnerTransporter & inner ()
 
auto innermost ()
 

Protected Member Functions

 StaticTransporterInterface (InnerTransporter &inner)
 
 StaticTransporterInterface ()
 

Additional Inherited Members

- Public Types inherited from goby::middleware::InnerTransporterInterface< Transporter, InnerTransporter >
using InnerTransporterType = InnerTransporter
 the InnerTransporter type (accessible for other uses) More...
 

Detailed Description

template<typename Transporter, typename InnerTransporter>
class goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >

Defines the common interface for publishing and subscribing data using static (constexpr) groups on Goby transporters.

Template Parameters
TransporterThe transporter for which this interface applies (derived class)
InnerTransporterThe inner layer transporter type (or NullTransporter if this is the innermost layer)

Definition at line 203 of file interface.h.

Constructor & Destructor Documentation

◆ StaticTransporterInterface() [1/2]

template<typename Transporter , typename InnerTransporter >
goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >::StaticTransporterInterface ( InnerTransporter &  inner)
inlineprotected

Definition at line 334 of file interface.h.

◆ StaticTransporterInterface() [2/2]

template<typename Transporter , typename InnerTransporter >
goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >::StaticTransporterInterface ( )
inlineprotected

Definition at line 338 of file interface.h.

Member Function Documentation

◆ publish() [1/3]

template<typename Transporter , typename InnerTransporter >
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>()>
void goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >::publish ( const Data &  data,
const Publisher< Data > &  publisher = Publisher<Data>() 
)
inline

Publish a message (const reference variant)

Template Parameters
groupgroup to publish this message to (reference to constexpr Group)
Datadata type to publish. Can usually be inferred from the data parameter.
schemeMarshalling scheme id (typically MarshallingScheme::MarshallingSchemeEnum). Can usually be inferred from the Data type.
Parameters
dataMessage to publish
publisherOptional metadata that controls the publication or sets callbacks to monitor the result. Typically unnecessary for interprocess and inner layers.

Definition at line 215 of file interface.h.

◆ publish() [2/3]

template<typename Transporter , typename InnerTransporter >
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>()>
void goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >::publish ( std::shared_ptr< const Data >  data,
const Publisher< Data > &  publisher = Publisher<Data>() 
)
inline

Publish a message (shared pointer to const data variant)

Template Parameters
groupgroup to publish this message to (reference to constexpr Group)
Datadata type to publish. Can usually be inferred from the data parameter.
schemeMarshalling scheme id (typically MarshallingScheme::MarshallingSchemeEnum). Can usually be inferred from the Data type.
Parameters
dataShared pointer to message to publish
publisherOptional metadata that controls the publication or sets callbacks to monitor the result. Typically unnecessary for interprocess and inner layers.

The shared pointer variants will likely be more efficient than the const reference variant when using interthread comms as no copy of the data is necessary. Note: need both const and non-const shared_ptr overload to ensure that the const& overload isn't preferred to these.

Definition at line 234 of file interface.h.

◆ publish() [3/3]

template<typename Transporter , typename InnerTransporter >
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>()>
void goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >::publish ( std::shared_ptr< Data >  data,
const Publisher< Data > &  publisher = Publisher<Data>() 
)
inline

Publish a message (shared pointer to mutable data variant)

Template Parameters
groupgroup to publish this message to (reference to constexpr Group)
Datadata type to publish. Can usually be inferred from the data parameter.
schemeMarshalling scheme id (typically MarshallingScheme::MarshallingSchemeEnum). Can usually be inferred from the Data type.
Parameters
dataShared pointer to message to publish
publisherOptional metadata that controls the publication or sets callbacks to monitor the result. Typically unnecessary for interprocess and inner layers.

The shared pointer variants will likely be more efficient than the const reference variant when using interthread comms as no copy of the data is necessary. Note: need both const and non-const shared_ptr overload to ensure that the const& overload isn't preferred to these.

Definition at line 254 of file interface.h.

◆ subscribe() [1/3]

template<typename Transporter , typename InnerTransporter >
template<const Group & group, Necessity necessity = Necessity::OPTIONAL, typename Func >
void goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >::subscribe ( Func  f)
inline

Simplified version of subscribe() that can deduce Data from the first argument of the function (lambda, function pointer, etc.) passed to it.

Template Parameters
groupgroup to subscribe to (reference to constexpr Group)
necessityHow important is this subscription (is it required?)
FuncFunction of a form accepted by other overloads of subscribe()
Parameters
fCallback function or lambda that is called upon receipt of the subscribed data

This removes the need to explicitly specify Data for simple calls to subscribe() that do not need to manually specify the 'scheme' or provide a Subscriber.

Definition at line 307 of file interface.h.

◆ subscribe() [2/3]

template<typename Transporter , typename InnerTransporter >
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>(), Necessity necessity = Necessity::OPTIONAL>
void goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >::subscribe ( std::function< void(const Data &)>  f,
const Subscriber< Data > &  subscriber = Subscriber<Data>() 
)
inline

Subscribe to a specific group and data type (const reference variant)

Template Parameters
groupgroup to subscribe to (reference to constexpr Group)
Datadata type to subscribe to.
schemeMarshalling scheme id (typically MarshallingScheme::MarshallingSchemeEnum). Can usually be inferred from the Data type.
necessityHow important is this subscription (is it required?)
Parameters
fCallback function or lambda that is called upon receipt of the subscribed data
subscriberOptional metadata that controls the subscription or sets callbacks to monitor the subscription result. Typically unnecessary for interprocess and inner layers.

Definition at line 270 of file interface.h.

◆ subscribe() [3/3]

template<typename Transporter , typename InnerTransporter >
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>(), Necessity necessity = Necessity::OPTIONAL>
void goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >::subscribe ( std::function< void(std::shared_ptr< const Data >)>  f,
const Subscriber< Data > &  subscriber = Subscriber<Data>() 
)
inline

Subscribe to a specific group and data type (shared pointer variant)

Template Parameters
groupgroup to subscribe to (reference to constexpr Group)
Datadata type to subscribe to.
schemeMarshalling scheme id (typically MarshallingScheme::MarshallingSchemeEnum). Can usually be inferred from the Data type.
necessityHow important is this subscription (is it required?)
Parameters
fCallback function or lambda that is called upon receipt of the subscribed data
subscriberOptional metadata that controls the subscription or sets callbacks to monitor the subscription result. Typically unnecessary for interprocess and inner layers.

Definition at line 289 of file interface.h.

◆ unsubscribe()

template<typename Transporter , typename InnerTransporter >
template<const Group & group, typename Data , int scheme = transporter_scheme<Data, Transporter>()>
void goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >::unsubscribe ( const Subscriber< Data > &  subscriber = Subscriber<Data>())
inline

Unsubscribe to a specific group and data type.

Template Parameters
groupgroup to unsubscribe from (reference to constexpr Group)
Datadata type to unsubscribe from.
schemeMarshalling scheme id (typically MarshallingScheme::MarshallingSchemeEnum). Can usually be inferred from the Data type.

Definition at line 323 of file interface.h.

◆ unsubscribe_all()

template<typename Transporter , typename InnerTransporter >
void goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >::unsubscribe_all ( )
inline

Unsubscribe to all messages that this transporter has subscribed to.

Definition at line 331 of file interface.h.


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