diff options
Diffstat (limited to 'core/src/Model/Workflow/Workflow.hpp')
-rw-r--r-- | core/src/Model/Workflow/Workflow.hpp | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/core/src/Model/Workflow/Workflow.hpp b/core/src/Model/Workflow/Workflow.hpp index bfed722..9c02168 100644 --- a/core/src/Model/Workflow/Workflow.hpp +++ b/core/src/Model/Workflow/Workflow.hpp @@ -1,6 +1,7 @@ #pragma once -#include "Value.hpp" +#include "Model/Workflow/Value.hpp" +#include "Utils/Vector.hpp" #include "cplt_fwd.hpp" #include <cstddef> @@ -9,6 +10,7 @@ #include <memory> #include <span> #include <string> +#include <variant> #include <vector> class WorkflowConnection { @@ -97,6 +99,7 @@ protected: size_t mId; std::vector<InputPin> mInputs; std::vector<OutputPin> mOutputs; + Vec2i mPosition; Type mType; Kind mKind; int mDepth; @@ -110,9 +113,13 @@ public: WorkflowNode(WorkflowNode&&) = default; WorkflowNode& operator=(WorkflowNode&&) = default; + Vec2i GetPosition() const; + void SetPosition(const Vec2i& position); + size_t GetId() const; Type GetType() const; Kind GetKind() const; + int GetDepth() const; void ConnectInput(int nodeId, WorkflowNode& output, int outputNodeId); void DisconnectInput(int nodeId); @@ -145,6 +152,7 @@ private: std::vector<WorkflowConnection> mConnections; std::vector<std::unique_ptr<WorkflowNode>> mNodes; std::vector<std::unique_ptr<BaseValue>> mConstants; + std::vector<std::vector<size_t>> mDepthGroups; bool mDepthsDirty = true; public: @@ -155,19 +163,32 @@ public: void AddStep(std::unique_ptr<WorkflowNode> step); void RemoveStep(size_t id); + void RemoveConnection(size_t id); + bool Connect(WorkflowNode& sourceNode, int sourcePin, WorkflowNode& destinationNode, int destinationPin); bool DisconnectBySource(WorkflowNode& sourceNode, int sourcePin); bool DisconnectByDestination(WorkflowNode& destinationNode, int destinationPin); - void RemoveConnection(size_t id); - + const std::vector<std::vector<size_t>>& GetDepthGroups() const; bool DoesDepthNeedsUpdate() const; - enum GraphUpdateResult { - Success, - CyclicReference, + struct GraphUpdate_Success {}; + struct GraphUpdate_NoWorkToDo {}; + struct GraphUpdate_UnsatisfiedDependencies { + std::vector<size_t> UnsatisfiedNodes; + }; + struct GraphUpdate_UnreachableNodes { + std::vector<size_t> UnreachableNodes; }; - GraphUpdateResult UpdateGraph(); + + using GraphUpdateResult = std::variant< + GraphUpdate_Success, + GraphUpdate_NoWorkToDo, + GraphUpdate_UnsatisfiedDependencies, + GraphUpdate_UnreachableNodes>; + + /// When `getInfo == false, the corresponding error code is returned but without/with empty payloads. + GraphUpdateResult UpdateGraph(bool getInfo = true); private: std::pair<WorkflowConnection&, size_t> AllocWorkflowConnection(); |