Browse Source

Extended SerializableJSONStateConnection class

- added setter method for value member
Patrick-Laptop 3 years ago
parent
commit
4c81672ed7

+ 8 - 1
source/serialization/json/logic/SerializableJSONStateConnection.cpp

@@ -3,12 +3,14 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-14
- * Changed:         2020-09-14
+ * Changed:         2020-09-15
  *
  * */
 
 #include "SerializableJSONStateConnection.hpp"
 
+#include <utility>
+
 ls_std::SerializableJSONStateConnection::SerializableJSONStateConnection(std::shared_ptr<ls_std::StateConnection> _value) :
 Class("SerializableJSONStateConnection"),
 value(std::move(_value))
@@ -30,6 +32,11 @@ void ls_std::SerializableJSONStateConnection::unmarshal(const ls_std::byte_field
   this->value->updatePassCondition(this->jsonObject["condition"]);
 }
 
+void ls_std::SerializableJSONStateConnection::setValue(std::shared_ptr<ls_std::StateConnection> _value)
+{
+  this->value = std::move(_value);
+}
+
 void ls_std::SerializableJSONStateConnection::_update()
 {
   this->jsonObject = {

+ 8 - 2
source/serialization/json/logic/SerializableJSONStateConnection.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-14
- * Changed:         2020-09-14
+ * Changed:         2020-09-15
  *
  * */
 
@@ -23,13 +23,19 @@ namespace ls_std {
       explicit SerializableJSONStateConnection(std::shared_ptr<ls_std::StateConnection> _value);
       ~SerializableJSONStateConnection() = default;
 
+      // implementation
+
       ls_std::byte_field marshal() override;
       void unmarshal(const ls_std::byte_field& _data) override;
 
+      // additional functionality
+
+      void setValue(std::shared_ptr<ls_std::StateConnection> _value);
+
     private:
 
-      std::shared_ptr<ls_std::StateConnection> value {};
       nlohmann::json jsonObject {};
+      std::shared_ptr<ls_std::StateConnection> value {};
 
       void _update();
   };

+ 3 - 1
test/cases/serialization/json/logic/SerializableJSONStateConnectionTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-14
- * Changed:         2020-09-14
+ * Changed:         2020-09-15
  *
  * */
 
@@ -23,6 +23,8 @@ namespace {
       void TearDown() override {}
   };
 
+  // implementation
+
   TEST_F(SerializableJSONStateConnectionTest, marshal)
   {
     ls_std::StateConnection x {"AB", "B"};