Goby3  3.1.4
2024.02.22
goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter > Class Template Reference

Base class for implementing transporters (both portal and forwarder) for the intervehicle layer. More...

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

Inheritance diagram for goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >:
goby::middleware::StaticTransporterInterface< InterVehicleTransporterBase< Derived, InnerTransporter >, InnerTransporter > goby::middleware::Poller< InterVehicleTransporterBase< Derived, InnerTransporter > > goby::middleware::InnerTransporterInterface< InterVehicleTransporterBase< Derived, InnerTransporter >, InnerTransporter > goby::middleware::PollerInterface

Public Types

enum  SubscriptionAction { SubscriptionAction::SUBSCRIBE, SubscriptionAction::UNSUBSCRIBE }
 
- Public Types inherited from goby::middleware::InnerTransporterInterface< InterVehicleTransporterBase< Derived, InnerTransporter >, InnerTransporter >
using InnerTransporterType = InnerTransporter
 the InnerTransporter type (accessible for other uses) More...
 

Public Member Functions

 InterVehicleTransporterBase (InnerTransporter &inner)
 
 InterVehicleTransporterBase ()
 
virtual ~InterVehicleTransporterBase ()=default
 
template<const Group & group>
void check_validity ()
 Check validity of the Group for interthread use (at compile time) More...
 
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void publish_dynamic (const Data &data, const Group &group=Group(), const Publisher< Data > &publisher=Publisher< Data >())
 Publish a message using a run-time defined DynamicGroup (const reference variant). Where possible, prefer the static variant in StaticTransporterInterface::publish() More...
 
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void publish_dynamic (std::shared_ptr< const Data > data, const Group &group=Group(), const Publisher< Data > &publisher=Publisher< Data >())
 Publish a message using a run-time defined DynamicGroup (shared pointer to const data variant). Where possible, prefer the static variant in StaticTransporterInterface::publish() More...
 
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void publish_dynamic (std::shared_ptr< Data > data, const Group &group=Group(), const Publisher< Data > &publisher=Publisher< Data >())
 Publish a message using a run-time defined DynamicGroup (shared pointer to mutable data variant). Where possible, prefer the static variant in StaticTransporterInterface::publish() More...
 
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void subscribe_dynamic (std::function< void(const Data &)> f, const Group &group=Group(), const Subscriber< Data > &subscriber=Subscriber< Data >())
 Subscribe to a specific run-time defined group and data type (const reference variant). Where possible, prefer the static variant in StaticTransporterInterface::subscribe() More...
 
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void subscribe_dynamic (std::function< void(std::shared_ptr< const Data >)> f, const Group &group=Group(), const Subscriber< Data > &subscriber=Subscriber< Data >())
 Subscribe to a specific run-time defined group and data type (shared pointer variant). Where possible, prefer the static variant in StaticTransporterInterface::subscribe() More...
 
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void unsubscribe_dynamic (const Group &group=Group(), const Subscriber< Data > &subscriber=Subscriber< Data >())
 Unsubscribe from a specific run-time defined group and data type. Where possible, prefer the static variant in StaticTransporterInterface::unsubscribe() More...
 
- Public Member Functions inherited from goby::middleware::StaticTransporterInterface< InterVehicleTransporterBase< Derived, InnerTransporter >, InnerTransporter >
void publish (const Data &data, const Publisher< Data > &publisher=Publisher< Data >())
 Publish a message (const reference variant) More...
 
void publish (std::shared_ptr< const Data > data, const Publisher< Data > &publisher=Publisher< Data >())
 Publish a message (shared pointer to const data variant) More...
 
void publish (std::shared_ptr< Data > data, const Publisher< Data > &publisher=Publisher< Data >())
 Publish a message (shared pointer to mutable data variant) More...
 
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...
 
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...
 
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...
 
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< InterVehicleTransporterBase< Derived, InnerTransporter >, InnerTransporter >
InnerTransporter & inner ()
 
