dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
TransportFactory.hpp
1// SPDX-FileCopyrightText: 2026 Vincent Leroy
2// SPDX-License-Identifier: MIT
3//
4// This file is part of dfx.
5//
6// Licensed under the MIT License. See the LICENSE file in the project root
7// for full license information.
8
9#pragma once
10
11// Standard includes
12#include <functional>
13
14// Project includes
15#include <dfx-core/transports/destinations/DestinationTransport.hpp>
16#include <dfx-core/transports/sources/SourceTransport.hpp>
17#include <dfx-utilities/StringMap.hpp>
18
19namespace dfx::Graph
20{
21class Controller;
22
40{
41public:
46 using SourceBuilder = std::move_only_function<Core::SourceTransportPtr (Core::Endpoint, nlohmann::json)>;
47
52 using DestinationBuilder = std::move_only_function<Core::DestinationTransportPtr (Core::Endpoint, nlohmann::json)>;
53
54public:
59
60public:
69 void registerBuilder(std::string scheme, SourceBuilder sourceBuilder, DestinationBuilder destinationBuilder);
70
86 Core::SourceTransportPtr createSource(std::string_view uri, nlohmann::json config,
87 Controller & controller);
88
99 Controller & controller);
100
113 Core::DestinationTransportPtr createDestination(std::string_view uri, nlohmann::json config,
114 Controller & controller);
115
125 Core::DestinationTransportPtr createDestination(Core::Endpoint::Descriptor descriptor, nlohmann::json config,
126 Controller & controller);
127
128public:
139
147
148private:
151};
152} // !namespace dfx::Graph
Definition Endpoint.hpp:24
Base class for both input and output ports.
Definition Port.hpp:66
In-memory graph builder and mutation controller (nodes + channels) with optional connection verificat...
Definition Controller.hpp:63
Core::DestinationTransportPtr createDestination(std::string_view uri, nlohmann::json config, Controller &controller)
Creates a DestinationTransport based on a URI string.
static Core::Endpoint endpointFromDescriptor(Core::Endpoint::Descriptor desc, Core::Port *port=nullptr)
Converts a descriptor into a concrete Endpoint.
std::move_only_function< Core::DestinationTransportPtr(Core::Endpoint, nlohmann::json)> DestinationBuilder
Function signature for creating a destination transport.
Definition TransportFactory.hpp:52
Core::SourceTransportPtr createSource(Core::Endpoint::Descriptor descriptor, nlohmann::json config, Controller &controller)
Creates a SourceTransport based on a Core::Endpoint::Descriptor.
void registerBuilder(std::string scheme, SourceBuilder sourceBuilder, DestinationBuilder destinationBuilder)
Register new builders for a specific scheme into the factory.
std::move_only_function< Core::SourceTransportPtr(Core::Endpoint, nlohmann::json)> SourceBuilder
Function signature for creating a source transport.
Definition TransportFactory.hpp:46
TransportFactory()
Default constructor.
static Core::Endpoint::Descriptor descriptorFromString(std::string_view str)
Parses a URI-like string into an endpoint descriptor.
Core::SourceTransportPtr createSource(std::string_view uri, nlohmann::json config, Controller &controller)
Creates a SourceTransport based on a URI string.
Core::DestinationTransportPtr createDestination(Core::Endpoint::Descriptor descriptor, nlohmann::json config, Controller &controller)
Creates a DestinationTransport based on a Core::Endpoint::Descriptor.
std::unique_ptr< SourceTransport > SourceTransportPtr
Unique ownership handle for SourceTransport.
Definition SourceTransport.hpp:48
Definition Node.hpp:43
std::unordered_map< std::string, T, TransparentHash, TransparentEqual, Allocator > UnorderedStringMap
Convenience alias for an unordered map keyed by std::string with transparent lookup.
Definition StringMap.hpp:76
Parsed metadata for an endpoint, used for routing and graph introspection.
Definition Endpoint.hpp:61