![]() |
dfx 0.1.0
Linux-based dynamic dataflow executor
|
Incoming message endpoint attached to a node. More...
#include <dfx-core/ports/InputPort.hpp>
Public Member Functions | |
| InputPort (Id id, NodeWPtr node, std::string name, Kind kind, MimeTypes supportedMimeTypes={}, std::optional< bool > allowsMimeTypePropagation=std::nullopt) | |
| Construct an input port. | |
| MimeTypes | supportedMimeTypes () const noexcept |
| Return the list of MIME types supported by this input port. An empty list means “accept anything”. | |
| bool | isMimeTypeSupported (MimeType const &mimeType) const noexcept |
| Check whether a MIME type is compatible with this port. | |
| bool | hasPendingMessage () const |
| Check whether any attached channel has at least one pending message. | |
| void | processAllPendingMessages () |
| Drain and process all pending messages from all attached channels. | |
| void | processMessage (MessagePtr message) |
| Process a single message received on this input port. | |
| void | setAllowUnknownControlCommand (bool allow) |
| Allow or forbid unknown control commands. | |
| bool | isUnknownControlCommandAllowed () const noexcept |
| Whether unknown control commands are accepted. | |
| void | registerControlCommand (std::string_view command, nlohmann::json schema, bool allowOverride=false) |
| Register a control command JSON schema for validation. | |
| void | deregisterControlCommand (std::string_view command) |
| Deregister a control command schema. | |
| Public Member Functions inherited from dfx::Core::Port | |
| ENABLE_DEFAULT_MOVE_DISABLE_COPY (Port) | |
| Move is allowed, copy is disabled. | |
| virtual | ~Port () |
| Virtual destructor for inheritance. | |
| NodePtr | node () const noexcept |
| Get the owning node. | |
| template<DerivedFromPort T> | |
| T & | as () noexcept |
| Unchecked cast to a derived port type. | |
| template<DerivedFromPort T> | |
| T const & | as () const noexcept |
| Unchecked cast to a derived port type. | |
| Id | id () const noexcept |
| Get the port id. | |
| std::string const & | name () const noexcept |
| Get the port name. | |
| Mode | mode () const noexcept |
| Get the port mode. | |
| Kind | kind () const noexcept |
| Get the port kind. | |
| bool | isInput () const noexcept |
| Check is this is an input port. | |
| bool | isOutput () const noexcept |
| Check is this is an output port. | |
| std::optional< bool > | allowsMimeTypePropagation () const noexcept |
| Check if this node allow mime-type propagation. | |
| void | addChannel (ChannelPtr channel) |
| Attach a channel to this port. | |
| void | removeChannel (ChannelPtr channel) |
| Detach a channel from this port. If the channel is not present, this is a no-op. | |
| bool | hasChannel (ChannelPtr channel) const noexcept |
| Check whether a channel is attached to this port. | |
| std::size_t | channelCount () const noexcept |
| Number of attached channels. | |
| ChannelPtr | channel (std::size_t index) const |
| Get the attached channel at the given index. | |
| void | registerHook (Hooks::Port *hook) |
| Register a hook on this port. | |
| void | deregisterHook (Hooks::Port *hook) |
| Deregister a hook from this port. If the hook is not registered, this is a no-op. | |
Additional Inherited Members | |
| Public Types inherited from dfx::Core::Port | |
| enum class | Mode { Input , Output } |
| Port direction. More... | |
| using | Id = uint32_t |
| Identifier type of a port (unique within a node by not unique accross a graph). | |
| Static Public Member Functions inherited from dfx::Core::Port | |
| static void | validatePortName (std::string_view name) |
| Validate a port name according to dfx rules. | |
| Protected Member Functions inherited from dfx::Core::Port | |
| Port (Id id, NodeWPtr node, Mode mode, Kind kind, std::string name, std::optional< bool > allowsMimeTypePropagation) | |
| Construct a port. | |
| Protected Attributes inherited from dfx::Core::Port | |
| std::vector< Hooks::Port * > | hooks |
| Registered port hooks. Stored as raw pointers. Managed via registerHook and deregisterHook. | |
Incoming message endpoint attached to a node.
| dfx::Core::InputPort::InputPort | ( | Id | id, |
| NodeWPtr | node, | ||
| std::string | name, | ||
| Kind | kind, | ||
| MimeTypes | supportedMimeTypes = {}, | ||
| std::optional< bool > | allowsMimeTypePropagation = std::nullopt ) |
Construct an input port.
| void dfx::Core::InputPort::deregisterControlCommand | ( | std::string_view | command | ) |
Deregister a control command schema.
After deregistration, receiving that command will be considered "unknown" will either throw or be allowed depending on isUnknownControlCommandAllowed.
| bool dfx::Core::InputPort::hasPendingMessage | ( | ) | const |
Check whether any attached channel has at least one pending message.
|
noexcept |
Check whether a MIME type is compatible with this port.
Implemented rules:
mimeType is Any, returns true.mimeType is contained in the list.
|
inlinenoexcept |
Whether unknown control commands are accepted.
| void dfx::Core::InputPort::processAllPendingMessages | ( | ) |
Drain and process all pending messages from all attached channels.
For each attached channel, repeatedly pops messages until none remain, and forwards each message to processMessage.
| void dfx::Core::InputPort::processMessage | ( | MessagePtr | message | ) |
Process a single message received on this input port.
Performs:
| message | Message to process. |
| void dfx::Core::InputPort::registerControlCommand | ( | std::string_view | command, |
| nlohmann::json | schema, | ||
| bool | allowOverride = false ) |
Register a control command JSON schema for validation.
The schema is registered under command, and validation checks the message params against the schema at JSON pointer "/params".
| command | Command name. |
| schema | JSON schema. |
| allowOverride | If true, replaces an existing schema for the same command. |
|
inline |
Allow or forbid unknown control commands.
If false (default), receiving an unregistered control command throws. If true, unregistered commands are accepted without schema validation.
|
inlinenoexcept |
Return the list of MIME types supported by this input port. An empty list means “accept anything”.