16#include <nlohmann/json.hpp>
19#include "../Endpoint.hpp"
125 friend class Channel;
165 Channel *
channel() const noexcept {
return _channel; }
169 Port *
port() const noexcept {
return _endpoint.port(); }
176 nlohmann::json
const &
config() const noexcept {
return _config; }
186 template<DerivedFromTransport T>
187 bool is() const noexcept {
return dynamic_cast<T
const *
>(
this) !=
nullptr; }
197 template<DerivedFromTransport T>
198 T &
as() noexcept {
return static_cast<T &
>(*this); }
208 template<DerivedFromTransport T>
209 T
const &
as() const noexcept {
return static_cast<T
const &
>(*this); }
218 virtual void stop() noexcept = 0;
222 void _attachToChannel(Channel *
channel);
228 nlohmann::json _config;
231 Channel * _channel =
nullptr;
Convenience macros to explicitly control copy and move semantics.
Orchestrator connecting a source transport to a destination transport.
Definition Channel.hpp:58
Definition Endpoint.hpp:24
Base class for both input and output ports.
Definition Port.hpp:66
Abstract base class for all message carriers within the dfx framework.
Definition Transport.hpp:124
Port * port() const noexcept
Gets the port associated with this transport.
Definition Transport.hpp:169
Endpoint const & endpoint() const noexcept
Gets the endpoint descriptor associated with this transport.
Definition Transport.hpp:161
bool isSource() const noexcept
Returns true if this transport is a source.
Definition Transport.hpp:156
NodePtr node() const noexcept
Gets the node associated with this transport.
Definition Transport.hpp:173
Channel * channel() const noexcept
Gets the channel which this transport is attached to if any.
Definition Transport.hpp:165
virtual ~Transport()=default
Virtual destructor ensuring proper cleanup of derived transports.
virtual void start(FdWatch::Poller &poller)=0
Activates the transport and begins I/O operations.
bool is() const noexcept
Check whether this transport is of a given derived type.
Definition Transport.hpp:187
bool isDestination() const noexcept
Returns true if this transport is a destination.
Definition Transport.hpp:158
T & as() noexcept
Cast this transport to a derived type (unchecked).
Definition Transport.hpp:198
DFX_DISABLE_COPY_AND_MOVE(Transport)
Transport is not copiable nor movable.
nlohmann::json const & config() const noexcept
Gets the JSON configuration used to initialize this transport.
Definition Transport.hpp:176
Role role() const noexcept
Returns the Role (Source or Destination) of this transport.
Definition Transport.hpp:153
virtual void stop() noexcept=0
Deactivates the transport and releases system resources.
Role
Defines the operational role of a transport relative to a channel.
Definition Transport.hpp:130
@ Destination
The transport acts as a message consumer for the channel.
Definition Transport.hpp:132
@ Source
The transport acts as a message producer for the channel.
Definition Transport.hpp:131
Transport(Role role, Endpoint endpoint, nlohmann::json config)
Constructs a transport instance.
T const & as() const noexcept
Cast this transport to a derived type (unchecked).
Definition Transport.hpp:209
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
Concept used by dfx::Core::Transport::as() and dfx::Core::Transport::is() to constrain types.
Definition Transport.hpp:97
Definition Channel.hpp:25
std::unique_ptr< Transport > TransportPtr
Unique ownership handle for transports.
Definition Transport.hpp:235
std::shared_ptr< Node > NodePtr
Shared ownership pointer type for Nodes..
Definition Endpoint.hpp:21
Definition SocketClient.hpp:23