Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches
goby::middleware::InterProcessForwarder< InnerTransporter > Class Template Reference

Implements the forwarder concept for the interprocess layer. More...

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

Inheritance diagram for goby::middleware::InterProcessForwarder< InnerTransporter >:
goby::middleware::InterProcessTransporterBase< InterProcessForwarder< InnerTransporter >, InnerTransporter > goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter > goby::middleware::Poller< Transporter > goby::middleware::InnerTransporterInterface< Transporter, InnerTransporter, Enable > goby::middleware::PollerInterface

Public Types

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

Public Member Functions

 InterProcessForwarder (InnerTransporter &inner)
 Construct a forwarder for the interprocess layer.
 
virtual ~InterProcessForwarder ()
 
- Public Member Functions inherited from goby::middleware::InterProcessTransporterBase< InterProcessForwarder< InnerTransporter >, InnerTransporter >
 InterProcessTransporterBase (InnerTransporter &inner)
 
 InterProcessTransporterBase ()
 
virtual ~InterProcessTransporterBase ()
 
void publish_dynamic (const Data &data, const 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()
 
void publish_dynamic (std::shared_ptr< const Data > data, const 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()
 
void publish_dynamic (std::shared_ptr< Data > data, const 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()
 
void publish_serialized (std::string type_name, int scheme, const std::vector< char > &bytes, const goby::middleware::Group &group)
 Publish a message that has already been serialized for the given scheme.
 
void subscribe_dynamic (std::function< void(const Data &)> f, const 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()
 
void subscribe_dynamic (std::function< void(std::shared_ptr< const Data >)> f, const 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()
 
void unsubscribe_dynamic (const Group &group, const Subscriber< Data > &subscriber=Subscriber< Data >())
 Unsubscribe to a specific run-time defined group and data type. Where possible, prefer the static variant in StaticTransporterInterface::unsubscribe()
 
void unsubscribe_all ()
 Unsubscribe from all current subscriptions.
 
std::shared_ptr< SerializationSubscriptionRegexsubscribe_regex (std::function< void(const std::vector< unsigned char > &, int scheme, const std::string &type, const Group &group)> f, const std::set< int > &schemes, const std::string &type_regex=".*", const std::string &group_regex=".*")
 Subscribe to multiple groups and/or types at once using regular expressions.
 
std::shared_ptr< SerializationSubscriptionRegexsubscribe_type_regex (std::function< void(std::shared_ptr< const Data >, const std::string &type)> f, const Group &group, const std::string &type_regex=".*")
 Subscribe to a number of types within a given group and scheme using a regular expression.
 
void subscribe_type_regex (std::function< void(std::shared_ptr< const Data >, const std::string &type)> f, const std::string &type_regex=".*")
 Subscribe to a number of types within a given group and scheme using a regular expression.
 
void check_validity ()
 Check validity of the Group for interthread use (at compile time)
 
void check_validity_runtime (const Group &group)
 Check validity of the Group for interthread use (for DynamicGroup at run time)
 
- Public Member Functions inherited from goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >
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)
 
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)
 
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)
 
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)
 
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)
 
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.
 
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.
 
void unsubscribe_all ()
 Unsubscribe to all messages that this transporter has subscribed to.
 
- Public Member Functions inherited from goby::middleware::InnerTransporterInterface< Transporter, InnerTransporter, Enable >
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
 
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)
 
std::shared_ptr< std::timed_mutex > poll_mutex ()
 access the mutex used for poll synchronization
 
std::shared_ptr< std::condition_variable_any > cv ()
 access the condition variable used for poll synchronization
 

Public Attributes

friend Base
 

Additional Inherited Members

- Static Public Member Functions inherited from goby::middleware::InterProcessTransporterBase< InterProcessForwarder< InnerTransporter >, InnerTransporter >
static constexpr int scheme ()
 returns the marshalling scheme id for a given data type on this layer
 
- Protected Member Functions inherited from goby::middleware::StaticTransporterInterface< Transporter, InnerTransporter >
 StaticTransporterInterface (InnerTransporter &inner)
 
 StaticTransporterInterface ()
 
- Protected Member Functions inherited from goby::middleware::Poller< Transporter >
 Poller (PollerInterface *inner_poller=nullptr)
 Construct this Poller with a pointer to the inner Poller (unless this is the innermost Poller)
 
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)
 
- Static Protected Attributes inherited from goby::middleware::InterProcessTransporterBase< InterProcessForwarder< InnerTransporter >, InnerTransporter >
static constexpr Group to_portal_group_
 
static constexpr Group regex_group_
 
static constexpr Group from_portal_group_
 

Detailed Description

template<typename InnerTransporter>
class goby::middleware::InterProcessForwarder< InnerTransporter >

Implements the forwarder concept for the interprocess layer.

The forwarder is intended to be used by inner nodes within the layer that do not connect directly to other nodes on that layer. For example, the main thread might instantiate a portal and then spawn several threads that instantiate forwarders. These auxiliary threads can then communicate on the interprocess layer as if they had a direct connection to other interprocess nodes.

Template Parameters
InnerTransporterThe type of the inner transporter used to forward data to and from this node

Definition at line 297 of file interprocess.h.

Member Typedef Documentation

◆ Base

template<typename InnerTransporter >
using goby::middleware::InterProcessForwarder< InnerTransporter >::Base = InterProcessTransporterBase<InterProcessForwarder<InnerTransporter>, InnerTransporter>

Definition at line 301 of file interprocess.h.

Constructor & Destructor Documentation

◆ InterProcessForwarder()

template<typename InnerTransporter >
goby::middleware::InterProcessForwarder< InnerTransporter >::InterProcessForwarder ( InnerTransporter &  inner)
inline

Construct a forwarder for the interprocess layer.

Parameters
innerA reference to the inner transporter used to forward messages to and from the portal

Definition at line 307 of file interprocess.h.

◆ ~InterProcessForwarder()

template<typename InnerTransporter >
virtual goby::middleware::InterProcessForwarder< InnerTransporter >::~InterProcessForwarder ( )
inlinevirtual

Definition at line 316 of file interprocess.h.

Member Data Documentation

◆ Base

template<typename InnerTransporter >
friend goby::middleware::InterProcessForwarder< InnerTransporter >::Base

Definition at line 324 of file interprocess.h.


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