SerializableJSONStateConnection.hpp 1.1 KB

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