diff options
Diffstat (limited to 'core/src/Model/Workflow/Evaluation.cpp')
-rw-r--r-- | core/src/Model/Workflow/Evaluation.cpp | 78 |
1 files changed, 10 insertions, 68 deletions
diff --git a/core/src/Model/Workflow/Evaluation.cpp b/core/src/Model/Workflow/Evaluation.cpp index 111d34e..db09973 100644 --- a/core/src/Model/Workflow/Evaluation.cpp +++ b/core/src/Model/Workflow/Evaluation.cpp @@ -55,89 +55,31 @@ void WorkflowEvaluationContext::SetConnectionValue(const WorkflowNode::OutputPin } void WorkflowEvaluationContext::Run() { - std::queue<size_t> candidates; // Stores index to nodes int evaluatedCount = 0; int erroredCount = 0; - // Evaluate all the input nodes first - for (size_t i = 0; i < mRuntimeNodes.size(); ++i) { - if (mWorkflow->mNodes[i]->GetType() == WorkflowNode::InputType) { - candidates.push(i); - } - } - - auto AddOutputsToCandidates = [&](size_t idx) { - auto& node = *mWorkflow->mNodes[idx]; - auto& rNode = mRuntimeNodes[idx]; - for (auto& pin : node.mOutputs) { - if (!pin.IsConnected()) continue; - // TODO support the other variant - if (pin.GetSupportedDirection() != WorkflowConnection::OneToMany) continue; - - auto& rConn = mRuntimeConnections[pin.Connection]; - auto& conn = mWorkflow->mConnections[pin.Connection]; - if (rConn.IsAvailableValue()) { - for (WorkflowConnection::ConnectionPoint& cp : conn.MultiConnections) { - if (rNode.Status != EvaluationStatus::Unevaluated) { - candidates.push(cp.Node); - } - } - } - } - }; - auto FindCandidates = [&]() { - for (size_t i = 0; i < mWorkflow->mNodes.size(); ++i) { - auto& node = mWorkflow->mNodes[i]; - auto& rNode = mRuntimeNodes[i]; - - if (rNode.Status != EvaluationStatus::Unevaluated) { - continue; - } - - for (auto& pin : node->mInputs) { - if (!pin.IsConnected()) continue; + for (auto& depthGroup : mWorkflow->GetDepthGroups()) { + for (size_t idx : depthGroup) { + auto& rn = mRuntimeNodes[idx]; + auto& n = *mWorkflow->mNodes[idx]; - auto& rConn = mRuntimeConnections[pin.Connection]; - if (!rConn.IsAvailableValue()) { - goto skip; - } - } - - candidates.push(i); - - skip: - continue; - } - }; - - while (true) { - while (!candidates.empty()) { - auto idx = candidates.front(); - auto& node = *mWorkflow->mNodes[idx]; - auto& rNode = mRuntimeNodes[idx]; - candidates.pop(); + // TODO int preEvalErrors = mErrors.size(); - node.Evaluate(*this); + n.Evaluate(*this); if (preEvalErrors != mErrors.size()) { erroredCount++; } else { evaluatedCount++; - AddOutputsToCandidates(idx); } } - - if (evaluatedCount + erroredCount >= mRuntimeNodes.size()) { - break; - } - - // Candidates empty, but there are still possibly-evaluable nodes - FindCandidates(); } for (size_t i = 0; i < mRuntimeNodes.size(); ++i) { - if (mWorkflow->mNodes[i]->GetType() == WorkflowNode::OutputType) { - // TODO + auto& rn = mRuntimeNodes[i]; + auto& n = *mWorkflow->mNodes[i]; + if (n.GetType() == WorkflowNode::OutputType) { + // TODO record outputs } } } |