diff options
Diffstat (limited to 'core/src/Model/Workflow')
-rw-r--r-- | core/src/Model/Workflow/Workflow.hpp | 17 | ||||
-rw-r--r-- | core/src/Model/Workflow/Workflow_RTTI.cpp | 83 |
2 files changed, 99 insertions, 1 deletions
diff --git a/core/src/Model/Workflow/Workflow.hpp b/core/src/Model/Workflow/Workflow.hpp index 9c809bf..cba0d72 100644 --- a/core/src/Model/Workflow/Workflow.hpp +++ b/core/src/Model/Workflow/Workflow.hpp @@ -7,6 +7,7 @@ #include <imgui_node_editor.h> #include <cstddef> +#include <span> #include <cstdint> #include <filesystem> #include <functional> @@ -72,6 +73,19 @@ public: KindCount = InvalidKind, }; + enum Category + { + CG_Numeric, + CG_Text, + CG_Document, + CG_UserInput, + CG_SystemInput, + CG_Output, + + InvalidCategory, + CategoryCount = InvalidCategory, + }; + struct InputPin { uint32_t Connection = WorkflowConnection::kInvalidId; @@ -108,7 +122,10 @@ protected: public: static const char* FormatKind(Kind kind); + static const char* FormatCategory(Category category); static const char* FormatType(Type type); + static Category QueryCategory(Kind kind); + static std::span<const Kind> QueryCategoryMembers(Category category); static std::unique_ptr<WorkflowNode> CreateByKind(Kind kind); static bool IsInstance(const WorkflowNode* node); diff --git a/core/src/Model/Workflow/Workflow_RTTI.cpp b/core/src/Model/Workflow/Workflow_RTTI.cpp index 579fb3b..cb66c69 100644 --- a/core/src/Model/Workflow/Workflow_RTTI.cpp +++ b/core/src/Model/Workflow/Workflow_RTTI.cpp @@ -27,6 +27,21 @@ const char* WorkflowNode::FormatKind(Kind kind) return ""; } +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); + case CG_Document: return I18N_TEXT("Document", L10N_WORKFLOW_CATEGORY_DOCUMENT); + case CG_UserInput: return I18N_TEXT("User input", L10N_WORKFLOW_CATEGORY_USER_INPUT); + case CG_SystemInput: return I18N_TEXT("System input", L10N_WORKFLOW_CATEGORY_SYS_INPUT); + case CG_Output: return I18N_TEXT("Output", L10N_WORKFLOW_CATEGORY_OUTPUT); + + case InvalidCategory: break; + } + return ""; +} + const char* WorkflowNode::FormatType(Type type) { switch (type) { @@ -37,6 +52,73 @@ const char* WorkflowNode::FormatType(Type type) return ""; } +WorkflowNode::Category WorkflowNode::QueryCategory(Kind kind) +{ + switch (kind) { + case KD_NumericAddition: + case KD_NumericSubtraction: + case KD_NumericMultiplication: + case KD_NumericDivision: + case KD_NumericExpression: + return CG_Numeric; + case KD_TextFormatting: + return CG_Text; + case KD_DocumentTemplateExpansion: + return CG_Document; + case KD_FormInput: + case KD_DatabaseRowsInput: + return CG_UserInput; + + case InvalidKind: break; + } + return InvalidCategory; +} + +std::span<const WorkflowNode::Kind> WorkflowNode::QueryCategoryMembers(Category category) +{ + constexpr WorkflowNode::Kind kNumeric[] = { + KD_NumericAddition, + KD_NumericSubtraction, + KD_NumericMultiplication, + KD_NumericDivision, + KD_NumericExpression, + }; + + constexpr WorkflowNode::Kind kText[] = { + KD_TextFormatting, + }; + + constexpr WorkflowNode::Kind kDocument[] = { + KD_DocumentTemplateExpansion, + }; + + constexpr WorkflowNode::Kind kUserInput[] = { + KD_FormInput, + KD_DatabaseRowsInput, + }; + + // TODO remove invalid kinds after we have nodes of these categories + constexpr WorkflowNode::Kind kSystemInput[] = { + InvalidKind, + }; + + constexpr WorkflowNode::Kind kOutput[] = { + InvalidKind, + }; + + switch (category) { + case CG_Numeric: return kNumeric; + case CG_Text: return kText; + case CG_Document: return kDocument; + case CG_UserInput: return kUserInput; + case CG_SystemInput: return kSystemInput; + case CG_Output: return kOutput; + + case InvalidCategory: break; + } + return {}; +} + std::unique_ptr<WorkflowNode> WorkflowNode::CreateByKind(WorkflowNode::Kind kind) { switch (kind) { @@ -44,7 +126,6 @@ std::unique_ptr<WorkflowNode> WorkflowNode::CreateByKind(WorkflowNode::Kind kind case KD_NumericSubtraction: return std::make_unique<NumericOperationNode>(NumericOperationNode::Subtraction); case KD_NumericMultiplication: return std::make_unique<NumericOperationNode>(NumericOperationNode::Multiplication); case KD_NumericDivision: return std::make_unique<NumericOperationNode>(NumericOperationNode::Division); - case KD_NumericExpression: return std::make_unique<NumericExpressionNode>(); case KD_TextFormatting: return std::make_unique<TextFormatterNode>(); case KD_DocumentTemplateExpansion: return std::make_unique<DocumentTemplateExpansionNode>(); |