From e7afe82857ac3ccc3e10b40cee60ea94cc59232b Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sat, 24 Apr 2021 17:11:44 -0700 Subject: Second draft of graph rebuild - Change working set approach to basic BFS with dependency (input pins) counting - TODO convert evaluator to use depths --- core/src/Model/Workflow/Workflow.hpp | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'core/src/Model/Workflow/Workflow.hpp') 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 @@ -9,6 +10,7 @@ #include #include #include +#include #include class WorkflowConnection { @@ -97,6 +99,7 @@ protected: size_t mId; std::vector mInputs; std::vector 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 mConnections; std::vector> mNodes; std::vector> mConstants; + std::vector> mDepthGroups; bool mDepthsDirty = true; public: @@ -155,19 +163,32 @@ public: void AddStep(std::unique_ptr 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>& GetDepthGroups() const; bool DoesDepthNeedsUpdate() const; - enum GraphUpdateResult { - Success, - CyclicReference, + struct GraphUpdate_Success {}; + struct GraphUpdate_NoWorkToDo {}; + struct GraphUpdate_UnsatisfiedDependencies { + std::vector UnsatisfiedNodes; + }; + struct GraphUpdate_UnreachableNodes { + std::vector 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 AllocWorkflowConnection(); -- cgit v1.2.3-70-g09d2