diff options
Diffstat (limited to 'core/src/Model/Workflow/Value_RTTI.cpp')
-rw-r--r-- | core/src/Model/Workflow/Value_RTTI.cpp | 115 |
1 files changed, 108 insertions, 7 deletions
diff --git a/core/src/Model/Workflow/Value_RTTI.cpp b/core/src/Model/Workflow/Value_RTTI.cpp index 5e24ed7..44b047c 100644 --- a/core/src/Model/Workflow/Value_RTTI.cpp +++ b/core/src/Model/Workflow/Value_RTTI.cpp @@ -1,6 +1,7 @@ #include "Value.hpp" -#include "Model/Workflow/Values/BasicValues.hpp" +#include "Model/Workflow/Values/Basic.hpp" +#include "Model/Workflow/Values/Database.hpp" #include "UI/UI.hpp" constexpr BaseValue::KindInfo kNumericInfo{ @@ -13,19 +14,42 @@ constexpr BaseValue::KindInfo kTextInfo{ .PinColor = RgbaColor(124, 21, 153), }; -constexpr BaseValue::KindInfo kDateTimeInfo{ - .PinIcon = ImGui::IconType::Diamond, +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: break; - case KD_DateTime: break; + 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) @@ -34,8 +58,15 @@ const char* BaseValue::Format(Kind kind) case KD_Numeric: return "Numeric"; case KD_Text: return "Text"; case KD_DateTime: return "Date/time"; - case InvalidKind: return "<invalid kind>"; + 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) @@ -44,6 +75,76 @@ std::unique_ptr<BaseValue> BaseValue::CreateByKind(BaseValue::Kind 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 InvalidKind: return nullptr; + 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; } |