aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2021-05-09 17:20:12 -0700
committerrtk0c <[email protected]>2021-05-09 17:20:12 -0700
commit8fbe7f89c808d8eb28d8615ddda219208f936956 (patch)
treef804e48b0a0a30af45fd257880ce25db3e1a62e0 /core/src/Model
parenta96761a29e9ff67b1756020f87deabc79f635b79 (diff)
Add unique id to workflow components
Diffstat (limited to 'core/src/Model')
-rw-r--r--core/src/Model/Workflow/Workflow.hpp10
-rw-r--r--core/src/Model/Workflow/Workflow_Main.cpp5
2 files changed, 15 insertions, 0 deletions
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<ConnectionPoint> 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<InputPin> mInputs;
std::vector<OutputPin> mOutputs;
@@ -178,6 +186,7 @@ class Workflow
private:
friend class WorkflowEvaluationContext;
+ size_t mUniqueId = 0;
std::vector<WorkflowConnection> mConnections;
std::vector<std::unique_ptr<WorkflowNode>> mNodes;
std::vector<std::unique_ptr<BaseValue>> mConstants;
@@ -257,6 +266,7 @@ public:
void WriteTo(std::ostream& stream);
private:
+ size_t AllocUniqueId();
std::pair<WorkflowConnection&, size_t> AllocWorkflowConnection();
std::pair<std::unique_ptr<WorkflowNode>&, 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<std::unique_ptr<WorkflowNode>&, size_t> Workflow::AllocWorkflowStep()
auto id = mNodes.size();
return { mNodes.emplace_back(std::unique_ptr<WorkflowNode>()), id };
}
+
+size_t Workflow::AllocUniqueId()
+{
+ return mUniqueId++;
+}