diff options
author | rtk0c <[email protected]> | 2021-05-06 21:56:40 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-05-06 21:56:40 -0700 |
commit | 1fd1e4b5f2418e3ac2909658993bfedb615537ec (patch) | |
tree | 6de080d2273890f8a74d7fcd3572bb44f44ac545 /core/src/Model/Workflow/Evaluation.cpp | |
parent | 538e804fc9beb83e711a210ffbb6badc15f285d5 (diff) |
Change brace style to on new line, add initial deliveries view when an order entry is selected
Diffstat (limited to 'core/src/Model/Workflow/Evaluation.cpp')
-rw-r--r-- | core/src/Model/Workflow/Evaluation.cpp | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/core/src/Model/Workflow/Evaluation.cpp b/core/src/Model/Workflow/Evaluation.cpp index ff3edf4..f6472dd 100644 --- a/core/src/Model/Workflow/Evaluation.cpp +++ b/core/src/Model/Workflow/Evaluation.cpp @@ -2,14 +2,16 @@ #include <queue> -const char* WorkflowEvaluationError::FormatMessageType(enum MessageType messageType) { +const char* WorkflowEvaluationError::FormatMessageType(enum MessageType messageType) +{ switch (messageType) { case Error: return "Error"; case Warning: return "Warning"; } } -const char* WorkflowEvaluationError::FormatPinType(enum PinType pinType) { +const char* WorkflowEvaluationError::FormatPinType(enum PinType pinType) +{ switch (pinType) { case NoPin: return nullptr; case InputPin: return "Input pin"; @@ -17,7 +19,8 @@ const char* WorkflowEvaluationError::FormatPinType(enum PinType pinType) { } } -std::string WorkflowEvaluationError::Format() const { +std::string WorkflowEvaluationError::Format() const +{ // TODO convert to std::format std::string result; @@ -37,32 +40,38 @@ std::string WorkflowEvaluationError::Format() const { } namespace { -enum class EvaluationStatus { +enum class EvaluationStatus +{ Unevaluated, Success, Failed, }; } // namespace -struct WorkflowEvaluationContext::RuntimeNode { +struct WorkflowEvaluationContext::RuntimeNode +{ EvaluationStatus Status = EvaluationStatus::Unevaluated; }; -struct WorkflowEvaluationContext::RuntimeConnection { +struct WorkflowEvaluationContext::RuntimeConnection +{ std::unique_ptr<BaseValue> Value; - bool IsAvailableValue() const { + bool IsAvailableValue() const + { return Value != nullptr; } }; WorkflowEvaluationContext::WorkflowEvaluationContext(Workflow& workflow) - : mWorkflow{ &workflow } { + : mWorkflow{ &workflow } +{ mRuntimeNodes.resize(workflow.mNodes.size()); mRuntimeConnections.resize(workflow.mConnections.size()); } -BaseValue* WorkflowEvaluationContext::GetConnectionValue(size_t id, bool constant) { +BaseValue* WorkflowEvaluationContext::GetConnectionValue(size_t id, bool constant) +{ if (constant) { return mWorkflow->GetConstantById(id); } else { @@ -70,7 +79,8 @@ BaseValue* WorkflowEvaluationContext::GetConnectionValue(size_t id, bool constan } } -BaseValue* WorkflowEvaluationContext::GetConnectionValue(const WorkflowNode::InputPin& inputPin) { +BaseValue* WorkflowEvaluationContext::GetConnectionValue(const WorkflowNode::InputPin& inputPin) +{ if (inputPin.IsConnected()) { return GetConnectionValue(inputPin.Connection, inputPin.IsConstantConnection()); } else { @@ -78,17 +88,20 @@ BaseValue* WorkflowEvaluationContext::GetConnectionValue(const WorkflowNode::Inp } } -void WorkflowEvaluationContext::SetConnectionValue(size_t id, std::unique_ptr<BaseValue> value) { +void WorkflowEvaluationContext::SetConnectionValue(size_t id, std::unique_ptr<BaseValue> value) +{ mRuntimeConnections[id].Value = std::move(value); } -void WorkflowEvaluationContext::SetConnectionValue(const WorkflowNode::OutputPin& outputPin, std::unique_ptr<BaseValue> value) { +void WorkflowEvaluationContext::SetConnectionValue(const WorkflowNode::OutputPin& outputPin, std::unique_ptr<BaseValue> value) +{ if (outputPin.IsConnected()) { SetConnectionValue(outputPin.Connection, std::move(value)); } } -void WorkflowEvaluationContext::Run() { +void WorkflowEvaluationContext::Run() +{ int evaluatedCount = 0; int erroredCount = 0; @@ -118,7 +131,8 @@ void WorkflowEvaluationContext::Run() { } } -void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowNode& node, int pinId, bool inputPin) { +void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowNode& node, int pinId, bool inputPin) +{ mErrors.push_back(WorkflowEvaluationError{ .Message = std::move(message), .NodeId = node.GetId(), @@ -128,7 +142,8 @@ void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowN }); } -void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowNode& node) { +void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowNode& node) +{ mErrors.push_back(WorkflowEvaluationError{ .Message = std::move(message), .NodeId = node.GetId(), @@ -138,7 +153,8 @@ void WorkflowEvaluationContext::ReportError(std::string message, const WorkflowN }); } -void WorkflowEvaluationContext::ReportWarning(std::string message, const WorkflowNode& node, int pinId, bool inputPin) { +void WorkflowEvaluationContext::ReportWarning(std::string message, const WorkflowNode& node, int pinId, bool inputPin) +{ mErrors.push_back(WorkflowEvaluationError{ .Message = std::move(message), .NodeId = node.GetId(), @@ -148,7 +164,8 @@ void WorkflowEvaluationContext::ReportWarning(std::string message, const Workflo }); } -void WorkflowEvaluationContext::ReportWarning(std::string message, const WorkflowNode& node) { +void WorkflowEvaluationContext::ReportWarning(std::string message, const WorkflowNode& node) +{ mErrors.push_back(WorkflowEvaluationError{ .Message = std::move(message), .NodeId = node.GetId(), |