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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#include "Value.hpp"
#include "Model/Workflow/Values/Basic.hpp"
#include "Model/Workflow/Values/Database.hpp"
#include "UI/UI.hpp"
constexpr BaseValue::KindInfo kNumericInfo{
.PinIcon = ImGui::IconType::Circle,
.PinColor = RgbaColor(147, 226, 74),
};
constexpr BaseValue::KindInfo kTextInfo{
.PinIcon = ImGui::IconType::Circle,
.PinColor = RgbaColor(124, 21, 153),
};
constexpr BaseValue::KindInfo kDateTimeInfo{
.PinIcon = ImGui::IconType::Circle,
.PinColor = RgbaColor(147, 226, 74),
};
constexpr BaseValue::KindInfo kDatabaseRowIdInfo{
.PinIcon = ImGui::IconType::Circle,
.PinColor = RgbaColor(216, 42, 221),
};
constexpr BaseValue::KindInfo kDatabaseRowInfo{
.PinIcon = ImGui::IconType::Square,
.PinColor = RgbaColor(15, 124, 196),
};
constexpr BaseValue::KindInfo kObjectinfo{
.PinIcon = ImGui::IconType::Square,
.PinColor = RgbaColor(161, 161, 161),
};
const BaseValue::KindInfo& BaseValue::QueryInfo(BaseValue::Kind kind)
{
switch (kind) {
case KD_Numeric: return kNumericInfo;
case KD_Text: return kTextInfo;
case KD_DateTime: return kDateTimeInfo;
case KD_DatabaseRowId: return kDatabaseRowIdInfo;
case KD_BaseObject: return kObjectinfo;
case KD_SaleDatabaseRow:
case KD_PurchaseDatabaseRow:
return kDatabaseRowInfo;
case InvalidKind: break;
}
// TODO provide info here
}
const char* BaseValue::Format(Kind kind)
{
switch (kind) {
case KD_Numeric: return "Numeric";
case KD_Text: return "Text";
case KD_DateTime: return "Date/time";
case KD_DatabaseRowId: return "Row id";
case KD_BaseObject: return "Object";
case KD_SaleDatabaseRow: return "Sale record";
case KD_PurchaseDatabaseRow: return "Purchase record";
case InvalidKind: break;
}
return "<invalid kind>";
}
std::unique_ptr<BaseValue> BaseValue::CreateByKind(BaseValue::Kind kind)
{
switch (kind) {
case KD_Numeric: return std::make_unique<NumericValue>();
case KD_Text: return std::make_unique<TextValue>();
case KD_DateTime: return std::make_unique<DateTimeValue>();
case KD_DatabaseRowId: return std::make_unique<DatabaseRowIdValue>();
case KD_BaseObject: return nullptr;
case KD_SaleDatabaseRow: return std::make_unique<SaleDatabaseRowValue>();
case KD_PurchaseDatabaseRow: return std::make_unique<PurchaseDatabaseRowValue>();
case InvalidKind: break;
}
return nullptr;
}
bool BaseValue::IsInstance(const BaseValue* value)
{
return true;
}
const BaseObjectDescription kEmptyObjectInfo{
.Properties = {},
};
const BaseObjectDescription kSaleDbRowObject{
.Properties = {
{
.Name = "Customer",
.Kind = BaseValue::KD_Text,
.Mutatable = false,
},
{
.Name = "Deadline",
.Kind = BaseValue::KD_DateTime,
},
{
.Name = "Completion time",
.Kind = BaseValue::KD_DateTime,
},
},
};
const BaseObjectDescription kPurchaseDbRowObject{
.Properties = {
{
.Name = "Factory",
.Kind = BaseValue::KD_Text,
.Mutatable = false,
},
{
.Name = "Order time",
.Kind = BaseValue::KD_DateTime,
},
{
.Name = "Arrival time",
.Kind = BaseValue::KD_DateTime,
},
},
};
const BaseObjectDescription& BaseObjectValue::QueryObjectInfo(Kind kind)
{
switch (kind) {
case KD_BaseObject: return kEmptyObjectInfo;
case KD_SaleDatabaseRow: return kSaleDbRowObject;
case KD_PurchaseDatabaseRow: return kPurchaseDbRowObject;
default: break;
}
return kEmptyObjectInfo;
}
bool BaseObjectValue::IsInstance(const BaseValue* value)
{
return value->GetKind() >= KD_BaseObject &&
value->GetKind() <= KD_BaseObjectLast;
}
|