17#include "../channels/Channel.hpp"
19#include <dfx-hooks/Port.hpp>
28using NodePtr = std::shared_ptr<Node>;
93 Id id() const noexcept {
return _id; }
95 std::string
const &
name() const noexcept {
return _name; }
115 template<DerivedFromPort T>
116 T &
as() noexcept {
return static_cast<T &
>(*this); }
123 template<DerivedFromPort T>
124 T
const &
as() const noexcept {
return static_cast<T
const &
>(*this); }
214 std::optional<bool> _allowsMimeTypePropagation;
217 std::vector<ChannelPtr> _channels;
Convenience macros to explicitly control copy and move semantics.
Macro-based enum <-> string utilities for dfx.
#define DECLARE_ENUM_STRING_FUNCTIONS(E)
Declare the enum string API (and std::formatter) for enum type E.
Definition EnumString.hpp:327
Abstract base class for all nodes in the dfx runtime.
Definition Node.hpp:91
Base class for both input and output ports.
Definition Port.hpp:66
static void validatePortName(std::string_view name)
Validate a port name according to dfx rules.
virtual ~Port()
Virtual destructor for inheritance.
std::size_t channelCount() const noexcept
Number of attached channels.
Definition Port.hpp:149
std::vector< Hooks::Port * > hooks
Registered port hooks. Stored as raw pointers. Managed via registerHook and deregisterHook.
Definition Port.hpp:206
Port(Id id, NodeWPtr node, Mode mode, Kind kind, std::string name, std::optional< bool > allowsMimeTypePropagation)
Construct a port.
NodePtr node() const noexcept
Get the owning node.
Definition Port.hpp:87
Mode mode() const noexcept
Get the port mode.
Definition Port.hpp:97
void registerHook(Hooks::Port *hook)
Register a hook on this port.
ChannelPtr channel(std::size_t index) const
Get the attached channel at the given index.
Definition Port.hpp:156
std::string const & name() const noexcept
Get the port name.
Definition Port.hpp:95
void deregisterHook(Hooks::Port *hook)
Deregister a hook from this port. If the hook is not registered, this is a no-op.
Id id() const noexcept
Get the port id.
Definition Port.hpp:93
Mode
Port direction.
Definition Port.hpp:74
@ Output
Outgoing endpoint.
Definition Port.hpp:76
@ Input
Incoming endpoint.
Definition Port.hpp:75
T const & as() const noexcept
Unchecked cast to a derived port type.
Definition Port.hpp:124
bool isOutput() const noexcept
Check is this is an output port.
Definition Port.hpp:103
void removeChannel(ChannelPtr channel)
Detach a channel from this port. If the channel is not present, this is a no-op.
Kind kind() const noexcept
Get the port kind.
Definition Port.hpp:99
T & as() noexcept
Unchecked cast to a derived port type.
Definition Port.hpp:116
ENABLE_DEFAULT_MOVE_DISABLE_COPY(Port)
Move is allowed, copy is disabled.
std::optional< bool > allowsMimeTypePropagation() const noexcept
Check if this node allow mime-type propagation.
Definition Port.hpp:106
uint32_t Id
Identifier type of a port (unique within a node by not unique accross a graph).
Definition Port.hpp:69
bool isInput() const noexcept
Check is this is an input port.
Definition Port.hpp:101
bool hasChannel(ChannelPtr channel) const noexcept
Check whether a channel is attached to this port.
void addChannel(ChannelPtr channel)
Attach a channel to this port.
Port-level message observation hook.
Definition Port.hpp:44
Concept used by dfx::Core::Port::as() to constrain types.
Definition Port.hpp:33
Definition Channel.hpp:22
std::shared_ptr< Node > NodePtr
Shared ownership pointer type for Nodes..
Definition Node.hpp:61
std::weak_ptr< Node > NodeWPtr
Weak pointer type for Nodes.
Definition Node.hpp:63
Kind
Port kind (connection domain).
Definition Kind.hpp:29
std::shared_ptr< Channel > ChannelPtr
Shared ownership handle for channels.
Definition Channel.hpp:147