SerializableJSONEvent.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-12-07
  6. * Changed: 2020-12-20
  7. *
  8. * */
  9. #ifndef LS_STD_SERIALIZABLE_JSON_EVENT_HPP
  10. #define LS_STD_SERIALIZABLE_JSON_EVENT_HPP
  11. #include <ls_std/serialization/ISerializable.hpp>
  12. #include <ls_std/base/Class.hpp>
  13. #include <ls_std/event/Event.hpp>
  14. #include <memory>
  15. #include <ls_std/lib/nlohmann_json/include/nlohmann/json.hpp>
  16. namespace ls_std {
  17. class SerializableJSONEvent : public ls_std::Class, public ls_std::ISerializable {
  18. public:
  19. explicit SerializableJSONEvent(const std::shared_ptr<ls_std::Event>& _value);
  20. ~SerializableJSONEvent() 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::Event> getValue();
  26. void setValue(const std::shared_ptr<ls_std::Event>& _value);
  27. private:
  28. nlohmann::json jsonObject {};
  29. std::shared_ptr<ls_std::Event> value {};
  30. void _assignValue(const std::shared_ptr<ls_std::Event>& _value);
  31. void _unmarshalParameterList();
  32. void _update();
  33. void _updateEventParameterList();
  34. };
  35. }
  36. #endif