From 7a325e1b3be04bc54941431458903022da1643ac Mon Sep 17 00:00:00 2001 From: rtk0c Date: Thu, 3 Jun 2021 10:06:55 -0700 Subject: Create template inheritance hierarchy, object value RTTI system --- core/src/Model/Workflow/Value.hpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'core/src/Model/Workflow/Value.hpp') diff --git a/core/src/Model/Workflow/Value.hpp b/core/src/Model/Workflow/Value.hpp index 8b3e63a..ff62d43 100644 --- a/core/src/Model/Workflow/Value.hpp +++ b/core/src/Model/Workflow/Value.hpp @@ -5,6 +5,7 @@ #include #include +#include class BaseValue { @@ -14,6 +15,12 @@ public: KD_Numeric, KD_Text, KD_DateTime, + KD_DatabaseRowId, + + KD_BaseObject, + KD_SaleDatabaseRow, + KD_PurchaseDatabaseRow, + KD_BaseObjectLast = KD_PurchaseDatabaseRow, /// An unspecified type, otherwise known as "any" in some contexts. InvalidKind, @@ -34,6 +41,8 @@ public: static const char* Format(Kind kind); static std::unique_ptr CreateByKind(Kind kind); + static bool IsInstance(const BaseValue* value); + BaseValue(Kind kind); virtual ~BaseValue() = default; @@ -51,3 +60,32 @@ public: virtual void ReadFrom(std::istream& stream); virtual void WriteTo(std::ostream& stream); }; + +class BaseObjectDescription +{ +public: + struct Property + { + std::string Name; + BaseValue::Kind Kind; + bool Mutatable = true; + }; + +public: + std::vector Properties; +}; + +class BaseObjectValue : public BaseValue +{ +public: + /// \param kind A value kind enum, within the range of KD_BaseObject and KD_BaseObjectLast (both inclusive). + static const BaseObjectDescription& QueryObjectInfo(Kind kind); + + static bool IsInstance(const BaseValue* value); + BaseObjectValue(Kind kind); + + const BaseObjectDescription& GetObjectDescription() const; + + virtual const BaseValue* GetProperty(int idx) const = 0; + virtual bool SetProperty(int idx, std::unique_ptr value) = 0; +}; -- cgit v1.2.3-70-g09d2