aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/WorkflowNodes.hpp
blob: e7d4bfcbb75ef061ecff3eeef9bc184223f537b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once

#include "Model/Workflow.hpp"

#include <cstddef>
#include <memory>
#include <variant>
#include <vector>

class NumericOperationNode : public WorkflowNode {
public:
	enum OperationType {
		Addition,
		Subtraction,
		Multiplication,
		Division,

		InvalidType,
		TypeCount = InvalidType,
	};

private:
	OperationType mType;

public:
	static Kind OperationTypeToNodeKind(OperationType type);
	static OperationType NodeKindToOperationType(Kind kind);
	static bool IsInstance(const WorkflowNode* node);
	NumericOperationNode(OperationType type);

	virtual void Evaluate(WorkflowEvaluationContext& ctx) override;
};

class NumericExpressionNode : public WorkflowNode {
public:
	static bool IsInstance(const WorkflowNode* node);
	NumericExpressionNode();

	// TODO
};

class FormatTextNode : public WorkflowNode {
public:
	enum ArgumentType {
		NumericArgument,
		TextArgument,
		DateTimeArgument,
	};

private:
	struct Argument;
	using Element = std::variant<std::string, Argument>;

	std::vector<Element> mElements;
	int mMinOutputChars;

public:
	static BaseValue::Kind ArgumentTypeToValueKind(ArgumentType arg);
	static bool IsInstance(const WorkflowNode* node);
	FormatTextNode();

	int GetElementCount() const;
	const Element& GetElement(int idx) const;

	void SetElement(int idx, std::string text);
	void SetElement(int idx, ArgumentType argument);
	void InsertElement(int idx, std::string text);
	void InsertElement(int idx, ArgumentType argument);
	void AppendElement(std::string text);
	void AppendElement(ArgumentType argument);
	void RemoveElement(int idx);

	virtual void Evaluate(WorkflowEvaluationContext& ctx) override;

private:
	void PreRemoveElement(int idx);
};

class DocumentTemplateExpansionNode : public WorkflowNode {
public:
	static bool IsInstance(const WorkflowNode* node);
	DocumentTemplateExpansionNode();

	// TODO
};

class FormInputNode : public WorkflowNode {
public:
	static bool IsInstance(const WorkflowNode* node);
	FormInputNode();

	// TODO
};

class DatabaseRowsInputNode : public WorkflowNode {
public:
	static bool IsInstance(const WorkflowNode* node);
	DatabaseRowsInputNode();

	// TODO
};