Template Class GatewayGeneric

Inheritance Relationships

Base Type

Class Documentation

template<typename channel_t, typename gateway_t = GatewayBase>
class GatewayGeneric : public iox::gw::GatewayBase

A reference generic gateway implementation.

This class can be extended to quickly implement any type of gateway, only custom initialization, configuration, discovery and forwarding logic needs to be provided.

When run, the gateway will automatically call the respective methods when required.

Public Functions

virtual ~GatewayGeneric() noexcept
GatewayGeneric(const GatewayGeneric&) = delete
GatewayGeneric &operator=(const GatewayGeneric&) = delete
GatewayGeneric(GatewayGeneric&&) = delete
GatewayGeneric &operator=(GatewayGeneric&&) = delete
void runMultithreaded() noexcept
void shutdown() noexcept
virtual void loadConfiguration(const config::GatewayConfig &config) noexcept = 0

loadConfiguration Load the provided configuration.

Parameters:

config – A generic gateway implementation.

virtual void discover(const capro::CaproMessage &msg) noexcept = 0

discover Process discovery messages coming from iceoryx.

Parameters:

msg – The discovery message.

virtual void forward(const channel_t &channel) noexcept = 0

forward Forward data between the two terminals of the channel used by the implementation.

Parameters:

channel – The channel to propogate data across.

uint64_t getNumberOfChannels() const noexcept

Protected Functions

GatewayGeneric(capro::Interfaces interface, units::Duration discoveryPeriod = 1000_ms, units::Duration forwardingPeriod = 50_ms) noexcept
template<typename IceoryxPubSubOptions>
cxx::expected<channel_t, GatewayError> addChannel(const capro::ServiceDescription &service, const IceoryxPubSubOptions &options) noexcept

addChannel Creates a channel for the given service and stores a copy of it in an internal collection for later access.

The service description is perhaps too large for copying since they contain strings, however this should be addressed with a service description repository feature.

Note

Wildcard services are not allowed and will be ignored.

Note

Channels are supposed to be lightweight, consisting only of pointers to the terminals and a copy of the service description, therefore a copy is provided to any entity that requires them. When no more copies of a channel exists in the system, the terminals will automatically be cleaned up via the custom deleters included in their pointers.

Parameters:
  • service – The service to create a channel for.

  • options – The PublisherOptions or SubscriberOptions with historyCapacity and queueCapacity.

Returns:

an expected containing a copy of the added channel, otherwise an error

cxx::optional<channel_t> findChannel(const capro::ServiceDescription &service) const noexcept

findChannel Searches for a channel for the given service in the internally stored collection and returns it one exists.

Parameters:

service – The service to find a channel for.

Returns:

An optional containining the matching channel if one exists, otherwise an empty optional.

void forEachChannel(const cxx::function_ref<void(channel_t&)> f) const noexcept

forEachChannel Executs the given function for each channel in the internally stored collection.

Note

This operation allows thread-safe access to the internal collection.

Parameters:

f – The function to execute.

cxx::expected<GatewayError> discardChannel(const capro::ServiceDescription &service) noexcept

discardChannel Discard the channel for the given service in the internal collection if one exists.

Parameters:

service – The service whose channels hiould be discarded.

Returns:

an empty expected on success, otherwise an error