Browse Source

Remove unfinished serialization classes

Patrick 3 years ago
parent
commit
d41590e964

+ 0 - 6
CMakeLists.txt

@@ -109,10 +109,6 @@ set(SOURCE_FILES
         ${CMAKE_CURRENT_SOURCE_DIR}/source/serialization/json/logic/SerializableJSONState.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/serialization/json/logic/SerializableJSONStateMachine.hpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/serialization/json/logic/SerializableJSONStateMachine.cpp
-        ${CMAKE_CURRENT_SOURCE_DIR}/source/serialization/xml/logic/SerializableXMLStateConnection.hpp
-        ${CMAKE_CURRENT_SOURCE_DIR}/source/serialization/xml/logic/SerializableXMLStateConnection.cpp
-        ${CMAKE_CURRENT_SOURCE_DIR}/source/serialization/xml/logic/SerializableXMLState.hpp
-        ${CMAKE_CURRENT_SOURCE_DIR}/source/serialization/xml/logic/SerializableXMLState.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/io/xml/XMLAttribute.hpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/io/xml/XMLAttribute.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/source/io/xml/XMLNode.hpp
@@ -163,8 +159,6 @@ set(TEST_FILES
         ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/logic/SerializableJSONStateMachineTest.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/test/TestDataFactory.hpp
         ${CMAKE_CURRENT_SOURCE_DIR}/test/TestDataFactory.cpp
-        ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/xml/logic/SerializableXMLStateConnectionTest.cpp
-        ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/xml/logic/SerializableXMLStateTest.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XMLAttributeTest.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XMLNodeTest.cpp
         ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/base/VersionTest.cpp

+ 0 - 113
source/serialization/xml/logic/SerializableXMLState.cpp

@@ -1,113 +0,0 @@
-/*
- * Author:          Patrick-Christopher Mattulat
- * Company:         Lynar Studios
- * E-Mail:          webmaster@lynarstudios.com
- * Created:         2020-09-20
- * Changed:         2020-09-20
- *
- * *//*
-
-
-#include "SerializableXMLState.hpp"
-#include "../../../boxing/String.hpp"
-#include "SerializableXMLStateConnection.hpp"
-
-ls_std::SerializableXMLState::SerializableXMLState(std::shared_ptr<ls_std::State> _value) :
-Class("SerializableXMLState"),
-value(std::move(_value))
-{}
-
-ls_std::byte_field ls_std::SerializableXMLState::marshal()
-{
-  this->_update();
-  tinyxml2::XMLPrinter printer {};
-  this->document.Print(&printer);
-
-  return printer.CStr();
-}
-
-void ls_std::SerializableXMLState::unmarshal(const ls_std::byte_field &_data)
-{
-  ls_std::String data {_data};
-  this->document.Parse(data.getByteData().data());
-  tinyxml2::XMLElement* root = this->document.RootElement();
-
-  if(root != nullptr ) {
-    this->_unmarshalConnections(root);
-    this->_unmarshalId(root);
-  }
-}
-
-std::shared_ptr<ls_std::State> ls_std::SerializableXMLState::getValue()
-{
-  return this->value;
-}
-
-void ls_std::SerializableXMLState::setValue(std::shared_ptr<ls_std::State> _value)
-{
-  this->value = std::move(_value);
-  this->_clear();
-}
-
-void ls_std::SerializableXMLState::_clear()
-{
-  this->document.Clear();
-}
-
-void ls_std::SerializableXMLState::_unmarshalConnections(tinyxml2::XMLElement *_root)
-{
-  tinyxml2::XMLNode* connections = _root->FirstChildElement("connections");
-
-  if(connections != nullptr) {
-    tinyxml2::XMLNode* connection = connections->FirstChildElement("connection");
-    tinyxml2::XMLPrinter printer{};
-    this->value->clearConnections();
-
-    do {
-     if (connection != nullptr) {
-       connection->Accept(&printer);
-       ls_std::SerializableXMLStateConnection serializable{std::make_shared<ls_std::StateConnection>("", "")};
-       serializable.unmarshal(printer.CStr());
-       this->value->addStateConnection(serializable.getValue());
-       connection = connection->NextSibling();
-       printer.ClearBuffer();
-     }
-    }
-    while(connection != nullptr);
-  }
-}
-
-void ls_std::SerializableXMLState::_unmarshalId(tinyxml2::XMLElement* _root)
-{
-  const tinyxml2::XMLAttribute *attribute = _root->FindAttribute("id");
-
-  if(attribute != nullptr) {
-    this->value->setId(attribute->Value());
-  }
-}
-
-void ls_std::SerializableXMLState::_update()
-{
-  this->_clear();
-  tinyxml2::XMLNode* root = this->document.NewElement("state");
-  this->document.InsertFirstChild(root);
-  root->ToElement()->SetAttribute("id", this->value->getId().c_str());
-  this->_updateStates();
-}
-
-void ls_std::SerializableXMLState::_updateStates()
-{
-  tinyxml2::XMLNode* connectionsNode = this->document.NewElement("connections");
-  tinyxml2::XMLElement* stateNode = this->document.FirstChildElement("state");
-
-  for(const auto& connection : this->value->getConnectedStates()) {
-    ls_std::byte_field data = ls_std::SerializableXMLStateConnection {connection.second}.marshal();
-    tinyxml2::XMLDocument connectionNodeDocument {};
-    connectionNodeDocument.Parse(data.c_str());
-    tinyxml2::XMLNode* connectionNode = connectionNodeDocument.RootElement();
-    connectionsNode->InsertFirstChild(connectionNode);
-  }
-
-  stateNode->InsertEndChild(connectionsNode);
-}
-*/

+ 0 - 51
source/serialization/xml/logic/SerializableXMLState.hpp

@@ -1,51 +0,0 @@
-/*
- * Author:          Patrick-Christopher Mattulat
- * Company:         Lynar Studios
- * E-Mail:          webmaster@lynarstudios.com
- * Created:         2020-09-20
- * Changed:         2020-09-20
- *
- * *//*
-
-
-#ifndef LS_STD_SERIALIZABLE_XML_STATE_HPP
-#define LS_STD_SERIALIZABLE_XML_STATE_HPP
-
-#include "../../../base/Class.hpp"
-#include "../../ISerializable.hpp"
-#include "../../../logic/State.hpp"
-#include <memory>
-#include <tinyxml2.h>
-
-namespace ls_std {
-  class SerializableXMLState : public Class, public ISerializable {
-    public:
-
-      explicit SerializableXMLState(std::shared_ptr<State> _value);
-      ~SerializableXMLState() = default;
-
-      // implementation
-
-      ls_std::byte_field marshal() override;
-      void unmarshal(const ls_std::byte_field& _data) override;
-
-      // additional functionality
-
-      std::shared_ptr<State> getValue();
-      void setValue(std::shared_ptr<State> _value);
-
-    private:
-
-      tinyxml2::XMLDocument document {};
-      std::shared_ptr<State> value {};
-
-      void _clear();
-      void _unmarshalConnections(tinyxml2::XMLElement* _root);
-      void _unmarshalId(tinyxml2::XMLElement* _root);
-      void _update();
-      void _updateStates();
-  };
-}
-
-#endif
-*/

+ 0 - 92
source/serialization/xml/logic/SerializableXMLStateConnection.cpp

@@ -1,92 +0,0 @@
-/*
- * Author:          Patrick-Christopher Mattulat
- * Company:         Lynar Studios
- * E-Mail:          webmaster@lynarstudios.com
- * Created:         2020-09-20
- * Changed:         2020-09-20
- *
- * *//*
-
-
-#include "SerializableXMLStateConnection.hpp"
-#include "../../../boxing/String.hpp"
-#include "../../../boxing/Boolean.hpp"
-
-ls_std::SerializableXMLStateConnection::SerializableXMLStateConnection(std::shared_ptr<StateConnection> _value) :
-Class("SerializableXMLStateConnection"),
-value(std::move(_value))
-{}
-
-ls_std::byte_field ls_std::SerializableXMLStateConnection::marshal()
-{
-  this->_update();
-  tinyxml2::XMLPrinter printer {};
-  this->document.Print(&printer);
-  return ls_std::byte_field(printer.CStr());
-}
-
-void ls_std::SerializableXMLStateConnection::unmarshal(const ls_std::byte_field &_data)
-{
-  ls_std::String data {_data};
-  this->document.Parse(data.getByteData().data());
-  this->_unmarshalConnectionId();
-  this->_unmarshalCondition();
-  this->_unmarshalId();
-}
-
-std::shared_ptr<ls_std::StateConnection> ls_std::SerializableXMLStateConnection::getValue()
-{
-  return this->value;
-}
-
-void ls_std::SerializableXMLStateConnection::setValue(std::shared_ptr<StateConnection> _value)
-{
-  this->value = std::move(_value);
-  this->_clear();
-}
-
-void ls_std::SerializableXMLStateConnection::_clear()
-{
-  this->document.Clear();
-}
-
-void ls_std::SerializableXMLStateConnection::_unmarshalCondition()
-{
-  ls_std::Boolean condition {};
-  const tinyxml2::XMLAttribute *attribute = this->document.RootElement()->FindAttribute("condition");
-
-  if(attribute != nullptr) {
-    condition.parse(attribute->Value());
-    this->value->updatePassCondition(condition.getValue());
-  }
-}
-
-void ls_std::SerializableXMLStateConnection::_unmarshalConnectionId()
-{
-  const tinyxml2::XMLAttribute *attribute = this->document.RootElement()->FindAttribute("connectionId");
-
-  if(attribute != nullptr) {
-    this->value->setConnectionId(attribute->Value());
-  }
-}
-
-void ls_std::SerializableXMLStateConnection::_unmarshalId()
-{
-  const tinyxml2::XMLAttribute *attribute = this->document.RootElement()->FindAttribute("id");
-
-  if(attribute != nullptr) {
-    this->value->setStateId(attribute->Value());
-  }
-}
-
-void ls_std::SerializableXMLStateConnection::_update()
-{
-  this->_clear();
-  tinyxml2::XMLNode* root = this->document.NewElement("connection");
-  this->document.InsertFirstChild(root);
-
-  root->ToElement()->SetAttribute("connectionId", this->value->getConnectionId().c_str());
-  root->ToElement()->SetAttribute("id", this->value->getStateId().c_str());
-  root->ToElement()->SetAttribute("condition", this->value->isPassable());
-}
-*/

+ 0 - 51
source/serialization/xml/logic/SerializableXMLStateConnection.hpp

@@ -1,51 +0,0 @@
-/*
- * Author:          Patrick-Christopher Mattulat
- * Company:         Lynar Studios
- * E-Mail:          webmaster@lynarstudios.com
- * Created:         2020-09-20
- * Changed:         2020-09-20
- *
- * *//*
-
-
-#ifndef LS_STD_SERIALIZABLE_XML_STATE_CONNECTION_HPP
-#define LS_STD_SERIALIZABLE_XML_STATE_CONNECTION_HPP
-
-#include "../../../base/Class.hpp"
-#include "../../ISerializable.hpp"
-#include "../../../logic/StateConnection.hpp"
-#include <memory>
-#include <tinyxml2.h>
-
-namespace ls_std {
-  class SerializableXMLStateConnection : public Class, public ISerializable {
-    public:
-
-      explicit SerializableXMLStateConnection(std::shared_ptr<StateConnection> _value);
-      ~SerializableXMLStateConnection() = default;
-
-      // implementation
-
-      ls_std::byte_field marshal() override;
-      void unmarshal(const ls_std::byte_field& _data) override;
-
-      // additional functionality
-
-      std::shared_ptr<StateConnection> getValue();
-      void setValue(std::shared_ptr<StateConnection> _value);
-
-    private:
-
-      tinyxml2::XMLDocument document {};
-      std::shared_ptr<StateConnection> value {};
-
-      void _clear();
-      void _unmarshalCondition();
-      void _unmarshalConnectionId();
-      void _unmarshalId();
-      void _update();
-  };
-}
-
-#endif
-*/

+ 0 - 74
test/cases/serialization/xml/logic/SerializableXMLStateConnectionTest.cpp

@@ -1,74 +0,0 @@
-/*
- * Author:          Patrick-Christopher Mattulat
- * Company:         Lynar Studios
- * E-Mail:          webmaster@lynarstudios.com
- * Created:         2020-09-20
- * Changed:         2020-09-20
- *
- * *//*
-
-
-#include <gtest/gtest.h>
-#include "../../../../../source/serialization/xml/logic/SerializableXMLStateConnection.hpp"
-#include "../../../../../source/boxing/String.hpp"
-
-namespace {
-  class SerializableXMLStateConnectionTest : public ::testing::Test {
-    protected:
-
-      SerializableXMLStateConnectionTest() = default;
-      ~SerializableXMLStateConnectionTest() override = default;
-
-      void SetUp() override {}
-      void TearDown() override {}
-  };
-
-  TEST_F(SerializableXMLStateConnectionTest, marshal)
-  {
-    ls_std::SerializableXMLStateConnection serializable {std::make_shared<ls_std::StateConnection>("AB", "B")};
-    ls_std::String data {serializable.marshal()};
-
-    ASSERT_TRUE(!data.toString().empty());
-    ls_std::String expected {R"(<connection connectionId="AB" id="B" condition="false"/>)"};
-    ASSERT_TRUE(data.contains(expected));
-  }
-
-  TEST_F(SerializableXMLStateConnectionTest, unmarshal)
-  {
-    ls_std::SerializableXMLStateConnection serializable {std::make_shared<ls_std::StateConnection>("AB", "B")};
-    std::string xmlString = R"(<connection connectionId="DE" id="E" condition="true"></connection>)";
-
-    serializable.unmarshal(xmlString);
-    ASSERT_STREQ("DE", serializable.getValue()->getConnectionId().c_str());
-    ASSERT_STREQ("E", serializable.getValue()->getStateId().c_str());
-    ASSERT_TRUE(serializable.getValue()->isPassable());
-  }
-
-  // additional functionality
-
-  TEST_F(SerializableXMLStateConnectionTest, getValue)
-  {
-    std::shared_ptr<ls_std::StateConnection> x = std::make_shared<ls_std::StateConnection>("AB", "B");
-    ls_std::SerializableXMLStateConnection serializable {x};
-
-    ASSERT_STREQ("AB", serializable.getValue()->getConnectionId().c_str());
-    ASSERT_STREQ("B", serializable.getValue()->getStateId().c_str());
-    ASSERT_FALSE(serializable.getValue()->isPassable());
-  }
-
-  TEST_F(SerializableXMLStateConnectionTest, setValue)
-  {
-    ls_std::SerializableXMLStateConnection serializable {std::make_shared<ls_std::StateConnection>("AB", "B")};
-
-    ASSERT_STREQ("AB", serializable.getValue()->getConnectionId().c_str());
-    ASSERT_STREQ("B", serializable.getValue()->getStateId().c_str());
-    ASSERT_FALSE(serializable.getValue()->isPassable());
-
-    serializable.setValue(std::make_shared<ls_std::StateConnection>("BC", "C"));
-
-    ASSERT_STREQ("BC", serializable.getValue()->getConnectionId().c_str());
-    ASSERT_STREQ("C", serializable.getValue()->getStateId().c_str());
-    ASSERT_FALSE(serializable.getValue()->isPassable());
-  }
-}
-*/

+ 0 - 85
test/cases/serialization/xml/logic/SerializableXMLStateTest.cpp

@@ -1,85 +0,0 @@
-/*
- * Author:          Patrick-Christopher Mattulat
- * Company:         Lynar Studios
- * E-Mail:          webmaster@lynarstudios.com
- * Created:         2020-09-20
- * Changed:         2020-09-20
- *
- * *//*
-
-
-#include <gtest/gtest.h>
-#include "../../../../../source/serialization/xml/logic/SerializableXMLState.hpp"
-#include "../../../../../source/boxing/String.hpp"
-
-namespace {
-  class SerializableXMLStateTest : public ::testing::Test {
-    protected:
-
-      SerializableXMLStateTest() = default;
-      ~SerializableXMLStateTest() override = default;
-
-      void SetUp() override {}
-      void TearDown() override {}
-  };
-
-  // implementation
-
-  TEST_F(SerializableXMLStateTest, marshal)
-  {
-    std::shared_ptr<ls_std::State> stateA = std::make_shared<ls_std::State>("A");
-    stateA->addStateConnection(std::make_shared<ls_std::StateConnection>("AB", "B"));
-    stateA->addStateConnection(std::make_shared<ls_std::StateConnection>("AC", "C"));
-    ls_std::SerializableXMLState serializable {stateA};
-
-    std::string data = serializable.marshal();
-    ASSERT_TRUE(!data.empty());
-  }
-
-  TEST_F(SerializableXMLStateTest, unmarshal)
-  {
-    ls_std::SerializableXMLState serializable {std::make_shared<ls_std::State>("A")};
-    std::string xmlText = R"(
-      <state id="B">
-        <connections>
-          <connection connectionId="BC" id="C" condition="true"/>
-          <connection connectionId="BD" id="D" condition="true"/>
-        </connections>
-      </state>)";
-
-    serializable.unmarshal(xmlText);
-    ASSERT_STREQ("B", serializable.getValue()->getId().c_str());
-    auto connections = serializable.getValue()->getConnectedStates();
-
-    ASSERT_EQ(2, connections.size());
-    ASSERT_TRUE(connections.at("BC") != nullptr);
-    ASSERT_TRUE(connections.at("BC")->isPassable());
-    ASSERT_STREQ("BC", connections.at("BC")->getConnectionId().c_str());
-    ASSERT_STREQ("C", connections.at("BC")->getStateId().c_str());
-
-    ASSERT_TRUE(connections.at("BD") != nullptr);
-    ASSERT_TRUE(connections.at("BD")->isPassable());
-    ASSERT_STREQ("BD", connections.at("BD")->getConnectionId().c_str());
-    ASSERT_STREQ("D", connections.at("BD")->getStateId().c_str());
-  }
-
-  // additional functionality
-
-  TEST_F(SerializableXMLStateTest, getValue)
-  {
-    std::shared_ptr<ls_std::State> x = std::make_shared<ls_std::State>("A");
-    ls_std::SerializableXMLState serializable {x};
-
-    ASSERT_STREQ("A", serializable.getValue()->getId().c_str());
-  }
-
-  TEST_F(SerializableXMLStateTest, setValue)
-  {
-    ls_std::SerializableXMLState serializable {std::make_shared<ls_std::State>("A")};
-    ASSERT_STREQ("A", serializable.getValue()->getId().c_str());
-
-    serializable.setValue(std::make_shared<ls_std::State>("C"));
-    ASSERT_STREQ("C", serializable.getValue()->getId().c_str());
-  }
-}
-*/