auto innermost ()
 
- Public Member Functions inherited from goby::middleware::PollerInterface
template<class Clock = std::chrono::system_clock, class Duration = typename Clock::duration>
int poll (const std::chrono::time_point< Clock, Duration > &timeout=std::chrono::time_point< Clock, Duration >::max())
 poll for data. Blocks until a data event occurs or a timeout when a particular time has been reached More...
 
template<class Clock = std::chrono::system_clock, class Duration = typename Clock::duration>
int poll (Duration wait_for)
 poll for data. Blocks until a data event occurs or a certain duration of time elapses (timeout) More...
 
std::shared_ptr< std::timed_mutex > poll_mutex ()
 access the mutex used for poll synchronization More...
 
std::shared_ptr< std::condition_variable_any > cv ()
 access the condition variable used for poll synchronization More...
 

Static Public Member Functions

template<typename Data >
static constexpr int scheme ()
 returns the marshalling scheme id for a given data type on this layer. Only MarshallingScheme::DCCL is currently supported More...
 

Protected Member Functions

template<typename Data >
std::shared_ptr< goby::middleware::protobuf::SerializerTransporterMessage_set_up_publish (const Data &d, const Group &group, const Publisher< Data > &publisher)
 
template<typename Data >
std::shared_ptr< intervehicle::protobuf::Subscription_set_up_subscribe (std::function< void(std::shared_ptr< const Data > d)> func, const Group &group, const Subscriber< Data > &subscriber, SubscriptionAction action)
 
template<int tuple_index, typename AckorExpirePair >
void _handle_ack_or_expire (const AckorExpirePair &ack_or_expire_pair)
 
void _receive (const intervehicle::protobuf::DCCLForwardedData &packets)
 
template<typename Data >
std::shared_ptr< intervehicle::protobuf::Subscription_serialize_subscription (const Group &group, const Subscriber< Data > &subscriber, SubscriptionAction action)
 
void _insert_pending_ack (int dccl_id, std::shared_ptr< goby::middleware::protobuf::SerializerTransporterMessage > data, std::shared_ptr< SerializationHandlerBase< intervehicle::protobuf::AckData >> ack_handler, std::shared_ptr< SerializationHandlerBase< intervehicle::protobuf::ExpireData >> expire_handler)
 
- Protected Member Functions inherited from goby::middleware::StaticTransporterInterface< InterVehicleTransporterBase< Derived, InnerTransporter >, InnerTransporter >
 StaticTransporterInterface (InnerTransporter &inner)
 
 StaticTransporterInterface ()
 
- Protected Member Functions inherited from goby::middleware::Poller< InterVehicleTransporterBase< Derived, InnerTransporter > >
 Poller (PollerInterface *inner_poller=nullptr)
 Construct this Poller with a pointer to the inner Poller (unless this is the innermost Poller) More...
 
PollerInterfaceinner_poller ()
 
- Protected Member Functions inherited from goby::middleware::PollerInterface
 PollerInterface (std::shared_ptr< std::timed_mutex > poll_mutex, std::shared_ptr< std::condition_variable_any > cv)
 

Protected Attributes

std::unordered_map< int, std::unordered_map< std::string, std::shared_ptr< const SerializationHandlerBase< intervehicle::protobuf::Header > > > > subscriptions_
 

Detailed Description

template<typename Derived, typename InnerTransporter>
class goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >

Base class for implementing transporters (both portal and forwarder) for the intervehicle layer.

Template Parameters
Derivedderived class (curiously recurring template pattern)
InnerTransporterinner layer transporter type

Definition at line 70 of file intervehicle.h.

Member Enumeration Documentation

◆ SubscriptionAction

template<typename Derived , typename InnerTransporter >
enum goby::middleware::InterVehicleTransporterBase::SubscriptionAction
strong
Enumerator
SUBSCRIBE 
UNSUBSCRIBE 

