18 #ifndef IOX_POSH_GW_GATEWAY_GENERIC_HPP
19 #define IOX_POSH_GW_GATEWAY_GENERIC_HPP
21 #include "iceoryx_posh/capro/service_description.hpp"
22 #include "iceoryx_posh/gateway/gateway_base.hpp"
23 #include "iceoryx_posh/gateway/gateway_config.hpp"
24 #include "iceoryx_posh/iceoryx_posh_config.hpp"
25 #include "iceoryx_posh/iceoryx_posh_types.hpp"
26 #include "iceoryx_utils/cxx/expected.hpp"
27 #include "iceoryx_utils/cxx/function_ref.hpp"
28 #include "iceoryx_utils/cxx/optional.hpp"
29 #include "iceoryx_utils/cxx/string.hpp"
30 #include "iceoryx_utils/cxx/vector.hpp"
31 #include "iceoryx_utils/internal/concurrent/smart_lock.hpp"
32 #include "iceoryx_utils/internal/units/duration.hpp"
41 using namespace iox::units::duration_literals;
43 enum class GatewayError : uint8_t
46 UNSUPPORTED_SERVICE_TYPE,
47 UNSUCCESSFUL_CHANNEL_CREATION,
58 template <
typename channel_t,
typename gateway_t = GatewayBase>
61 using ChannelVector = cxx::vector<channel_t, MAX_CHANNEL_NUMBER>;
62 using ConcurrentChannelVector = concurrent::smart_lock<ChannelVector>;
72 void runMultithreaded() noexcept;
73 void shutdown() noexcept;
89 virtual void forward(
const channel_t& channel) noexcept = 0;
91 uint64_t getNumberOfChannels() const noexcept;
95 units::Duration discoveryPeriod = 1000_ms,
96 units::Duration forwardingPeriod = 50_ms) noexcept;
115 template <typename IceoryxPubSubOptions>
116 cxx::expected<channel_t, GatewayError> addChannel(const capro::ServiceDescription& service,
117 const IceoryxPubSubOptions& options) noexcept;
125 cxx::optional<channel_t> findChannel(const capro::ServiceDescription& service) const noexcept;
132 void forEachChannel(const cxx::function_ref<
void(channel_t&)> f) const noexcept;
139 cxx::expected<GatewayError> discardChannel(const capro::ServiceDescription& service) noexcept;
142 ConcurrentChannelVector m_channels;
144 std::atomic_bool m_isRunning{
false};
146 units::Duration m_discoveryPeriod;
147 units::Duration m_forwardingPeriod;
149 std::thread m_discoveryThread;
150 std::thread m_forwardingThread;
152 void forwardingLoop() noexcept;
153 void discoveryLoop() noexcept;
159 #include "iceoryx_posh/internal/gateway/gateway_generic.inl"
C'tors for CaPro messages.
Definition: capro_message.hpp:60
A reference generic gateway implementation.
Definition: gateway_generic.hpp:60
virtual void discover(const capro::CaproMessage &msg) noexcept=0
discover Process discovery messages coming from iceoryx.
virtual void loadConfiguration(const config::GatewayConfig &config) noexcept=0
loadConfiguration Load the provided configuration.
virtual void forward(const channel_t &channel) noexcept=0
forward Forward data between the two terminals of the channel used by the implementation.
Definition: service_description.hpp:29
Generic configuration for gateways.
Definition: gateway_config.hpp:32