SerializableJSONStateConnection.hpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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-06
  7. *
  8. * */
  9. #ifndef LS_STD_SERIALIZABLE_JSON_STATE_CONNECTION_HPP
  10. #define LS_STD_SERIALIZABLE_JSON_STATE_CONNECTION_HPP
  11. #include "../../../../../include/ls_std/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 _clear();
  30. void _update();
  31. };
  32. }
  33. #endif