aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/Workflow/Values
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/Model/Workflow/Values')
-rw-r--r--core/src/Model/Workflow/Values/Basic.cpp (renamed from core/src/Model/Workflow/Values/BasicValues.cpp)2
-rw-r--r--core/src/Model/Workflow/Values/Basic.hpp (renamed from core/src/Model/Workflow/Values/BasicValues.hpp)15
-rw-r--r--core/src/Model/Workflow/Values/Database.cpp88
-rw-r--r--core/src/Model/Workflow/Values/Database.hpp51
-rw-r--r--core/src/Model/Workflow/Values/fwd.hpp10
5 files changed, 164 insertions, 2 deletions
diff --git a/core/src/Model/Workflow/Values/BasicValues.cpp b/core/src/Model/Workflow/Values/Basic.cpp
index 748c652..d6a2395 100644
--- a/core/src/Model/Workflow/Values/BasicValues.cpp
+++ b/core/src/Model/Workflow/Values/Basic.cpp
@@ -1,4 +1,4 @@
-#include "BasicValues.hpp"
+#include "Basic.hpp"
#include <charconv>
#include <cmath>
diff --git a/core/src/Model/Workflow/Values/BasicValues.hpp b/core/src/Model/Workflow/Values/Basic.hpp
index 795876e..38e0531 100644
--- a/core/src/Model/Workflow/Values/BasicValues.hpp
+++ b/core/src/Model/Workflow/Values/Basic.hpp
@@ -15,6 +15,11 @@ public:
static bool IsInstance(const BaseValue* value);
NumericValue();
+ NumericValue(const NumericValue&) = delete;
+ NumericValue& operator=(const NumericValue&) = delete;
+ NumericValue(NumericValue&&) = default;
+ NumericValue& operator=(NumericValue&&) = default;
+
std::string GetTruncatedString() const;
std::string GetRoundedString() const;
std::string GetString() const;
@@ -33,6 +38,11 @@ public:
static bool IsInstance(const BaseValue* value);
TextValue();
+ TextValue(const TextValue&) = delete;
+ TextValue& operator=(const TextValue&) = delete;
+ TextValue(TextValue&&) = default;
+ TextValue& operator=(TextValue&&) = default;
+
const std::string& GetValue() const;
void SetValue(const std::string& value);
};
@@ -46,6 +56,11 @@ public:
static bool IsInstance(const BaseValue* value);
DateTimeValue();
+ DateTimeValue(const DateTimeValue&) = delete;
+ DateTimeValue& operator=(const DateTimeValue&) = delete;
+ DateTimeValue(DateTimeValue&&) = default;
+ DateTimeValue& operator=(DateTimeValue&&) = default;
+
std::string GetString() const;
const std::chrono::time_point<std::chrono::system_clock>& GetValue() const;
void SetValue(const std::chrono::time_point<std::chrono::system_clock>& value);
diff --git a/core/src/Model/Workflow/Values/Database.cpp b/core/src/Model/Workflow/Values/Database.cpp
new file mode 100644
index 0000000..12d2b80
--- /dev/null
+++ b/core/src/Model/Workflow/Values/Database.cpp
@@ -0,0 +1,88 @@
+#include "Database.hpp"
+
+#include "Model/TransactionsModel.hpp"
+#include "Model/Workflow/ValueInternals.hpp"
+
+#include <limits>
+
+TableKind DatabaseRowIdValue::GetTable() const
+{
+ return mTable;
+}
+
+int64_t DatabaseRowIdValue::GetRowId() const
+{
+ return mRowId;
+}
+
+bool DatabaseRowIdValue::IsInstance(const BaseValue* value)
+{
+ return value->GetKind() == KD_DatabaseRowId;
+}
+
+DatabaseRowIdValue::DatabaseRowIdValue()
+ : BaseValue(KD_DatabaseRowId)
+ , mTable{ TableKind::Sales }
+ , mRowId{ std::numeric_limits<int64_t>::max() }
+{
+}
+
+bool SaleDatabaseRowValue::IsInstance(const BaseValue* value)
+{
+ return value->GetKind() == KD_SaleDatabaseRow;
+}
+
+SaleDatabaseRowValue::SaleDatabaseRowValue()
+ : BaseObjectValue(KD_SaleDatabaseRow)
+{
+}
+
+const BaseValue* SaleDatabaseRowValue::GetProperty(int idx) const
+{
+ switch (idx) {
+ case 0: return &mCustomerName;
+ case 1: return &mDeadline;
+ case 2: return &mDeliveryTime;
+ default: return nullptr;
+ }
+}
+
+bool SaleDatabaseRowValue::SetProperty(int idx, std::unique_ptr<BaseValue> value)
+{
+ switch (idx) {
+ case 0: return false;
+ case 1: CHECK_VALUE_TYPE_AND_MOVE(DateTimeValue, mDeadline, value.get()); break;
+ case 2: CHECK_VALUE_TYPE_AND_MOVE(DateTimeValue, mDeliveryTime, value.get()); break;
+ }
+ return true;
+}
+
+bool PurchaseDatabaseRowValue::IsInstance(const BaseValue* value)
+{
+ return value->GetKind() == KD_PurchaseDatabaseRow;
+}
+
+PurchaseDatabaseRowValue::PurchaseDatabaseRowValue()
+ : BaseObjectValue(KD_PurchaseDatabaseRow)
+{
+}
+
+const BaseValue* PurchaseDatabaseRowValue::GetProperty(int idx) const
+{
+ switch (idx) {
+ case 0: return &mFactoryName;
+ case 1: return &mOrderTime;
+ case 2: return &mDeliveryTime;
+ default: return nullptr;
+ }
+}
+
+bool PurchaseDatabaseRowValue::SetProperty(int idx, std::unique_ptr<BaseValue> value)
+{
+ switch (idx) {
+ case 0: return false;
+ case 1: CHECK_VALUE_TYPE_AND_MOVE(DateTimeValue, mOrderTime, value.get()); break;
+ case 2: CHECK_VALUE_TYPE_AND_MOVE(DateTimeValue, mDeliveryTime, value.get()); break;
+ }
+ return true;
+}
diff --git a/core/src/Model/Workflow/Values/Database.hpp b/core/src/Model/Workflow/Values/Database.hpp
new file mode 100644
index 0000000..e8a4f83
--- /dev/null
+++ b/core/src/Model/Workflow/Values/Database.hpp
@@ -0,0 +1,51 @@
+#pragma once
+
+#include "Model/Workflow/Value.hpp"
+#include "Model/Workflow/Values/Basic.hpp"
+#include "cplt_fwd.hpp"
+
+class DatabaseRowIdValue : public BaseValue
+{
+private:
+ TableKind mTable;
+ int64_t mRowId;
+
+public:
+ static bool IsInstance(const BaseValue* value);
+ DatabaseRowIdValue();
+
+ TableKind GetTable() const;
+ int64_t GetRowId() const;
+};
+
+class SaleDatabaseRowValue : public BaseObjectValue
+{
+private:
+ int mCustomerId;
+ TextValue mCustomerName;
+ DateTimeValue mDeadline;
+ DateTimeValue mDeliveryTime;
+
+public:
+ static bool IsInstance(const BaseValue* value);
+ SaleDatabaseRowValue();
+
+ virtual const BaseValue* GetProperty(int idx) const;
+ virtual bool SetProperty(int idx, std::unique_ptr<BaseValue> value);
+};
+
+class PurchaseDatabaseRowValue : public BaseObjectValue
+{
+private:
+ int mFactoryId;
+ TextValue mFactoryName;
+ DateTimeValue mOrderTime;
+ DateTimeValue mDeliveryTime;
+
+public:
+ static bool IsInstance(const BaseValue* value);
+ PurchaseDatabaseRowValue();
+
+ virtual const BaseValue* GetProperty(int idx) const;
+ virtual bool SetProperty(int idx, std::unique_ptr<BaseValue> value);
+};
diff --git a/core/src/Model/Workflow/Values/fwd.hpp b/core/src/Model/Workflow/Values/fwd.hpp
index 24f8119..de26226 100644
--- a/core/src/Model/Workflow/Values/fwd.hpp
+++ b/core/src/Model/Workflow/Values/fwd.hpp
@@ -1,6 +1,14 @@
#pragma once
-// BasicValues.hpp
+// Basic.hpp
class NumericValue;
class TextValue;
class DateTimeValue;
+
+// Database.hpp
+class DatabaseRowIdValue;
+class SaleDatabaseRowValue;
+class PurchaseDatabaseRowValue;
+
+// List.hpp
+class ListValue;