dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
dfx::Core::Transport Class Referenceabstract

Abstract base class for all message carriers within the dfx framework. More...

#include <dfx-core/transports/Transport.hpp>

Inheritance diagram for dfx::Core::Transport:
[legend]
Collaboration diagram for dfx::Core::Transport:
[legend]

Public Types

enum class  Role { Source , Destination }
 Defines the operational role of a transport relative to a channel. More...

Public Member Functions

 Transport (Role role, Endpoint endpoint, nlohmann::json config)
 Constructs a transport instance.
 DFX_DISABLE_COPY_AND_MOVE (Transport)
 Transport is not copiable nor movable.
virtual ~Transport ()=default
 Virtual destructor ensuring proper cleanup of derived transports.
template<DerivedFromTransport T>
bool is () const noexcept
 Check whether this transport is of a given derived type.
template<DerivedFromTransport T>
T & as () noexcept
 Cast this transport to a derived type (unchecked).
template<DerivedFromTransport T>
T const & as () const noexcept
 Cast this transport to a derived type (unchecked).
virtual void start (FdWatch::Poller &poller)=0
 Activates the transport and begins I/O operations.
virtual void stop () noexcept=0
 Deactivates the transport and releases system resources.
Introspection
Role role () const noexcept
 Returns the Role (Source or Destination) of this transport.
bool isSource () const noexcept
 Returns true if this transport is a source.
bool isDestination () const noexcept
 Returns true if this transport is a destination.
Endpoint const & endpoint () const noexcept
 Gets the endpoint descriptor associated with this transport.
Channelchannel () const noexcept
 Gets the channel which this transport is attached to if any.
Portport () const noexcept
 Gets the port associated with this transport.
NodePtr node () const noexcept
 Gets the node associated with this transport.
nlohmann::json const & config () const noexcept
 Gets the JSON configuration used to initialize this transport.

Protected Attributes

Role const _role
Endpoint _endpoint
nlohmann::json _config

Friends

class Channel

Detailed Description

Abstract base class for all message carriers within the dfx framework.

A Transport encapsulates the physical or logical mechanism used to move data across a Channel. It abstracts the "how" of message delivery—whether via local memory copies, POSIX message queues, or network sockets—allowing the rest of the graph to remain transport-agnostic.

Lifecycle and Initialization

Transports are designed to decouple configuration from activation. This is critical for scenarios like graph validation or GUI editors where objects need to be inspected without opening live sockets or file descriptors.

  • Construction: Validates the Endpoint and JSON configuration. No external resources (sockets, FDs) are acquired here.
  • Attachment: The Transport is linked to a Channel during Channel construction.
  • Start: Invoked during Node::start. This is where the transport joins the FdWatch::Poller and begins active I/O.
  • Stop: Invoked during Node::stop. Closes resources and stops I/O.

Transport Roles

Every transport plays a specific Role :

Member Enumeration Documentation

◆ Role

enum class dfx::Core::Transport::Role
strong

Defines the operational role of a transport relative to a channel.

Enumerator
Source 

The transport acts as a message producer for the channel.

Destination 

The transport acts as a message consumer for the channel.

Constructor & Destructor Documentation

◆ Transport()

dfx::Core::Transport::Transport ( Role role,
Endpoint endpoint,
nlohmann::json config )

Constructs a transport instance.

Parameters
roleThe role (Source or Destination) this transport plays.
endpointThe descriptor identifying this endpoint.
configAdditional Transport-specific JSON configuration.

◆ ~Transport()

virtual dfx::Core::Transport::~Transport ( )
virtualdefault

Virtual destructor ensuring proper cleanup of derived transports.

Member Function Documentation

◆ as() [1/2]

template<DerivedFromTransport T>
T const & dfx::Core::Transport::as ( ) const
inlinenoexcept

Cast this transport to a derived type (unchecked).

Template Parameters
TA type derived from Transport.
Returns
Reference to the transport as T.
Warning
This is a static_cast. Only call it if you are sure of the type, or check first with is.

◆ as() [2/2]

template<DerivedFromTransport T>
T & dfx::Core::Transport::as ( )
inlinenoexcept

Cast this transport to a derived type (unchecked).

Template Parameters
TA type derived from Transport.
Returns
Reference to the transport as T.
Warning
This is a static_cast. Only call it if you are sure of the type, or check first with is.

◆ channel()

Channel * dfx::Core::Transport::channel ( ) const
inlinenoexcept

Gets the channel which this transport is attached to if any.

Returns
nullptr if this transport isn't attached to a channel yet.

◆ config()

nlohmann::json const & dfx::Core::Transport::config ( ) const
inlinenoexcept

Gets the JSON configuration used to initialize this transport.

◆ DFX_DISABLE_COPY_AND_MOVE()

dfx::Core::Transport::DFX_DISABLE_COPY_AND_MOVE ( Transport )

Transport is not copiable nor movable.

◆ endpoint()

Endpoint const & dfx::Core::Transport::endpoint ( ) const
inlinenoexcept

Gets the endpoint descriptor associated with this transport.

◆ is()

template<DerivedFromTransport T>
bool dfx::Core::Transport::is ( ) const
inlinenoexcept

Check whether this transport is of a given derived type.

Template Parameters
TA type derived from Transport.
Returns
true if dynamic_cast<T const*>(this) succeeds.

◆ isDestination()

bool dfx::Core::Transport::isDestination ( ) const
inlinenoexcept

Returns true if this transport is a destination.

◆ isSource()

bool dfx::Core::Transport::isSource ( ) const
inlinenoexcept

Returns true if this transport is a source.

◆ node()

NodePtr dfx::Core::Transport::node ( ) const
inlinenoexcept

Gets the node associated with this transport.

Returns
nullptr if the transport isn't attached to a local node.

◆ port()

Port * dfx::Core::Transport::port ( ) const
inlinenoexcept

Gets the port associated with this transport.

Returns
nullptr if the transport isn't attached to a local port.

◆ role()

Role dfx::Core::Transport::role ( ) const
inlinenoexcept

Returns the Role (Source or Destination) of this transport.

◆ start()

virtual void dfx::Core::Transport::start ( FdWatch::Poller & poller)
pure virtual

Activates the transport and begins I/O operations.

Parameters
pollerThe event loop poller used to watch File Descriptors.

Implemented in dfx::Core::LocalDestination, dfx::Core::LocalSource, dfx::Core::MqDestination, dfx::Core::MqSource, dfx::Core::UdpDestination, dfx::Core::UdpSource, dfx::Plugins::CDestinationTransport, and dfx::Plugins::CSourceTransport.

◆ stop()

virtual void dfx::Core::Transport::stop ( )
pure virtualnoexcept

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