From 182c8f8357739f905bbd721006480502435b6b43 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 27 Nov 2022 12:04:31 -0800 Subject: Update brace style to match rest of my projects --- app/source/Cplt/Model/Workflow/Evaluation.cpp | 51 ++--- app/source/Cplt/Model/Workflow/Evaluation.hpp | 12 +- .../Cplt/Model/Workflow/Nodes/DocumentNodes.cpp | 9 +- .../Cplt/Model/Workflow/Nodes/DocumentNodes.hpp | 3 +- .../Cplt/Model/Workflow/Nodes/NumericNodes.cpp | 24 +- .../Cplt/Model/Workflow/Nodes/NumericNodes.hpp | 9 +- app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp | 51 ++--- app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp | 9 +- .../Cplt/Model/Workflow/Nodes/UserInputNodes.cpp | 18 +- .../Cplt/Model/Workflow/Nodes/UserInputNodes.hpp | 6 +- app/source/Cplt/Model/Workflow/Value.hpp | 18 +- app/source/Cplt/Model/Workflow/Value_Main.cpp | 21 +- app/source/Cplt/Model/Workflow/Value_RTTI.cpp | 18 +- app/source/Cplt/Model/Workflow/Values/Basic.cpp | 54 ++--- app/source/Cplt/Model/Workflow/Values/Basic.hpp | 9 +- app/source/Cplt/Model/Workflow/Values/Database.cpp | 36 +-- app/source/Cplt/Model/Workflow/Values/Database.hpp | 9 +- .../Cplt/Model/Workflow/Values/Dictionary.cpp | 21 +- .../Cplt/Model/Workflow/Values/Dictionary.hpp | 3 +- app/source/Cplt/Model/Workflow/Values/List.cpp | 57 ++--- app/source/Cplt/Model/Workflow/Values/List.hpp | 6 +- app/source/Cplt/Model/Workflow/Workflow.hpp | 33 +-- app/source/Cplt/Model/Workflow/Workflow_Main.cpp | 252 +++++++-------------- app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp | 21 +- 24 files changed, 250 insertions(+), 500 deletions(-) (limited to 'app/source/Cplt/Model/Workflow') diff --git a/app/source/Cplt/Model/Workflow/Evaluation.cpp b/app/source/Cplt/Model/Workflow/Evaluation.cpp index 7035bf9..fc5f661 100644 --- a/app/source/Cplt/Model/Workflow/Evaluation.cpp +++ b/app/source/Cplt/Model/Workflow/Evaluation.cpp @@ -2,16 +2,14 @@ #include -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"; @@ -19,8 +17,7 @@ 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; @@ -39,10 +36,8 @@ std::string WorkflowEvaluationError::Format() const return result; } -struct WorkflowEvaluationContext::RuntimeNode -{ - enum EvaluationStatus - { +struct WorkflowEvaluationContext::RuntimeNode { + enum EvaluationStatus { ST_Unevaluated, ST_Success, ST_Failed, @@ -51,25 +46,21 @@ struct WorkflowEvaluationContext::RuntimeNode EvaluationStatus Status = ST_Unevaluated; }; -struct WorkflowEvaluationContext::RuntimeConnection -{ +struct WorkflowEvaluationContext::RuntimeConnection { std::unique_ptr 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 { @@ -77,8 +68,7 @@ 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 { @@ -86,20 +76,17 @@ BaseValue* WorkflowEvaluationContext::GetConnectionValue(const WorkflowNode::Inp } } -void WorkflowEvaluationContext::SetConnectionValue(size_t id, std::unique_ptr value) -{ +void WorkflowEvaluationContext::SetConnectionValue(size_t id, std::unique_ptr value) { mRuntimeConnections[id].Value = std::move(value); } -void WorkflowEvaluationContext::SetConnectionValue(const WorkflowNode::OutputPin& outputPin, std::unique_ptr value) -{ +void WorkflowEvaluationContext::SetConnectionValue(const WorkflowNode::OutputPin& outputPin, std::unique_ptr value) { if (outputPin.IsConnected()) { SetConnectionValue(outputPin.Connection, std::move(value)); } } -void WorkflowEvaluationContext::Run() -{ +void WorkflowEvaluationContext::Run() { int evaluatedCount = 0; int erroredCount = 0; @@ -129,8 +116,7 @@ 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(), @@ -140,8 +126,7 @@ 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(), @@ -151,8 +136,7 @@ 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(), @@ -162,8 +146,7 @@ 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(), diff --git a/app/source/Cplt/Model/Workflow/Evaluation.hpp b/app/source/Cplt/Model/Workflow/Evaluation.hpp index 5b8c6cc..2cd0e53 100644 --- a/app/source/Cplt/Model/Workflow/Evaluation.hpp +++ b/app/source/Cplt/Model/Workflow/Evaluation.hpp @@ -7,17 +7,14 @@ #include #include -class WorkflowEvaluationError -{ +class WorkflowEvaluationError { public: - enum MessageType : int16_t - { + enum MessageType : int16_t { Error, Warning, }; - enum PinType : int16_t - { + enum PinType : int16_t { NoPin, InputPin, OutputPin, @@ -37,8 +34,7 @@ public: std::string Format() const; }; -class WorkflowEvaluationContext -{ +class WorkflowEvaluationContext { private: struct RuntimeNode; struct RuntimeConnection; diff --git a/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.cpp b/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.cpp index df4a8bb..202f8cf 100644 --- a/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.cpp +++ b/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.cpp @@ -3,16 +3,13 @@ #include #include -bool DocumentTemplateExpansionNode::IsInstance(const WorkflowNode* node) -{ +bool DocumentTemplateExpansionNode::IsInstance(const WorkflowNode* node) { return node->GetKind() == KD_DocumentTemplateExpansion; } DocumentTemplateExpansionNode::DocumentTemplateExpansionNode() - : WorkflowNode(KD_DocumentTemplateExpansion, false) -{ + : WorkflowNode(KD_DocumentTemplateExpansion, false) { } -void DocumentTemplateExpansionNode::Evaluate(WorkflowEvaluationContext& ctx) -{ +void DocumentTemplateExpansionNode::Evaluate(WorkflowEvaluationContext& ctx) { } diff --git a/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.hpp b/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.hpp index a266b2c..2a49a91 100644 --- a/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.hpp +++ b/app/source/Cplt/Model/Workflow/Nodes/DocumentNodes.hpp @@ -2,8 +2,7 @@ #include -class DocumentTemplateExpansionNode : public WorkflowNode -{ +class DocumentTemplateExpansionNode : public WorkflowNode { public: static bool IsInstance(const WorkflowNode* node); DocumentTemplateExpansionNode(); diff --git a/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.cpp b/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.cpp index f8b29bb..8a47423 100644 --- a/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.cpp +++ b/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.cpp @@ -9,8 +9,7 @@ #include #include -WorkflowNode::Kind NumericOperationNode::OperationTypeToNodeKind(OperationType type) -{ +WorkflowNode::Kind NumericOperationNode::OperationTypeToNodeKind(OperationType type) { switch (type) { case Addition: return KD_NumericAddition; case Subtraction: return KD_NumericSubtraction; @@ -20,8 +19,7 @@ WorkflowNode::Kind NumericOperationNode::OperationTypeToNodeKind(OperationType t } } -NumericOperationNode::OperationType NumericOperationNode::NodeKindToOperationType(Kind kind) -{ +NumericOperationNode::OperationType NumericOperationNode::NodeKindToOperationType(Kind kind) { switch (kind) { case KD_NumericAddition: return Addition; case KD_NumericSubtraction: return Subtraction; @@ -31,15 +29,13 @@ NumericOperationNode::OperationType NumericOperationNode::NodeKindToOperationTyp } } -bool NumericOperationNode::IsInstance(const WorkflowNode* node) -{ +bool NumericOperationNode::IsInstance(const WorkflowNode* node) { return node->GetKind() >= KD_NumericAddition && node->GetKind() <= KD_NumericDivision; } NumericOperationNode::NumericOperationNode(OperationType type) : WorkflowNode(OperationTypeToNodeKind(type), false) - , mType{ type } -{ + , mType{ type } { mInputs.resize(2); mInputs[0].MatchingType = BaseValue::KD_Numeric; mInputs[1].MatchingType = BaseValue::KD_Numeric; @@ -48,8 +44,7 @@ NumericOperationNode::NumericOperationNode(OperationType type) mOutputs[0].MatchingType = BaseValue::KD_Numeric; } -void NumericOperationNode::Evaluate(WorkflowEvaluationContext& ctx) -{ +void NumericOperationNode::Evaluate(WorkflowEvaluationContext& ctx) { auto lhsVal = dyn_cast(ctx.GetConnectionValue(mInputs[0])); if (!lhsVal) return; double lhs = lhsVal->GetValue(); @@ -79,16 +74,13 @@ void NumericOperationNode::Evaluate(WorkflowEvaluationContext& ctx) ctx.SetConnectionValue(mOutputs[0], std::move(value)); } -bool NumericExpressionNode::IsInstance(const WorkflowNode* node) -{ +bool NumericExpressionNode::IsInstance(const WorkflowNode* node) { return node->GetKind() == KD_NumericExpression; } NumericExpressionNode::NumericExpressionNode() - : WorkflowNode(KD_NumericExpression, false) -{ + : WorkflowNode(KD_NumericExpression, false) { } -void NumericExpressionNode::Evaluate(WorkflowEvaluationContext& ctx) -{ +void NumericExpressionNode::Evaluate(WorkflowEvaluationContext& ctx) { } diff --git a/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.hpp b/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.hpp index 3c89708..0d3120b 100644 --- a/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.hpp +++ b/app/source/Cplt/Model/Workflow/Nodes/NumericNodes.hpp @@ -7,11 +7,9 @@ #include #include -class NumericOperationNode : public WorkflowNode -{ +class NumericOperationNode : public WorkflowNode { public: - enum OperationType - { + enum OperationType { Addition, Subtraction, Multiplication, @@ -33,8 +31,7 @@ public: virtual void Evaluate(WorkflowEvaluationContext& ctx) override; }; -class NumericExpressionNode : public WorkflowNode -{ +class NumericExpressionNode : public WorkflowNode { public: static bool IsInstance(const WorkflowNode* node); NumericExpressionNode(); diff --git a/app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp b/app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp index 9b31f7a..4bca0c8 100644 --- a/app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp +++ b/app/source/Cplt/Model/Workflow/Nodes/TextNodes.cpp @@ -11,12 +11,10 @@ #include #include -class TextFormatterNode::Impl -{ +class TextFormatterNode::Impl { public: template - static void ForArguments(std::vector::iterator begin, std::vector::iterator end, const TFunction& func) - { + static void ForArguments(std::vector::iterator begin, std::vector::iterator end, const TFunction& func) { for (auto it = begin; it != end; ++it) { auto& elm = *it; if (auto arg = std::get_if(&elm)) { @@ -26,8 +24,7 @@ public: } /// Find the pin index that the \c elmIdx -th element should have, based on the elements coming before it. - static int FindPinForElement(const std::vector& vec, int elmIdx) - { + static int FindPinForElement(const std::vector& vec, int elmIdx) { for (int i = elmIdx; i >= 0; --i) { auto& elm = vec[i]; if (auto arg = std::get_if(&elm)) { @@ -38,8 +35,7 @@ public: } }; -BaseValue::Kind TextFormatterNode::ArgumentTypeToValueKind(TextFormatterNode::ArgumentType arg) -{ +BaseValue::Kind TextFormatterNode::ArgumentTypeToValueKind(TextFormatterNode::ArgumentType arg) { switch (arg) { case NumericArgument: return BaseValue::KD_Numeric; case TextArgument: return BaseValue::KD_Text; @@ -47,28 +43,23 @@ BaseValue::Kind TextFormatterNode::ArgumentTypeToValueKind(TextFormatterNode::Ar } } -bool TextFormatterNode::IsInstance(const WorkflowNode* node) -{ +bool TextFormatterNode::IsInstance(const WorkflowNode* node) { return node->GetKind() == KD_TextFormatting; } TextFormatterNode::TextFormatterNode() - : WorkflowNode(KD_TextFormatting, false) -{ + : WorkflowNode(KD_TextFormatting, false) { } -int TextFormatterNode::GetElementCount() const -{ +int TextFormatterNode::GetElementCount() const { return mElements.size(); } -const TextFormatterNode::Element& TextFormatterNode::GetElement(int idx) const -{ +const TextFormatterNode::Element& TextFormatterNode::GetElement(int idx) const { return mElements[idx]; } -void TextFormatterNode::SetElement(int idx, std::string text) -{ +void TextFormatterNode::SetElement(int idx, std::string text) { assert(idx >= 0 && idx < mElements.size()); std::visit( @@ -82,8 +73,7 @@ void TextFormatterNode::SetElement(int idx, std::string text) mElements[idx] = std::move(text); } -void TextFormatterNode::SetElement(int idx, ArgumentType argument) -{ +void TextFormatterNode::SetElement(int idx, ArgumentType argument) { assert(idx >= 0 && idx < mElements.size()); std::visit( @@ -115,8 +105,7 @@ void TextFormatterNode::SetElement(int idx, ArgumentType argument) mElements[idx]); } -void TextFormatterNode::InsertElement(int idx, std::string text) -{ +void TextFormatterNode::InsertElement(int idx, std::string text) { assert(idx >= 0); if (idx >= mElements.size()) AppendElement(std::move(text)); @@ -124,8 +113,7 @@ void TextFormatterNode::InsertElement(int idx, std::string text) mElements.insert(mElements.begin() + idx, std::move(text)); } -void TextFormatterNode::InsertElement(int idx, ArgumentType argument) -{ +void TextFormatterNode::InsertElement(int idx, ArgumentType argument) { assert(idx >= 0); if (idx >= mElements.size()) AppendElement(argument); @@ -144,14 +132,12 @@ void TextFormatterNode::InsertElement(int idx, ArgumentType argument) }); } -void TextFormatterNode::AppendElement(std::string text) -{ +void TextFormatterNode::AppendElement(std::string text) { mMinOutputChars += text.size(); mElements.push_back(std::move(text)); } -void TextFormatterNode::AppendElement(ArgumentType argument) -{ +void TextFormatterNode::AppendElement(ArgumentType argument) { int pinIdx = mInputs.size(); // Create pin mInputs.push_back(InputPin{}); @@ -163,8 +149,7 @@ void TextFormatterNode::AppendElement(ArgumentType argument) }); } -void TextFormatterNode::RemoveElement(int idx) -{ +void TextFormatterNode::RemoveElement(int idx) { assert(idx >= 0 && idx < mElements.size()); PreRemoveElement(idx); @@ -174,8 +159,7 @@ void TextFormatterNode::RemoveElement(int idx) mElements.erase(mElements.begin() + idx); } -void TextFormatterNode::Evaluate(WorkflowEvaluationContext& ctx) -{ +void TextFormatterNode::Evaluate(WorkflowEvaluationContext& ctx) { std::string result; result.reserve((size_t)(mMinOutputChars * 1.5f)); @@ -216,8 +200,7 @@ void TextFormatterNode::Evaluate(WorkflowEvaluationContext& ctx) } } -void TextFormatterNode::PreRemoveElement(int idx) -{ +void TextFormatterNode::PreRemoveElement(int idx) { auto& elm = mElements[idx]; if (auto arg = std::get_if(&elm)) { RemoveInputPin(arg->PinIdx); diff --git a/app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp b/app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp index 4689931..56eb19b 100644 --- a/app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp +++ b/app/source/Cplt/Model/Workflow/Nodes/TextNodes.hpp @@ -7,11 +7,9 @@ #include #include -class TextFormatterNode : public WorkflowNode -{ +class TextFormatterNode : public WorkflowNode { public: - enum ArgumentType - { + enum ArgumentType { NumericArgument, TextArgument, DateTimeArgument, @@ -20,8 +18,7 @@ public: private: class Impl; - struct Argument - { + struct Argument { ArgumentType Type; int PinIdx; }; diff --git a/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.cpp b/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.cpp index 93d458c..4b56052 100644 --- a/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.cpp +++ b/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.cpp @@ -3,30 +3,24 @@ #include #include -bool FormInputNode::IsInstance(const WorkflowNode* node) -{ +bool FormInputNode::IsInstance(const WorkflowNode* node) { return node->GetKind() == KD_FormInput; } FormInputNode::FormInputNode() - : WorkflowNode(KD_FormInput, false) -{ + : WorkflowNode(KD_FormInput, false) { } -void FormInputNode::Evaluate(WorkflowEvaluationContext& ctx) -{ +void FormInputNode::Evaluate(WorkflowEvaluationContext& ctx) { } -bool DatabaseRowsInputNode::IsInstance(const WorkflowNode* node) -{ +bool DatabaseRowsInputNode::IsInstance(const WorkflowNode* node) { return node->GetKind() == KD_DatabaseRowsInput; } DatabaseRowsInputNode::DatabaseRowsInputNode() - : WorkflowNode(KD_DatabaseRowsInput, false) -{ + : WorkflowNode(KD_DatabaseRowsInput, false) { } -void DatabaseRowsInputNode::Evaluate(WorkflowEvaluationContext& ctx) -{ +void DatabaseRowsInputNode::Evaluate(WorkflowEvaluationContext& ctx) { } diff --git a/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.hpp b/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.hpp index f0b923c..4ad4b02 100644 --- a/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.hpp +++ b/app/source/Cplt/Model/Workflow/Nodes/UserInputNodes.hpp @@ -2,8 +2,7 @@ #include -class FormInputNode : public WorkflowNode -{ +class FormInputNode : public WorkflowNode { public: static bool IsInstance(const WorkflowNode* node); FormInputNode(); @@ -12,8 +11,7 @@ public: virtual void Evaluate(WorkflowEvaluationContext& ctx) override; }; -class DatabaseRowsInputNode : public WorkflowNode -{ +class DatabaseRowsInputNode : public WorkflowNode { public: static bool IsInstance(const WorkflowNode* node); DatabaseRowsInputNode(); diff --git a/app/source/Cplt/Model/Workflow/Value.hpp b/app/source/Cplt/Model/Workflow/Value.hpp index 70fcb57..8e39358 100644 --- a/app/source/Cplt/Model/Workflow/Value.hpp +++ b/app/source/Cplt/Model/Workflow/Value.hpp @@ -8,11 +8,9 @@ #include #include -class BaseValue -{ +class BaseValue { public: - enum Kind - { + enum Kind { KD_Numeric, KD_Text, KD_DateTime, @@ -30,8 +28,7 @@ public: KindCount = InvalidKind, }; - struct KindInfo - { + struct KindInfo { ImGui::IconType PinIcon; RgbaColor PinColor; }; @@ -64,11 +61,9 @@ public: virtual void WriteTo(std::ostream& stream); }; -class BaseObjectDescription -{ +class BaseObjectDescription { public: - struct Property - { + struct Property { std::string Name; BaseValue::Kind Kind; bool Mutatable = true; @@ -78,8 +73,7 @@ public: std::vector Properties; }; -class BaseObjectValue : public BaseValue -{ +class BaseObjectValue : public BaseValue { public: /// \param kind A value kind enum, within the range of KD_BaseObject and KD_BaseObjectLast (both inclusive). static const BaseObjectDescription& QueryObjectInfo(Kind kind); diff --git a/app/source/Cplt/Model/Workflow/Value_Main.cpp b/app/source/Cplt/Model/Workflow/Value_Main.cpp index ca972c4..ab78b86 100644 --- a/app/source/Cplt/Model/Workflow/Value_Main.cpp +++ b/app/source/Cplt/Model/Workflow/Value_Main.cpp @@ -1,35 +1,28 @@ #include "Value.hpp" BaseValue::BaseValue(Kind kind) - : mKind{ kind } -{ + : mKind{ kind } { } -BaseValue::Kind BaseValue::GetKind() const -{ +BaseValue::Kind BaseValue::GetKind() const { return mKind; } -bool BaseValue::SupportsConstant() const -{ +bool BaseValue::SupportsConstant() const { return false; } -void BaseValue::ReadFrom(std::istream& stream) -{ +void BaseValue::ReadFrom(std::istream& stream) { } -void BaseValue::WriteTo(std::ostream& stream) -{ +void BaseValue::WriteTo(std::ostream& stream) { } BaseObjectValue::BaseObjectValue(Kind kind) - : BaseValue(kind) -{ + : BaseValue(kind) { assert(kind >= KD_BaseObject && kind <= KD_BaseObjectLast); } -const BaseObjectDescription& BaseObjectValue::GetObjectDescription() const -{ +const BaseObjectDescription& BaseObjectValue::GetObjectDescription() const { return QueryObjectInfo(this->GetKind()); } diff --git a/app/source/Cplt/Model/Workflow/Value_RTTI.cpp b/app/source/Cplt/Model/Workflow/Value_RTTI.cpp index a2a6960..b075b12 100644 --- a/app/source/Cplt/Model/Workflow/Value_RTTI.cpp +++ b/app/source/Cplt/Model/Workflow/Value_RTTI.cpp @@ -52,8 +52,7 @@ constexpr BaseValue::KindInfo kObjectInfo{ .PinColor = RgbaColor(161, 161, 161), }; -const BaseValue::KindInfo& BaseValue::QueryInfo(BaseValue::Kind kind) -{ +const BaseValue::KindInfo& BaseValue::QueryInfo(BaseValue::Kind kind) { switch (kind) { case KD_Numeric: return kNumericInfo; case KD_Text: return kTextInfo; @@ -72,8 +71,7 @@ const BaseValue::KindInfo& BaseValue::QueryInfo(BaseValue::Kind kind) return kEmptyInfo; } -const char* BaseValue::Format(Kind kind) -{ +const char* BaseValue::Format(Kind kind) { switch (kind) { case KD_Numeric: return I18N_TEXT("Numeric", L10N_VALUE_NUMERIC); case KD_Text: return I18N_TEXT("Text", L10N_VALUE_TEXT); @@ -91,8 +89,7 @@ const char* BaseValue::Format(Kind kind) return ""; } -std::unique_ptr BaseValue::CreateByKind(BaseValue::Kind kind) -{ +std::unique_ptr BaseValue::CreateByKind(BaseValue::Kind kind) { switch (kind) { case KD_Numeric: return std::make_unique(); case KD_Text: return std::make_unique(); @@ -110,8 +107,7 @@ std::unique_ptr BaseValue::CreateByKind(BaseValue::Kind kind) return nullptr; } -bool BaseValue::IsInstance(const BaseValue* value) -{ +bool BaseValue::IsInstance(const BaseValue* value) { return true; } @@ -155,8 +151,7 @@ const BaseObjectDescription kPurchaseDbRowObject{ }, }; -const BaseObjectDescription& BaseObjectValue::QueryObjectInfo(Kind kind) -{ +const BaseObjectDescription& BaseObjectValue::QueryObjectInfo(Kind kind) { switch (kind) { case KD_BaseObject: return kEmptyObjectInfo; case KD_SaleDatabaseRow: return kSaleDbRowObject; @@ -167,8 +162,7 @@ const BaseObjectDescription& BaseObjectValue::QueryObjectInfo(Kind kind) return kEmptyObjectInfo; } -bool BaseObjectValue::IsInstance(const BaseValue* value) -{ +bool BaseObjectValue::IsInstance(const BaseValue* value) { return value->GetKind() >= KD_BaseObject && value->GetKind() <= KD_BaseObjectLast; } diff --git a/app/source/Cplt/Model/Workflow/Values/Basic.cpp b/app/source/Cplt/Model/Workflow/Values/Basic.cpp index 198387c..a480e2f 100644 --- a/app/source/Cplt/Model/Workflow/Values/Basic.cpp +++ b/app/source/Cplt/Model/Workflow/Values/Basic.cpp @@ -4,19 +4,16 @@ #include #include -bool NumericValue::IsInstance(const BaseValue* value) -{ +bool NumericValue::IsInstance(const BaseValue* value) { return value->GetKind() == KD_Numeric; } NumericValue::NumericValue() - : BaseValue(BaseValue::KD_Numeric) -{ + : BaseValue(BaseValue::KD_Numeric) { } template -static std::string NumberToString(T value) -{ +static std::string NumberToString(T value) { char buf[kMaxSize]; auto res = std::to_chars(buf, buf + kMaxSize, value); if (res.ec == std::errc()) { @@ -26,71 +23,58 @@ static std::string NumberToString(T value) } } -std::string NumericValue::GetTruncatedString() const -{ +std::string NumericValue::GetTruncatedString() const { constexpr auto kMaxSize = std::numeric_limits::digits10; return ::NumberToString((int64_t)mValue); } -std::string NumericValue::GetRoundedString() const -{ +std::string NumericValue::GetRoundedString() const { constexpr auto kMaxSize = std::numeric_limits::digits10; return ::NumberToString((int64_t)std::round(mValue)); } -std::string NumericValue::GetString() const -{ +std::string NumericValue::GetString() const { constexpr auto kMaxSize = std::numeric_limits::max_digits10; return ::NumberToString(mValue); } -int64_t NumericValue::GetInt() const -{ +int64_t NumericValue::GetInt() const { return static_cast(mValue); } -double NumericValue::GetValue() const -{ +double NumericValue::GetValue() const { return mValue; } -void NumericValue::SetValue(double value) -{ +void NumericValue::SetValue(double value) { mValue = value; } -bool TextValue::IsInstance(const BaseValue* value) -{ +bool TextValue::IsInstance(const BaseValue* value) { return value->GetKind() == KD_Text; } TextValue::TextValue() - : BaseValue(BaseValue::KD_Text) -{ + : BaseValue(BaseValue::KD_Text) { } -const std::string& TextValue::GetValue() const -{ +const std::string& TextValue::GetValue() const { return mValue; } -void TextValue::SetValue(const std::string& value) -{ +void TextValue::SetValue(const std::string& value) { mValue = value; } -bool DateTimeValue::IsInstance(const BaseValue* value) -{ +bool DateTimeValue::IsInstance(const BaseValue* value) { return value->GetKind() == KD_DateTime; } DateTimeValue::DateTimeValue() - : BaseValue(BaseValue::KD_DateTime) -{ + : BaseValue(BaseValue::KD_DateTime) { } -std::string DateTimeValue::GetString() const -{ +std::string DateTimeValue::GetString() const { namespace chrono = std::chrono; auto t = chrono::system_clock::to_time_t(mValue); @@ -100,12 +84,10 @@ std::string DateTimeValue::GetString() const return std::string(data); } -const std::chrono::time_point& DateTimeValue::GetValue() const -{ +const std::chrono::time_point& DateTimeValue::GetValue() const { return mValue; } -void DateTimeValue::SetValue(const std::chrono::time_point& value) -{ +void DateTimeValue::SetValue(const std::chrono::time_point& value) { mValue = value; } diff --git a/app/source/Cplt/Model/Workflow/Values/Basic.hpp b/app/source/Cplt/Model/Workflow/Values/Basic.hpp index 820fb13..65d2100 100644 --- a/app/source/Cplt/Model/Workflow/Values/Basic.hpp +++ b/app/source/Cplt/Model/Workflow/Values/Basic.hpp @@ -6,8 +6,7 @@ #include #include -class NumericValue : public BaseValue -{ +class NumericValue : public BaseValue { private: double mValue; @@ -29,8 +28,7 @@ public: void SetValue(double value); }; -class TextValue : public BaseValue -{ +class TextValue : public BaseValue { private: std::string mValue; @@ -47,8 +45,7 @@ public: void SetValue(const std::string& value); }; -class DateTimeValue : public BaseValue -{ +class DateTimeValue : public BaseValue { private: std::chrono::time_point mValue; diff --git a/app/source/Cplt/Model/Workflow/Values/Database.cpp b/app/source/Cplt/Model/Workflow/Values/Database.cpp index 25b77e9..25487f3 100644 --- a/app/source/Cplt/Model/Workflow/Values/Database.cpp +++ b/app/source/Cplt/Model/Workflow/Values/Database.cpp @@ -5,40 +5,33 @@ #include -TableKind DatabaseRowIdValue::GetTable() const -{ +TableKind DatabaseRowIdValue::GetTable() const { return mTable; } -int64_t DatabaseRowIdValue::GetRowId() const -{ +int64_t DatabaseRowIdValue::GetRowId() const { return mRowId; } -bool DatabaseRowIdValue::IsInstance(const BaseValue* value) -{ +bool DatabaseRowIdValue::IsInstance(const BaseValue* value) { return value->GetKind() == KD_DatabaseRowId; } DatabaseRowIdValue::DatabaseRowIdValue() : BaseValue(KD_DatabaseRowId) , mTable{ TableKind::Sales } - , mRowId{ std::numeric_limits::max() } -{ + , mRowId{ std::numeric_limits::max() } { } -bool SaleDatabaseRowValue::IsInstance(const BaseValue* value) -{ +bool SaleDatabaseRowValue::IsInstance(const BaseValue* value) { return value->GetKind() == KD_SaleDatabaseRow; } SaleDatabaseRowValue::SaleDatabaseRowValue() - : BaseObjectValue(KD_SaleDatabaseRow) -{ + : BaseObjectValue(KD_SaleDatabaseRow) { } -const BaseValue* SaleDatabaseRowValue::GetProperty(int idx) const -{ +const BaseValue* SaleDatabaseRowValue::GetProperty(int idx) const { switch (idx) { case 0: return &mCustomerName; case 1: return &mDeadline; @@ -47,8 +40,7 @@ const BaseValue* SaleDatabaseRowValue::GetProperty(int idx) const } } -bool SaleDatabaseRowValue::SetProperty(int idx, std::unique_ptr value) -{ +bool SaleDatabaseRowValue::SetProperty(int idx, std::unique_ptr value) { switch (idx) { case 0: return false; case 1: CHECK_VALUE_TYPE_AND_MOVE(DateTimeValue, mDeadline, value.get()); break; @@ -57,18 +49,15 @@ bool SaleDatabaseRowValue::SetProperty(int idx, std::unique_ptr value return true; } -bool PurchaseDatabaseRowValue::IsInstance(const BaseValue* value) -{ +bool PurchaseDatabaseRowValue::IsInstance(const BaseValue* value) { return value->GetKind() == KD_PurchaseDatabaseRow; } PurchaseDatabaseRowValue::PurchaseDatabaseRowValue() - : BaseObjectValue(KD_PurchaseDatabaseRow) -{ + : BaseObjectValue(KD_PurchaseDatabaseRow) { } -const BaseValue* PurchaseDatabaseRowValue::GetProperty(int idx) const -{ +const BaseValue* PurchaseDatabaseRowValue::GetProperty(int idx) const { switch (idx) { case 0: return &mFactoryName; case 1: return &mOrderTime; @@ -77,8 +66,7 @@ const BaseValue* PurchaseDatabaseRowValue::GetProperty(int idx) const } } -bool PurchaseDatabaseRowValue::SetProperty(int idx, std::unique_ptr value) -{ +bool PurchaseDatabaseRowValue::SetProperty(int idx, std::unique_ptr value) { switch (idx) { case 0: return false; case 1: CHECK_VALUE_TYPE_AND_MOVE(DateTimeValue, mOrderTime, value.get()); break; diff --git a/app/source/Cplt/Model/Workflow/Values/Database.hpp b/app/source/Cplt/Model/Workflow/Values/Database.hpp index f1c1571..cacbb1a 100644 --- a/app/source/Cplt/Model/Workflow/Values/Database.hpp +++ b/app/source/Cplt/Model/Workflow/Values/Database.hpp @@ -4,8 +4,7 @@ #include #include -class DatabaseRowIdValue : public BaseValue -{ +class DatabaseRowIdValue : public BaseValue { private: TableKind mTable; int64_t mRowId; @@ -18,8 +17,7 @@ public: int64_t GetRowId() const; }; -class SaleDatabaseRowValue : public BaseObjectValue -{ +class SaleDatabaseRowValue : public BaseObjectValue { private: int mCustomerId; TextValue mCustomerName; @@ -34,8 +32,7 @@ public: virtual bool SetProperty(int idx, std::unique_ptr value); }; -class PurchaseDatabaseRowValue : public BaseObjectValue -{ +class PurchaseDatabaseRowValue : public BaseObjectValue { private: int mFactoryId; TextValue mFactoryName; diff --git a/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp b/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp index 97bf509..718a0c8 100644 --- a/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp +++ b/app/source/Cplt/Model/Workflow/Values/Dictionary.cpp @@ -2,23 +2,19 @@ #include -bool DictionaryValue::IsInstance(const BaseValue* value) -{ +bool DictionaryValue::IsInstance(const BaseValue* value) { return value->GetKind() == KD_Dictionary; } DictionaryValue::DictionaryValue() - : BaseValue(KD_Dictionary) -{ + : BaseValue(KD_Dictionary) { } -int DictionaryValue::GetCount() const -{ +int DictionaryValue::GetCount() const { return mElements.size(); } -BaseValue* DictionaryValue::Find(std::string_view key) -{ +BaseValue* DictionaryValue::Find(std::string_view key) { auto iter = mElements.find(key); if (iter != mElements.end()) { return iter.value().get(); @@ -27,8 +23,7 @@ BaseValue* DictionaryValue::Find(std::string_view key) } } -BaseValue* DictionaryValue::Insert(std::string_view key, std::unique_ptr& value) -{ +BaseValue* DictionaryValue::Insert(std::string_view key, std::unique_ptr& value) { auto [iter, success] = mElements.insert(key, std::move(value)); if (success) { return iter.value().get(); @@ -37,13 +32,11 @@ BaseValue* DictionaryValue::Insert(std::string_view key, std::unique_ptr value) -{ +BaseValue& DictionaryValue::InsertOrReplace(std::string_view key, std::unique_ptr value) { auto [iter, DISCARD] = mElements.emplace(key, std::move(value)); return *iter.value(); } -void DictionaryValue::Remove(std::string_view key) -{ +void DictionaryValue::Remove(std::string_view key) { mElements.erase(mElements.find(key)); } diff --git a/app/source/Cplt/Model/Workflow/Values/Dictionary.hpp b/app/source/Cplt/Model/Workflow/Values/Dictionary.hpp index 6eff308..f14e04f 100644 --- a/app/source/Cplt/Model/Workflow/Values/Dictionary.hpp +++ b/app/source/Cplt/Model/Workflow/Values/Dictionary.hpp @@ -7,8 +7,7 @@ #include #include -class DictionaryValue : public BaseValue -{ +class DictionaryValue : public BaseValue { private: tsl::array_map> mElements; diff --git a/app/source/Cplt/Model/Workflow/Values/List.cpp b/app/source/Cplt/Model/Workflow/Values/List.cpp index 9fd6bfd..e274344 100644 --- a/app/source/Cplt/Model/Workflow/Values/List.cpp +++ b/app/source/Cplt/Model/Workflow/Values/List.cpp @@ -2,99 +2,80 @@ #include -BaseValue* ListValue::Iterator::operator*() const -{ +BaseValue* ListValue::Iterator::operator*() const { return mIter->get(); } -BaseValue* ListValue::Iterator::operator->() const -{ +BaseValue* ListValue::Iterator::operator->() const { return mIter->get(); } -ListValue::Iterator& ListValue::Iterator::operator++() -{ +ListValue::Iterator& ListValue::Iterator::operator++() { ++mIter; return *this; } -ListValue::Iterator ListValue::Iterator::operator++(int) const -{ +ListValue::Iterator ListValue::Iterator::operator++(int) const { return Iterator(mIter + 1); } -ListValue::Iterator& ListValue::Iterator::operator--() -{ +ListValue::Iterator& ListValue::Iterator::operator--() { --mIter; return *this; } -ListValue::Iterator ListValue::Iterator::operator--(int) const -{ +ListValue::Iterator ListValue::Iterator::operator--(int) const { return Iterator(mIter - 1); } -bool operator==(const ListValue::Iterator& a, const ListValue::Iterator& b) -{ +bool operator==(const ListValue::Iterator& a, const ListValue::Iterator& b) { return a.mIter == b.mIter; } ListValue::Iterator::Iterator(decltype(mIter) iter) - : mIter{ iter } -{ + : mIter{ iter } { } -bool ListValue::IsInstance(const BaseValue* value) -{ +bool ListValue::IsInstance(const BaseValue* value) { return value->GetKind() == KD_List; } ListValue::ListValue() - : BaseValue(KD_List) -{ + : BaseValue(KD_List) { } -int ListValue::GetCount() const -{ +int ListValue::GetCount() const { return mElements.size(); } -BaseValue* ListValue::GetElement(int i) const -{ +BaseValue* ListValue::GetElement(int i) const { return mElements[i].get(); } -void ListValue::Append(std::unique_ptr element) -{ +void ListValue::Append(std::unique_ptr element) { mElements.push_back(std::move(element)); } -void ListValue::Insert(int i, std::unique_ptr element) -{ +void ListValue::Insert(int i, std::unique_ptr element) { mElements.insert(mElements.begin() + i, std::move(element)); } -void ListValue::Insert(Iterator iter, std::unique_ptr element) -{ +void ListValue::Insert(Iterator iter, std::unique_ptr element) { mElements.insert(iter.mIter, std::move(element)); } -void ListValue::Remove(int i) -{ +void ListValue::Remove(int i) { mElements.erase(mElements.begin() + i); } -void ListValue::Remove(Iterator iter) -{ +void ListValue::Remove(Iterator iter) { mElements.erase(iter.mIter); } -ListValue::Iterator ListValue::begin() -{ +ListValue::Iterator ListValue::begin() { return Iterator(mElements.begin()); } -ListValue::Iterator ListValue::end() -{ +ListValue::Iterator ListValue::end() { return Iterator(mElements.end()); } diff --git a/app/source/Cplt/Model/Workflow/Values/List.hpp b/app/source/Cplt/Model/Workflow/Values/List.hpp index cc8e061..36f71a1 100644 --- a/app/source/Cplt/Model/Workflow/Values/List.hpp +++ b/app/source/Cplt/Model/Workflow/Values/List.hpp @@ -5,11 +5,9 @@ #include #include -class ListValue : public BaseValue -{ +class ListValue : public BaseValue { public: - class Iterator - { + class Iterator { private: std::vector>::iterator mIter; diff --git a/app/source/Cplt/Model/Workflow/Workflow.hpp b/app/source/Cplt/Model/Workflow/Workflow.hpp index e075e3c..bc75121 100644 --- a/app/source/Cplt/Model/Workflow/Workflow.hpp +++ b/app/source/Cplt/Model/Workflow/Workflow.hpp @@ -20,8 +20,7 @@ namespace ImNodes = ax::NodeEditor; -class WorkflowConnection -{ +class WorkflowConnection { public: static constexpr auto kInvalidId = std::numeric_limits::max(); @@ -44,21 +43,18 @@ public: void WriteTo(std::ostream& stream) const; }; -class WorkflowNode -{ +class WorkflowNode { public: static constexpr auto kInvalidId = std::numeric_limits::max(); static constexpr auto kInvalidPinId = std::numeric_limits::max(); - enum Type - { + enum Type { InputType, TransformType, OutputType, }; - enum Kind - { + enum Kind { KD_NumericAddition, KD_NumericSubtraction, KD_NumericMultiplication, @@ -73,8 +69,7 @@ public: KindCount = InvalidKind, }; - enum Category - { + enum Category { CG_Numeric, CG_Text, CG_Document, @@ -86,8 +81,7 @@ public: CategoryCount = InvalidCategory, }; - struct InputPin - { + struct InputPin { uint32_t Connection = WorkflowConnection::kInvalidId; BaseValue::Kind MatchingType = BaseValue::InvalidKind; bool ConnectionToConst = false; @@ -98,8 +92,7 @@ public: BaseValue::Kind GetMatchingType() const; }; - struct OutputPin - { + struct OutputPin { uint32_t Connection = WorkflowConnection::kInvalidId; BaseValue::Kind MatchingType = BaseValue::InvalidKind; @@ -191,8 +184,7 @@ protected: void OnDetach(); }; -class Workflow : public Asset -{ +class Workflow : public Asset { friend class WorkflowNode; friend class WorkflowEvaluationContext; class Private; @@ -227,8 +219,7 @@ public: WorkflowNode* GetNodeByNodeId(ImNodes::NodeId nodeId); BaseValue* GetConstantById(uint32_t id); - struct GlobalPinId - { + struct GlobalPinId { WorkflowNode* Node; uint32_t PinId; /// true => input pin @@ -256,8 +247,7 @@ public: /* Graph rebuild */ - enum GraphUpdateResult - { + enum GraphUpdateResult { /// Successfully rebuilt graph dependent data. /// Details: nothing is written. GUR_Success, @@ -288,8 +278,7 @@ private: std::pair&, uint32_t> AllocWorkflowStep(); }; -class WorkflowAssetList final : public AssetListTyped -{ +class WorkflowAssetList final : public AssetListTyped { private: // AC = Asset Creator std::string mACNewName; diff --git a/app/source/Cplt/Model/Workflow/Workflow_Main.cpp b/app/source/Cplt/Model/Workflow/Workflow_Main.cpp index 0f35b32..cd0e419 100644 --- a/app/source/Cplt/Model/Workflow/Workflow_Main.cpp +++ b/app/source/Cplt/Model/Workflow/Workflow_Main.cpp @@ -28,112 +28,92 @@ WorkflowConnection::WorkflowConnection() , SourceNode{ WorkflowNode::kInvalidId } , SourcePin{ WorkflowNode::kInvalidPinId } , DestinationNode{ WorkflowNode::kInvalidId } - , DestinationPin{ WorkflowNode::kInvalidPinId } -{ + , DestinationPin{ WorkflowNode::kInvalidPinId } { } -bool WorkflowConnection::IsValid() const -{ +bool WorkflowConnection::IsValid() const { return Id != 0; } -ImNodes::LinkId WorkflowConnection::GetLinkId() const -{ +ImNodes::LinkId WorkflowConnection::GetLinkId() const { // Our id is 0-based (represents an index directly) // but imgui-node-editor uses the value 0 to represent a null id, so we need to offset by 1 return Id + 1; } -void WorkflowConnection::DrawDebugInfo() const -{ +void WorkflowConnection::DrawDebugInfo() const { ImGui::Text("Source (node with output pin):"); ImGui::Text("{ Node = %u, Pin = %u }", SourceNode, SourcePin); ImGui::Text("Destination (node with input pin):"); ImGui::Text("{ Node = %u, Pin = %u }", DestinationNode, DestinationPin); } -void WorkflowConnection::ReadFrom(std::istream& stream) -{ +void WorkflowConnection::ReadFrom(std::istream& stream) { stream >> SourceNode >> SourcePin; stream >> DestinationNode >> DestinationPin; } -void WorkflowConnection::WriteTo(std::ostream& stream) const -{ +void WorkflowConnection::WriteTo(std::ostream& stream) const { stream << SourceNode << SourcePin; stream << DestinationNode << DestinationPin; } -bool WorkflowNode::InputPin::IsConstantConnection() const -{ +bool WorkflowNode::InputPin::IsConstantConnection() const { return ConnectionToConst && IsConnected(); } -bool WorkflowNode::InputPin::IsConnected() const -{ +bool WorkflowNode::InputPin::IsConnected() const { return Connection != WorkflowConnection::kInvalidId; } -BaseValue::Kind WorkflowNode::InputPin::GetMatchingType() const -{ +BaseValue::Kind WorkflowNode::InputPin::GetMatchingType() const { return MatchingType; } -bool WorkflowNode::OutputPin::IsConnected() const -{ +bool WorkflowNode::OutputPin::IsConnected() const { return Connection != WorkflowConnection::kInvalidId; } -BaseValue::Kind WorkflowNode::OutputPin::GetMatchingType() const -{ +BaseValue::Kind WorkflowNode::OutputPin::GetMatchingType() const { return MatchingType; } WorkflowNode::WorkflowNode(Kind kind, bool locked) : mKind{ kind } , mDepth{ -1 } - , mLocked(locked) -{ + , mLocked(locked) { } -Vec2i WorkflowNode::GetPosition() const -{ +Vec2i WorkflowNode::GetPosition() const { return mPosition; } -void WorkflowNode::SetPosition(const Vec2i& position) -{ +void WorkflowNode::SetPosition(const Vec2i& position) { mPosition = position; } -uint32_t WorkflowNode::GetId() const -{ +uint32_t WorkflowNode::GetId() const { return mId; } -ImNodes::NodeId WorkflowNode::GetNodeId() const -{ +ImNodes::NodeId WorkflowNode::GetNodeId() const { // See WorkflowConnection::GetLinkId for the rationale return mId + 1; } -WorkflowNode::Kind WorkflowNode::GetKind() const -{ +WorkflowNode::Kind WorkflowNode::GetKind() const { return mKind; } -int WorkflowNode::GetDepth() const -{ +int WorkflowNode::GetDepth() const { return mDepth; } -bool WorkflowNode::IsLocked() const -{ +bool WorkflowNode::IsLocked() const { return mLocked; } -WorkflowNode::Type WorkflowNode::GetType() const -{ +WorkflowNode::Type WorkflowNode::GetType() const { if (IsInputNode()) { return InputType; } else if (IsOutputNode()) { @@ -143,70 +123,57 @@ WorkflowNode::Type WorkflowNode::GetType() const } } -bool WorkflowNode::IsInputNode() const -{ +bool WorkflowNode::IsInputNode() const { return mInputs.size() == 0; } -bool WorkflowNode::IsOutputNode() const -{ +bool WorkflowNode::IsOutputNode() const { return mOutputs.size() == 0; } -void WorkflowNode::ConnectInput(uint32_t pinId, WorkflowNode& srcNode, uint32_t srcPinId) -{ +void WorkflowNode::ConnectInput(uint32_t pinId, WorkflowNode& srcNode, uint32_t srcPinId) { mWorkflow->Connect(*this, pinId, srcNode, srcPinId); } -void WorkflowNode::DisconnectInput(uint32_t pinId) -{ +void WorkflowNode::DisconnectInput(uint32_t pinId) { mWorkflow->DisconnectByDestination(*this, pinId); } -void WorkflowNode::DrawInputPinDebugInfo(uint32_t pinId) const -{ +void WorkflowNode::DrawInputPinDebugInfo(uint32_t pinId) const { ImGui::Text("Node ID: %d", mId); ImGui::Text("Pin ID: (input) %d", pinId); } -const WorkflowNode::InputPin& WorkflowNode::GetInputPin(uint32_t pinId) const -{ +const WorkflowNode::InputPin& WorkflowNode::GetInputPin(uint32_t pinId) const { return mInputs[pinId]; } -ImNodes::PinId WorkflowNode::GetInputPinUniqueId(uint32_t pinId) const -{ +ImNodes::PinId WorkflowNode::GetInputPinUniqueId(uint32_t pinId) const { return mWorkflow->FabricateGlobalPinId(*this, pinId, false); } -void WorkflowNode::ConnectOutput(uint32_t pinId, WorkflowNode& dstNode, uint32_t dstPinId) -{ +void WorkflowNode::ConnectOutput(uint32_t pinId, WorkflowNode& dstNode, uint32_t dstPinId) { mWorkflow->Connect(dstNode, dstPinId, *this, pinId); } -void WorkflowNode::DisconnectOutput(uint32_t pinId) -{ +void WorkflowNode::DisconnectOutput(uint32_t pinId) { mWorkflow->DisconnectBySource(*this, pinId); } -void WorkflowNode::DrawOutputPinDebugInfo(uint32_t pinId) const -{ +void WorkflowNode::DrawOutputPinDebugInfo(uint32_t pinId) const { ImGui::Text("Node ID: %d", mId); ImGui::Text("Pin ID: (output) %d", pinId); } -const WorkflowNode::OutputPin& WorkflowNode::GetOutputPin(uint32_t pinId) const -{ +const WorkflowNode::OutputPin& WorkflowNode::GetOutputPin(uint32_t pinId) const { return mOutputs[pinId]; } -ImNodes::PinId WorkflowNode::GetOutputPinUniqueId(uint32_t pinId) const -{ +ImNodes::PinId WorkflowNode::GetOutputPinUniqueId(uint32_t pinId) const { return mWorkflow->FabricateGlobalPinId(*this, pinId, true); } -void WorkflowNode::Draw() -{ +void WorkflowNode::Draw() { for (uint32_t i = 0; i < mInputs.size(); ++i) { auto& pin = mInputs[i]; auto& typeInfo = BaseValue::QueryInfo(pin.MatchingType); @@ -223,8 +190,7 @@ void WorkflowNode::Draw() } } -void WorkflowNode::DrawDebugInfo() const -{ +void WorkflowNode::DrawDebugInfo() const { ImGui::Text("Node kind: %s", FormatKind(mKind)); ImGui::Text("Node type: %s", FormatType(GetType())); ImGui::Text("Node ID: %u", mId); @@ -232,20 +198,17 @@ void WorkflowNode::DrawDebugInfo() const DrawExtraDebugInfo(); } -void WorkflowNode::ReadFrom(std::istream& stream) -{ +void WorkflowNode::ReadFrom(std::istream& stream) { stream >> mId; stream >> mPosition.x >> mPosition.y; } -void WorkflowNode::WriteTo(std::ostream& stream) -{ +void WorkflowNode::WriteTo(std::ostream& stream) { stream << mId; stream << mPosition.x << mPosition.y; } -WorkflowNode::InputPin& WorkflowNode::InsertInputPin(int atIdx) -{ +WorkflowNode::InputPin& WorkflowNode::InsertInputPin(int atIdx) { assert(atIdx >= 0 && atIdx < mInputs.size()); mInputs.push_back(InputPin{}); @@ -256,8 +219,7 @@ WorkflowNode::InputPin& WorkflowNode::InsertInputPin(int atIdx) return mInputs[atIdx]; } -void WorkflowNode::RemoveInputPin(int pin) -{ +void WorkflowNode::RemoveInputPin(int pin) { DisconnectInput(pin); for (int i = 0, end = (int)mInputs.size() - 1; i < end; ++i) { SwapInputPin(i, i + 1); @@ -265,8 +227,7 @@ void WorkflowNode::RemoveInputPin(int pin) mInputs.resize(mInputs.size() - 1); } -void WorkflowNode::SwapInputPin(int a, int b) -{ +void WorkflowNode::SwapInputPin(int a, int b) { auto& pinA = mInputs[a]; auto& pinB = mInputs[b]; @@ -284,8 +245,7 @@ void WorkflowNode::SwapInputPin(int a, int b) std::swap(pinA, pinB); } -WorkflowNode::OutputPin& WorkflowNode::InsertOutputPin(int atIdx) -{ +WorkflowNode::OutputPin& WorkflowNode::InsertOutputPin(int atIdx) { assert(atIdx >= 0 && atIdx < mOutputs.size()); mOutputs.push_back(OutputPin{}); @@ -296,8 +256,7 @@ WorkflowNode::OutputPin& WorkflowNode::InsertOutputPin(int atIdx) return mOutputs[atIdx]; } -void WorkflowNode::RemoveOutputPin(int pin) -{ +void WorkflowNode::RemoveOutputPin(int pin) { DisconnectOutput(pin); for (int i = 0, end = (int)mOutputs.size() - 1; i < end; ++i) { SwapInputPin(i, i + 1); @@ -305,8 +264,7 @@ void WorkflowNode::RemoveOutputPin(int pin) mOutputs.resize(mOutputs.size() - 1); } -void WorkflowNode::SwapOutputPin(int a, int b) -{ +void WorkflowNode::SwapOutputPin(int a, int b) { auto& pinA = mOutputs[a]; auto& pinB = mOutputs[b]; @@ -324,71 +282,57 @@ void WorkflowNode::SwapOutputPin(int a, int b) std::swap(pinA, pinB); } -void WorkflowNode::OnAttach(Workflow& workflow, uint32_t newId) -{ +void WorkflowNode::OnAttach(Workflow& workflow, uint32_t newId) { } -void WorkflowNode::OnDetach() -{ +void WorkflowNode::OnDetach() { } -const std::vector& Workflow::GetConnections() const -{ +const std::vector& Workflow::GetConnections() const { return mConnections; } -std::vector& Workflow::GetConnections() -{ +std::vector& Workflow::GetConnections() { return mConnections; } -const std::vector>& Workflow::GetNodes() const -{ +const std::vector>& Workflow::GetNodes() const { return mNodes; } -std::vector>& Workflow::GetNodes() -{ +std::vector>& Workflow::GetNodes() { return mNodes; } -const std::vector>& Workflow::GetConstants() const -{ +const std::vector>& Workflow::GetConstants() const { return mConstants; } -std::vector>& Workflow::GetConstants() -{ +std::vector>& Workflow::GetConstants() { return mConstants; } -WorkflowConnection* Workflow::GetConnectionById(uint32_t id) -{ +WorkflowConnection* Workflow::GetConnectionById(uint32_t id) { return &mConnections[id]; } -WorkflowConnection* Workflow::GetConnectionByLinkId(ImNodes::LinkId id) -{ +WorkflowConnection* Workflow::GetConnectionByLinkId(ImNodes::LinkId id) { return &mConnections[(uint32_t)(size_t)id - 1]; } -WorkflowNode* Workflow::GetNodeById(uint32_t id) -{ +WorkflowNode* Workflow::GetNodeById(uint32_t id) { return mNodes[id].get(); } -WorkflowNode* Workflow::GetNodeByNodeId(ImNodes::NodeId id) -{ +WorkflowNode* Workflow::GetNodeByNodeId(ImNodes::NodeId id) { return mNodes[(uint32_t)(size_t)id - 1].get(); } -BaseValue* Workflow::GetConstantById(uint32_t id) -{ +BaseValue* Workflow::GetConstantById(uint32_t id) { return mConstants[id].get(); } -Workflow::GlobalPinId Workflow::DisassembleGlobalPinId(ImNodes::PinId pinId) -{ +Workflow::GlobalPinId Workflow::DisassembleGlobalPinId(ImNodes::PinId pinId) { // imgui-node-editor requires all pins to have a global, unique id // but in our model the pin are typed (input vs output) and associated with a node: there is no built-in global id // Therefore we encode one ourselves @@ -411,8 +355,7 @@ Workflow::GlobalPinId Workflow::DisassembleGlobalPinId(ImNodes::PinId pinId) return result; } -ImNodes::PinId Workflow::FabricateGlobalPinId(const WorkflowNode& node, uint32_t pinId, bool isOutput) const -{ +ImNodes::PinId Workflow::FabricateGlobalPinId(const WorkflowNode& node, uint32_t pinId, bool isOutput) const { // See this->DisassembleGlobalPinId for format details and rationale uint64_t id = 0; @@ -423,18 +366,15 @@ ImNodes::PinId Workflow::FabricateGlobalPinId(const WorkflowNode& node, uint32_t return id; } -const std::vector>& Workflow::GetDepthGroups() const -{ +const std::vector>& Workflow::GetDepthGroups() const { return mDepthGroups; } -bool Workflow::DoesDepthNeedsUpdate() const -{ +bool Workflow::DoesDepthNeedsUpdate() const { return mDepthsDirty; } -void Workflow::AddNode(std::unique_ptr step) -{ +void Workflow::AddNode(std::unique_ptr step) { auto [storage, id] = AllocWorkflowStep(); storage = std::move(step); storage->OnAttach(*this, id); @@ -442,8 +382,7 @@ void Workflow::AddNode(std::unique_ptr step) storage->mId = id; } -void Workflow::RemoveNode(uint32_t id) -{ +void Workflow::RemoveNode(uint32_t id) { auto& step = mNodes[id]; if (step == nullptr) return; @@ -452,8 +391,7 @@ void Workflow::RemoveNode(uint32_t id) step->mId = WorkflowNode::kInvalidId; } -void Workflow::RemoveConnection(uint32_t id) -{ +void Workflow::RemoveConnection(uint32_t id) { auto& conn = mConnections[id]; if (!conn.IsValid()) return; @@ -464,8 +402,7 @@ void Workflow::RemoveConnection(uint32_t id) mDepthsDirty = true; } -bool Workflow::Connect(WorkflowNode& sourceNode, uint32_t sourcePin, WorkflowNode& destinationNode, uint32_t destinationPin) -{ +bool Workflow::Connect(WorkflowNode& sourceNode, uint32_t sourcePin, WorkflowNode& destinationNode, uint32_t destinationPin) { auto& src = sourceNode.mOutputs[sourcePin]; auto& dst = destinationNode.mInputs[destinationPin]; @@ -491,8 +428,7 @@ bool Workflow::Connect(WorkflowNode& sourceNode, uint32_t sourcePin, WorkflowNod return true; } -bool Workflow::DisconnectBySource(WorkflowNode& sourceNode, uint32_t sourcePin) -{ +bool Workflow::DisconnectBySource(WorkflowNode& sourceNode, uint32_t sourcePin) { auto& sn = sourceNode.mOutputs[sourcePin]; if (!sn.IsConnected()) return false; @@ -507,8 +443,7 @@ bool Workflow::DisconnectBySource(WorkflowNode& sourceNode, uint32_t sourcePin) return true; } -bool Workflow::DisconnectByDestination(WorkflowNode& destinationNode, uint32_t destinationPin) -{ +bool Workflow::DisconnectByDestination(WorkflowNode& destinationNode, uint32_t destinationPin) { auto& dn = destinationNode.mOutputs[destinationPin]; if (!dn.IsConnected()) return false; @@ -523,8 +458,7 @@ bool Workflow::DisconnectByDestination(WorkflowNode& destinationNode, uint32_t d return true; } -Workflow::GraphUpdateResult Workflow::UpdateGraph(GraphUpdateDetails* details) -{ +Workflow::GraphUpdateResult Workflow::UpdateGraph(GraphUpdateDetails* details) { if (!mDepthsDirty) { return GUR_NoWorkToDo; } @@ -533,8 +467,7 @@ Workflow::GraphUpdateResult Workflow::UpdateGraph(GraphUpdateDetails* details) // - Dependency = nodes its input pins are connected to // - Dependents = nodes its output pins are connected to - struct WorkingNode - { + struct WorkingNode { // The max depth out of all dependency nodes, maintained during the traversal and committed as the actual depth // when all dependencies of this node has been resolved. Add 1 to get the depth that will be assigned to the node. int MaximumDepth = 0; @@ -635,28 +568,23 @@ Workflow::GraphUpdateResult Workflow::UpdateGraph(GraphUpdateDetails* details) return GUR_Success; } -class Workflow::Private -{ +class Workflow::Private { public: template - static void OperateStream(TSelf& self, TProxy& proxy) - { + static void OperateStream(TSelf& self, TProxy& proxy) { // TODO } }; -void Workflow::ReadFromDataStream(InputDataStream& stream) -{ +void Workflow::ReadFromDataStream(InputDataStream& stream) { Private::OperateStream(*this, stream); } -void Workflow::WriteToDataStream(OutputDataStream& stream) const -{ +void Workflow::WriteToDataStream(OutputDataStream& stream) const { Private::OperateStream(*this, stream); } -std::pair Workflow::AllocWorkflowConnection() -{ +std::pair Workflow::AllocWorkflowConnection() { for (size_t idx = 0; idx < mConnections.size(); ++idx) { auto& elm = mConnections[idx]; if (!elm.IsValid()) { @@ -671,8 +599,7 @@ std::pair Workflow::AllocWorkflowConnection() return { conn, id }; } -std::pair&, uint32_t> Workflow::AllocWorkflowStep() -{ +std::pair&, uint32_t> Workflow::AllocWorkflowStep() { for (size_t idx = 0; idx < mNodes.size(); ++idx) { auto& elm = mNodes[idx]; if (elm == nullptr) { @@ -686,14 +613,12 @@ std::pair&, uint32_t> Workflow::AllocWorkflowStep( return { node, id }; } -void WorkflowAssetList::DiscoverFiles(const std::function& callback) const -{ +void WorkflowAssetList::DiscoverFiles(const std::function& callback) const { auto dir = GetConnectedProject().GetWorkflowsDirectory(); DiscoverFilesByExtension(callback, dir, ".cplt-workflow"sv); } -std::string WorkflowAssetList::RetrieveNameFromFile(const fs::path& file) const -{ +std::string WorkflowAssetList::RetrieveNameFromFile(const fs::path& file) const { auto res = DataArchive::LoadFile(file); if (!res) return ""; auto& stream = res.value(); @@ -704,19 +629,16 @@ std::string WorkflowAssetList::RetrieveNameFromFile(const fs::path& file) const return assetInfo.Name; } -uuids::uuid WorkflowAssetList::RetrieveUuidFromFile(const fs::path& file) const -{ +uuids::uuid WorkflowAssetList::RetrieveUuidFromFile(const fs::path& file) const { return uuids::uuid::from_string(file.stem().string()); } -fs::path WorkflowAssetList::RetrievePathFromAsset(const SavedAsset& asset) const -{ +fs::path WorkflowAssetList::RetrievePathFromAsset(const SavedAsset& asset) const { auto fileName = uuids::to_string(asset.Uuid); return GetConnectedProject().GetWorkflowPath(fileName); } -bool WorkflowAssetList::SaveInstance(const SavedAsset& assetInfo, const Asset* asset) const -{ +bool WorkflowAssetList::SaveInstance(const SavedAsset& assetInfo, const Asset* asset) const { auto path = RetrievePathFromAsset(assetInfo); auto res = DataArchive::SaveFile(path); if (!res) return false; @@ -731,8 +653,7 @@ bool WorkflowAssetList::SaveInstance(const SavedAsset& assetInfo, const Asset* a return true; } -static std::unique_ptr LoadWorkflowFromFile(const fs::path& path) -{ +static std::unique_ptr LoadWorkflowFromFile(const fs::path& path) { auto res = DataArchive::LoadFile(path); if (!res) return nullptr; auto& stream = res.value(); @@ -747,18 +668,15 @@ static std::unique_ptr LoadWorkflowFromFile(const fs::path& path) return workflow; } -Workflow* WorkflowAssetList::LoadInstance(const SavedAsset& assetInfo) const -{ +Workflow* WorkflowAssetList::LoadInstance(const SavedAsset& assetInfo) const { return ::LoadWorkflowFromFile(RetrievePathFromAsset(assetInfo)).release(); } -Workflow* WorkflowAssetList::CreateInstance(const SavedAsset& assetInfo) const -{ +Workflow* WorkflowAssetList::CreateInstance(const SavedAsset& assetInfo) const { return new Workflow(); } -bool WorkflowAssetList::RenameInstanceOnDisk(const SavedAsset& assetInfo, std::string_view oldName) const -{ +bool WorkflowAssetList::RenameInstanceOnDisk(const SavedAsset& assetInfo, std::string_view oldName) const { auto path = RetrievePathFromAsset(assetInfo); auto workflow = ::LoadWorkflowFromFile(path); @@ -769,8 +687,7 @@ bool WorkflowAssetList::RenameInstanceOnDisk(const SavedAsset& assetInfo, std::s return true; } -void WorkflowAssetList::DisplayAssetCreator(ListState& state) -{ +void WorkflowAssetList::DisplayAssetCreator(ListState& state) { auto ValidateNewName = [&]() -> void { if (mACNewName.empty()) { mACNewNameError = NameSelectionError::Empty; @@ -826,8 +743,7 @@ void WorkflowAssetList::DisplayAssetCreator(ListState& state) } } -void WorkflowAssetList::DisplayDetailsTable(ListState& state) const -{ +void WorkflowAssetList::DisplayDetailsTable(ListState& state) const { ImGui::BeginTable("AssetDetailsTable", 1, ImGuiTableFlags_Borders); ImGui::TableSetupColumn(I18N_TEXT("Name", L10N_NAME)); diff --git a/app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp b/app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp index ee3da28..6b8f76e 100644 --- a/app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp +++ b/app/source/Cplt/Model/Workflow/Workflow_RTTI.cpp @@ -9,8 +9,7 @@ #include -const char* WorkflowNode::FormatKind(Kind kind) -{ +const char* WorkflowNode::FormatKind(Kind kind) { switch (kind) { case KD_NumericAddition: return I18N_TEXT("Add", L10N_WORKFLOW_ADD); case KD_NumericSubtraction: return I18N_TEXT("Subtract", L10N_WORKFLOW_SUB); @@ -27,8 +26,7 @@ const char* WorkflowNode::FormatKind(Kind kind) return ""; } -const char* WorkflowNode::FormatCategory(WorkflowNode::Category category) -{ +const char* WorkflowNode::FormatCategory(WorkflowNode::Category category) { switch (category) { case CG_Numeric: return I18N_TEXT("Numeric", L10N_WORKFLOW_CATEGORY_NUMERIC); case CG_Text: return I18N_TEXT("Text", L10N_WORKFLOW_CATEGORY_TEXT); @@ -42,8 +40,7 @@ const char* WorkflowNode::FormatCategory(WorkflowNode::Category category) return ""; } -const char* WorkflowNode::FormatType(Type type) -{ +const char* WorkflowNode::FormatType(Type type) { switch (type) { case InputType: return I18N_TEXT("Input", L10N_WORKFLOW_KIND_INPUT); case TransformType: return I18N_TEXT("Transform", L10N_WORKFLOW_KIND_TRANSFORM); @@ -52,8 +49,7 @@ const char* WorkflowNode::FormatType(Type type) return ""; } -WorkflowNode::Category WorkflowNode::QueryCategory(Kind kind) -{ +WorkflowNode::Category WorkflowNode::QueryCategory(Kind kind) { switch (kind) { case KD_NumericAddition: case KD_NumericSubtraction: @@ -74,8 +70,7 @@ WorkflowNode::Category WorkflowNode::QueryCategory(Kind kind) return InvalidCategory; } -std::span WorkflowNode::QueryCategoryMembers(Category category) -{ +std::span WorkflowNode::QueryCategoryMembers(Category category) { constexpr WorkflowNode::Kind kNumeric[] = { KD_NumericAddition, KD_NumericSubtraction, @@ -119,8 +114,7 @@ std::span WorkflowNode::QueryCategoryMembers(Category return {}; } -std::unique_ptr WorkflowNode::CreateByKind(WorkflowNode::Kind kind) -{ +std::unique_ptr WorkflowNode::CreateByKind(WorkflowNode::Kind kind) { switch (kind) { case KD_NumericAddition: return std::make_unique(NumericOperationNode::Addition); case KD_NumericSubtraction: return std::make_unique(NumericOperationNode::Subtraction); @@ -137,7 +131,6 @@ std::unique_ptr WorkflowNode::CreateByKind(WorkflowNode::Kind kind return nullptr; } -bool WorkflowNode::IsInstance(const WorkflowNode* node) -{ +bool WorkflowNode::IsInstance(const WorkflowNode* node) { return true; } -- cgit v1.2.3-70-g09d2