SerializableJSONStateConnection.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-14
  6. * Changed: 2020-11-26
  7. *
  8. * */
  9. #ifndef LS_STD_SERIALIZABLE_JSON_STATE_CONNECTION_HPP
  10. #define LS_STD_SERIALIZABLE_JSON_STATE_CONNECTION_HPP
  11. #include <memory>
  12. #include <ls_std/lib/nlohmann_json/include/nlohmann/json.hpp>
  13. #include <ls_std/base/Class.hpp>
  14. #include <ls_std/serialization/ISerializable.hpp>
  15. #include <ls_std/logic/StateConnection.hpp>
  16. namespace ls_std {
  17. class SerializableJSONStateConnection : public Class, public ISerializable {
  18. public:
  19. explicit SerializableJSONStateConnection(const std::shared_ptr<ls_std::StateConnection>& _value);
  20. ~SerializableJSONStateConnection() override = default;
  21. // implementation
  22. ls_std::byte_field marshal() override;
  23. void unmarshal(const ls_std::byte_field& _data) override;
  24. // additional functionality
  25. std::shared_ptr<ls_std::StateConnection> getValue();
  26. void setValue(const std::shared_ptr<ls_std::StateConnection>& _value);
  27. private:
  28. nlohmann::json jsonObject {};
  29. std::shared_ptr<ls_std::StateConnection> value {};
  30. void _assignValue(const std::shared_ptr<ls_std::StateConnection>& _value);
  31. void _clear();
  32. void _update();
  33. };
  34. }
  35. #endif