2#include <score/model/EntityBase.hpp>
4#include <score/serialization/JSONVisitor.hpp>
26#if defined(SCORE_SERIALIZABLE_COMPONENTS)
28 score::DataStreamComponents vec;
29 for(
auto& comp : obj.components())
31 if(
auto c =
dynamic_cast<score::SerializableComponent*
>(&comp))
33 vec[c->concreteKey()] = s.marshall(*c);
39 SCORE_DEBUG_INSERT_DELIMITER2(s);
44 s.writeTo(obj.metadata());
45#if defined(SCORE_SERIALIZABLE_COMPONENTS)
48 score::DataStreamComponents vec;
54 auto comp =
new score::DataStreamSerializedComponents{
56 obj.components().add(comp);
59 SCORE_DEBUG_CHECK_DELIMITER2(s);
69 s.obj[s.strings.Metadata] = obj.metadata();
71#if defined(SCORE_SERIALIZABLE_COMPONENTS)
73 QJsonArray json_components;
74 for(
auto& comp : obj.components())
76 if(
auto c =
dynamic_cast<score::SerializableComponent*
>(&comp))
78 json_components.append(s.marshall(*c));
82 s.obj[s.strings.Components] = std::move(json_components);
90 writer.writeTo(obj.metadata());
93#if defined(SCORE_SERIALIZABLE_COMPONENTS)
94 const QJsonArray json_components = s.obj[s.strings.Components].toArray();
95 if(!json_components.empty())
97 score::JSONComponents vec;
98 for(
const auto& comp : json_components)
102 auto obj = comp.toObject();
105 = fromJsonValue<score::uuid_t>(obj[s.strings.uuid]);
106 vec.emplace(k, std::move(obj));
110 auto comp =
new score::JSONSerializedComponents{
112 obj.components().add(comp);
121 template <
typename T>
124 s.m_stream << (int32_t)vec.size();
129 template <
typename List,
typename OnSucces,
typename OnFailure>
132 const OnSucces& success,
const OnFailure& fail)
138 auto proc = deserialize_interface(lst, s, parent);
150 template <
typename T>
153 s.stream.StartArray();
154 for(
const auto* elt : vec)
159 template <
typename List,
typename OnSucces,
typename OnFailure>
162 const OnSucces& success,
const OnFailure& fail)
164 for(
const auto& json_vref : s.base.GetArray())
180template <
typename T,
typename Alloc>
184template <
typename T,
typename Alloc>
189template <
typename T, std::
size_t N>
194template <
typename T, std::
size_t N>
Definition VisitorInterface.hpp:53
Definition DataStreamVisitor.hpp:27
void readFrom(const score::Entity< T > &obj)
Called by code that wants to serialize.
Definition DataStreamVisitor.hpp:53
Definition DataStreamVisitor.hpp:202
The IdentifiedObject class.
Definition IdentifiedObject.hpp:19
Definition VisitorInterface.hpp:61
Definition JSONVisitor.hpp:52
void readFrom(const score::Entity< T > &obj)
Definition EntitySerialization.hpp:7
Definition JSONVisitor.hpp:423
Definition UuidKey.hpp:343
The id_base_t class.
Definition Identifier.hpp:57
Base for complex model objects.
Definition EntityBase.hpp:24
Base toolkit upon which the software is built.
Definition Application.cpp:90
Definition EntitySerialization.hpp:119
static void readFrom(DataStream::Serializer &s, const T &vec)
Arrays of pointed-to objects.
Definition EntitySerialization.hpp:122
Definition VisitorInterface.hpp:13