Definition at line 82 of file intervehicle.h.

Constructor & Destructor Documentation

◆ InterVehicleTransporterBase() [1/2]

template<typename Derived , typename InnerTransporter >
goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::InterVehicleTransporterBase ( InnerTransporter &  inner)
inline

Definition at line 88 of file intervehicle.h.

◆ InterVehicleTransporterBase() [2/2]

template<typename Derived , typename InnerTransporter >
goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::InterVehicleTransporterBase ( )
inline

Definition at line 111 of file intervehicle.h.

◆ ~InterVehicleTransporterBase()

template<typename Derived , typename InnerTransporter >
virtual goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::~InterVehicleTransporterBase ( )
virtualdefault

Member Function Documentation

◆ _handle_ack_or_expire()

template<typename Derived , typename InnerTransporter >
template<int tuple_index, typename AckorExpirePair >
void goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::_handle_ack_or_expire ( const AckorExpirePair &  ack_or_expire_pair)
inlineprotected

Definition at line 387 of file intervehicle.h.

◆ _insert_pending_ack()

template<typename Derived , typename InnerTransporter >
void goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::_insert_pending_ack ( int  dccl_id,
std::shared_ptr< goby::middleware::protobuf::SerializerTransporterMessage data,
std::shared_ptr< SerializationHandlerBase< intervehicle::protobuf::AckData >>  ack_handler,
std::shared_ptr< SerializationHandlerBase< intervehicle::protobuf::ExpireData >>  expire_handler 
)
inlineprotected

Definition at line 468 of file intervehicle.h.

◆ _receive()

template<typename Derived , typename InnerTransporter >
void goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::_receive ( const intervehicle::protobuf::DCCLForwardedData packets)
inlineprotected

Definition at line 430 of file intervehicle.h.

◆ _serialize_subscription()

template<typename Derived , typename InnerTransporter >
template<typename Data >
std::shared_ptr<intervehicle::protobuf::Subscription> goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::_serialize_subscription ( const Group group,
const Subscriber< Data > &  subscriber,
SubscriptionAction  action 
)
inlineprotected

Definition at line 444 of file intervehicle.h.

◆ _set_up_publish()

template<typename Derived , typename InnerTransporter >
template<typename Data >
std::shared_ptr<goby::middleware::protobuf::SerializerTransporterMessage> goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::_set_up_publish ( const Data &  d,
const Group group,
const Publisher< Data > &  publisher 
)
inlineprotected

Definition at line 261 of file intervehicle.h.

◆ _set_up_subscribe()

template<typename Derived , typename InnerTransporter >
template<typename Data >
std::shared_ptr<intervehicle::protobuf::Subscription> goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::_set_up_subscribe ( std::function< void(std::shared_ptr< const Data > d)>  func,
const Group group,
const Subscriber< Data > &  subscriber,
SubscriptionAction  action 
)
inlineprotected

Definition at line 302 of file intervehicle.h.

◆ check_validity()

template<typename Derived , typename InnerTransporter >
template<const Group & group>
void goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::check_validity ( )
inline

Check validity of the Group for interthread use (at compile time)

The layer requires a valid numeric group

Definition at line 127 of file intervehicle.h.

◆ publish_dynamic() [1/3]

template<typename Derived , typename InnerTransporter >
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::publish_dynamic ( const Data &  data,
const Group group = Group(),
const Publisher< Data > &  publisher = Publisher<Data>() 
)
inline

Publish a message using a run-time defined DynamicGroup (const reference variant). Where possible, prefer the static variant in StaticTransporterInterface::publish()

Template Parameters
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
groupgroup to publish this message to (typically a DynamicGroup). If a Publisher is provided, the group will be set in the data using Publisher::set_group()
publisherOptional metadata that controls the publication or sets callbacks to monitor the result.

Definition at line 142 of file intervehicle.h.

◆ publish_dynamic() [2/3]

