From 8fbe7f89c808d8eb28d8615ddda219208f936956 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 9 May 2021 17:20:12 -0700 Subject: Add unique id to workflow components --- core/src/Model/Workflow/Workflow.hpp | 10 ++++++++++ core/src/Model/Workflow/Workflow_Main.cpp | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/core/src/Model/Workflow/Workflow.hpp b/core/src/Model/Workflow/Workflow.hpp index cf3e2f9..77341fa 100644 --- a/core/src/Model/Workflow/Workflow.hpp +++ b/core/src/Model/Workflow/Workflow.hpp @@ -34,6 +34,8 @@ public: }; std::vector MultiConnections; + /// Used for `LinkId` when interfacing with imgui node editor. Runtime only (not saved to disk and generated when loading). + size_t UniqueId; ConnectionPoint SingleConnection; Direction ConnectionDirection; @@ -82,6 +84,8 @@ public: protected: struct InputPin { + /// Equivalent of `PinId` when interfacing with imgui node editor. Runtime only (not saved to disk and generated when loading). + size_t UniqueId; size_t Connection = WorkflowConnection::kInvalidId; BaseValue::Kind MatchingType = BaseValue::InvalidKind; bool ConnectionToConst = false; @@ -96,6 +100,8 @@ protected: struct OutputPin { + /// Equivalent of `PinId` when interfacing with imgui node editor. Runtime only (not saved to disk and generated when loading). + size_t UniqueId; size_t Connection = WorkflowConnection::kInvalidId; BaseValue::Kind MatchingType = BaseValue::InvalidKind; bool AllowsMultipleConnections = false; @@ -109,6 +115,8 @@ protected: friend class WorkflowEvaluationContext; Workflow* mWorkflow; + /// Equivalent of `NodeId` when interfacing with imgui node editor. Runtime only (not saved to disk and generated when loading). + size_t mUniqueId; size_t mId; std::vector mInputs; std::vector mOutputs; @@ -178,6 +186,7 @@ class Workflow private: friend class WorkflowEvaluationContext; + size_t mUniqueId = 0; std::vector mConnections; std::vector> mNodes; std::vector> mConstants; @@ -257,6 +266,7 @@ public: void WriteTo(std::ostream& stream); private: + size_t AllocUniqueId(); std::pair AllocWorkflowConnection(); std::pair&, size_t> AllocWorkflowStep(); }; diff --git a/core/src/Model/Workflow/Workflow_Main.cpp b/core/src/Model/Workflow/Workflow_Main.cpp index a108dc7..39a08df 100644 --- a/core/src/Model/Workflow/Workflow_Main.cpp +++ b/core/src/Model/Workflow/Workflow_Main.cpp @@ -852,3 +852,8 @@ std::pair&, size_t> Workflow::AllocWorkflowStep() auto id = mNodes.size(); return { mNodes.emplace_back(std::unique_ptr()), id }; } + +size_t Workflow::AllocUniqueId() +{ + return mUniqueId++; +} -- cgit v1.2.3-70-g09d2