aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/Items.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2021-03-31 20:19:18 -0700
committerrtk0c <[email protected]>2021-03-31 20:19:18 -0700
commit44f5fa5c8f258e8fc1f7d7e2e45e0485bd6cc490 (patch)
tree3f09a1cce46d38f5a8c6266150e67af3802d4b95 /core/src/Model/Items.cpp
parent31950890c939862f79c817053c106bf711c63a64 (diff)
Complete items tab (UI and serialization)
Diffstat (limited to 'core/src/Model/Items.cpp')
-rw-r--r--core/src/Model/Items.cpp88
1 files changed, 40 insertions, 48 deletions
diff --git a/core/src/Model/Items.cpp b/core/src/Model/Items.cpp
index db2d39f..7679eb9 100644
--- a/core/src/Model/Items.cpp
+++ b/core/src/Model/Items.cpp
@@ -1,37 +1,5 @@
#include "Items.hpp"
-#include <limits>
-#include <utility>
-
-ItemBase::ItemBase()
- : mId{ std::numeric_limits<size_t>::max() } {
-}
-
-ItemBase::ItemBase(size_t id)
- : mId{ id } {
-}
-
-bool ItemBase::IsInvalid() const {
- return mId == std::numeric_limits<size_t>::max();
-}
-
-size_t ItemBase::GetId() const {
- return mId;
-}
-
-ProductItem::ProductItem(size_t id, std::string name)
- : ItemBase(id)
- , mName{ std::move(name) } {
-}
-
-const std::string& ProductItem::GetName() const {
- return mName;
-}
-
-void ProductItem::SetName(std::string name) {
- mName = std::move(name);
-}
-
const std::string& ProductItem::GetDescription() const {
return mDescription;
}
@@ -40,17 +8,14 @@ void ProductItem::SetDescription(std::string description) {
mDescription = std::move(description);
}
-FactoryItem::FactoryItem(size_t id, std::string name)
- : ItemBase(id)
- , mName{ std::move(name) } {
-}
-
-const std::string& FactoryItem::GetName() const {
- return mName;
+Json::Value ProductItem::Serialize() const {
+ Json::Value elm;
+ elm["Description"] = mDescription;
+ return elm;
}
-void FactoryItem::SetName(std::string name) {
- mName = std::move(name);
+void ProductItem::Deserialize(const Json::Value& elm) {
+ mDescription = elm["Description"].asString();
}
const std::string& FactoryItem::GetDescription() const {
@@ -61,17 +26,24 @@ void FactoryItem::SetDescription(std::string description) {
mDescription = std::move(description);
}
-CustomerItem::CustomerItem(size_t id, std::string name)
- : ItemBase(id)
- , mName{ std::move(name) } {
+const std::string& FactoryItem::GetEmail() const {
+ return mEmail;
}
-const std::string& CustomerItem::GetName() const {
- return mName;
+void FactoryItem::SetEmail(std::string email) {
+ mEmail = std::move(email);
}
-void CustomerItem::SetName(std::string name) {
- mName = std::move(name);
+Json::Value FactoryItem::Serialize() const {
+ Json::Value elm;
+ elm["Description"] = mDescription;
+ elm["Email"] = mEmail;
+ return elm;
+}
+
+void FactoryItem::Deserialize(const Json::Value& elm) {
+ mDescription = elm["Description"].asString();
+ mEmail = elm["Email"].asString();
}
const std::string& CustomerItem::GetDescription() const {
@@ -81,3 +53,23 @@ const std::string& CustomerItem::GetDescription() const {
void CustomerItem::SetDescription(std::string description) {
mDescription = std::move(description);
}
+
+const std::string& CustomerItem::GetEmail() const {
+ return mEmail;
+}
+
+void CustomerItem::SetEmail(std::string email) {
+ mEmail = std::move(email);
+}
+
+Json::Value CustomerItem::Serialize() const {
+ Json::Value elm;
+ elm["Description"] = mDescription;
+ elm["Email"] = mEmail;
+ return elm;
+}
+
+void CustomerItem::Deserialize(const Json::Value& elm) {
+ mDescription = elm["Description"].asString();
+ mEmail = elm["Email"].asString();
+}