diff options
author | rtk0c <[email protected]> | 2021-04-17 17:31:47 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-04-17 17:31:47 -0700 |
commit | dca1286661f61e51943863de8ce68849a9578363 (patch) | |
tree | ada6c32fdf9ebf11a2b302398e8de28f57e3de8a /core/src/Model/Workflow.hpp | |
parent | 4e5730e1fcef150ce2f13f52a278890589ca96ad (diff) |
Initial work on one-to-many/many-to-one connections
Diffstat (limited to 'core/src/Model/Workflow.hpp')
-rw-r--r-- | core/src/Model/Workflow.hpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/core/src/Model/Workflow.hpp b/core/src/Model/Workflow.hpp index 2c83816..62dd9ca 100644 --- a/core/src/Model/Workflow.hpp +++ b/core/src/Model/Workflow.hpp @@ -7,21 +7,37 @@ #include <cstdint> #include <limits> #include <memory> +#include <span> #include <vector> class WorkflowConnection { public: static constexpr auto kInvalidId = std::numeric_limits<size_t>::max(); - size_t Source; - size_t Destination; - int SourcePin; - int DestinationPin; + enum Direction { + ManyToOne, + OneToMany, + }; + + struct ConnectionPoint { + size_t Node; + int Pin; + + bool operator==(const ConnectionPoint&) const = default; + }; + + std::vector<ConnectionPoint> MultiConnections; + ConnectionPoint SingleConnection; + Direction ConnectionDirection; public: WorkflowConnection(); bool IsValid() const; + std::span<ConnectionPoint> GetSourcePoints(); + std::span<const ConnectionPoint> GetSourcePoints() const; + std::span<ConnectionPoint> GetDestinationPoints(); + std::span<const ConnectionPoint> GetDestinationPoints() const; }; class WorkflowNode { @@ -54,17 +70,23 @@ protected: size_t Connection = WorkflowConnection::kInvalidId; BaseValue::Kind MatchingType = BaseValue::KindInvalid; bool ConnectionToConst = false; + bool AllowsMultipleConnections = false; /// A constant connection connects from a user-specified constant value, feeding to a valid \c Destination and \c DestinationPin (i.e. input pins). bool IsConstantConnection() const; bool IsConnected() const; + BaseValue::Kind GetMatchingType() const; + WorkflowConnection::Direction GetSupportedDirection() const; }; struct OutputPin { size_t Connection = WorkflowConnection::kInvalidId; BaseValue::Kind MatchingType = BaseValue::KindInvalid; + bool AllowsMultipleConnections = false; bool IsConnected() const; + BaseValue::Kind GetMatchingType() const; + WorkflowConnection::Direction GetSupportedDirection() const; }; friend class Workflow; @@ -131,9 +153,9 @@ public: void AddStep(std::unique_ptr<WorkflowNode> step); void RemoveStep(size_t id); - void Connect(WorkflowNode& source, int sourceNode, WorkflowNode& destination, int destinationNode); - void DisconnectBySource(WorkflowNode& source, int sourceNode); - void DisconnectByDestination(WorkflowNode& destination, int destinationNode); + bool Connect(WorkflowNode& sourceNode, int sourcePin, WorkflowNode& destinationNode, int destinationPin); + bool DisconnectBySource(WorkflowNode& sourceNode, int sourcePin); + bool DisconnectByDestination(WorkflowNode& destinationNode, int destinationPin); private: std::pair<WorkflowConnection&, size_t> AllocWorkflowConnection(); |