template<typename Derived , typename InnerTransporter >
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::publish_dynamic ( std::shared_ptr< const Data >  data,
const Group group = Group(),
const Publisher< Data > &  publisher = Publisher<Data>() 
)
inline

Publish a message using a run-time defined DynamicGroup (shared pointer to const data variant). Where possible, prefer the static variant in StaticTransporterInterface::publish()

Template Parameters
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
groupgroup to publish this message to (typically a DynamicGroup). If a Publisher is provided, the group will be set in the data using Publisher::set_group()
publisherOptional metadata that controls the publication or sets callbacks to monitor the result.

Definition at line 167 of file intervehicle.h.

◆ publish_dynamic() [3/3]

template<typename Derived , typename InnerTransporter >
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::publish_dynamic ( std::shared_ptr< Data >  data,
const Group group = Group(),
const Publisher< Data > &  publisher = Publisher<Data>() 
)
inline

Publish a message using a run-time defined DynamicGroup (shared pointer to mutable data variant). Where possible, prefer the static variant in StaticTransporterInterface::publish()

Template Parameters
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
groupgroup to publish this message to (typically a DynamicGroup). If a Publisher is provided, the group will be set in the data using Publisher::set_group()
publisherOptional metadata that controls the publication or sets callbacks to monitor the result.

Definition at line 199 of file intervehicle.h.

◆ scheme()

template<typename Derived , typename InnerTransporter >
template<typename Data >
static constexpr int goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::scheme ( )
inlinestaticconstexpr

returns the marshalling scheme id for a given data type on this layer. Only MarshallingScheme::DCCL is currently supported

Definition at line 116 of file intervehicle.h.

◆ subscribe_dynamic() [1/2]

template<typename Derived , typename InnerTransporter >
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::subscribe_dynamic ( std::function< void(const Data &)>  f,
const Group group = Group(),
const Subscriber< Data > &  subscriber = Subscriber<Data>() 
)
inline

Subscribe to a specific run-time defined group and data type (const reference variant). Where possible, prefer the static variant in StaticTransporterInterface::subscribe()

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

Definition at line 213 of file intervehicle.h.

◆ subscribe_dynamic() [2/2]

template<typename Derived , typename InnerTransporter >
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::subscribe_dynamic ( std::function< void(std::shared_ptr< const Data >)>  f,
const Group group = Group(),
const Subscriber< Data > &  subscriber = Subscriber<Data>() 
)
inline

Subscribe to a specific run-time defined group and data type (shared pointer variant). Where possible, prefer the static variant in StaticTransporterInterface::subscribe()

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

Definition at line 231 of file intervehicle.h.

◆ unsubscribe_dynamic()

template<typename Derived , typename InnerTransporter >
template<typename Data , int scheme = goby::middleware::scheme<Data>()>
void goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::unsubscribe_dynamic ( const Group group = Group(),
const Subscriber< Data > &  subscriber = Subscriber<Data>() 
)
inline

Unsubscribe from a specific run-time defined group and data type. Where possible, prefer the static variant in StaticTransporterInterface::unsubscribe()

Template Parameters
Datadata type to unsubscribe from.
schemeMarshalling scheme id (typically MarshallingScheme::MarshallingSchemeEnum). Can usually be inferred from the Data type.
Parameters
groupgroup to subscribe to (typically a DynamicGroup)
subscriberOptional metadata that controls the subscription or sets callbacks to monitor the subscription result. Typically unnecessary for interprocess and inner layers.

Definition at line 248 of file intervehicle.h.

Member Data Documentation

◆ subscriptions_

template<typename Derived , typename InnerTransporter >
std::unordered_map< int, std::unordered_map<std::string, std::shared_ptr<const SerializationHandlerBase< intervehicle::protobuf::Header> > > > goby::middleware::InterVehicleTransporterBase< Derived, InnerTransporter >::subscriptions_
protected

Definition at line 487 of file intervehicle.h.


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