dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
Endpoint.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 <string>
13
14// Project includes
16
17namespace dfx::Core
18{
19class Port;
20class Node;
21using NodePtr = std::shared_ptr<Node>;
22
24{
50public:
52 enum class Location
53 {
56 };
57
58public:
61 {
62 std::string scheme;
63 std::string address;
64 std::string node;
65 std::string port;
66 };
67
68public:
72 explicit Endpoint(Port & port);
73
80 explicit Endpoint(std::string scheme, std::string address, std::string node, std::string port);
81
83 Location location() const noexcept { return _location; }
84
86 Descriptor const & desc() const noexcept { return _desc; }
87
89 Port * port() const noexcept { return _port; }
90
92 NodePtr node() const noexcept;
93
95 bool isLocal() const noexcept { return _location == Location::Local; }
96
98 bool isRemote() const noexcept { return _location == Location::Remote; }
99
105 std::string toString(bool forceUriFormat = false) const;
106
107private:
108 Location _location = Location::Local;
109 Port * _port = nullptr;
110 Descriptor _desc;
111};
112} // !namespace dfx::Core
113
Macro-based enum <-> string utilities for dfx.
#define DFX_DECLARE_ENUM_STRING_FUNCTIONS(E)
Declare the enum string API (and std::formatter) for enum type E.
Definition EnumString.hpp:327
Descriptor const & desc() const noexcept
Access the descriptor.
Definition Endpoint.hpp:86
bool isLocal() const noexcept
Helper to check if location is Location::Local.
Definition Endpoint.hpp:95
Endpoint(Port &port)
Construct a local endpoint from an existing port.
NodePtr node() const noexcept
Return the owning node pointer if local, otherwise nullptr.
Port * port() const noexcept
Return the underlying port if local, otherwise nullptr.
Definition Endpoint.hpp:89
Location location() const noexcept
Check if the endpoint is local or remote.
Definition Endpoint.hpp:83
Location
Logical descriptor of a port endpoint in the dataflow graph.
Definition Endpoint.hpp:53
@ Local
The associated port is local and accessible to this dfx instance.
Definition Endpoint.hpp:54
@ Remote
The associated port is not managed by this dfx instance.
Definition Endpoint.hpp:55
Endpoint(std::string scheme, std::string address, std::string node, std::string port)
Construct a remote endpoint from manual descriptors.
std::string toString(bool forceUriFormat=false) const
Format the endpoint as a string for logging or UI.
bool isRemote() const noexcept
Helper to check if location is Location::Remote.
Definition Endpoint.hpp:98
Abstract base class for all nodes in the dfx runtime.
Definition Node.hpp:94
Base class for both input and output ports.
Definition Port.hpp:66
Definition Channel.hpp:25
std::shared_ptr< Node > NodePtr
Shared ownership pointer type for Nodes..
Definition Endpoint.hpp:21
Parsed metadata for an endpoint, used for routing and graph introspection.
Definition Endpoint.hpp:61
std::string node
Name of the node.
Definition Endpoint.hpp:64
std::string scheme
Type of endpoint: "tcp", "mq", "uds", "shm", "local", ...
Definition Endpoint.hpp:62
std::string port
Port of this endpoint.
Definition Endpoint.hpp:65
std::string address
Address description if remote: "127.0.0.1:8080" or "/tmp/dfx.sock".
Definition Endpoint.hpp:63