SerializableJSONState.hpp 1.1 KB

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