![]() |
fpmas 1.6
|
#include <json_serializer.h>
Static Public Member Functions | |
static void | to_json (JsonType &j, const WeakAgentPtr &ptr) |
static WeakAgentPtr | from_json (const JsonType &j) |
Generic AgentPtr serializer, that recursively deduces the final and concrete types of polymorphic AgentPtr instances.
JsonType | type of json used for serialization |
Type | type currently inspected |
AgentTypes | agent types not inspected yet (must end with void ) |
|
inlinestatic |
Recursive to_json method used to serialize polymorphic Agent pointers as JSON.
Type
corresponds to the currently examined Agent type. If this type id (i.e. Type::TYPE_ID) corresponds to the ptr
Agent type (i.e. ptr->typedId()
), the underlying agent is serialized using the specified JsonType.
Else, attempts to recursively serialize ptr
with to_json<AgentTypes...>(j, ptr)
. Notice that the last value of AgentTypes
must be void to reach the recursion base case (see to_json<void>).
j | json |
ptr | polymorphic agent pointer to serialize |
|
inlinestatic |
Recursive from_json method used to unserialize polymorphic Agent pointers from JSON.
Type
corresponds to the currently examined Agent type. If this type id (i.e. Type::TYPE_ID) corresponds to the JSON type id value (i.e. j.at("type").get<fpmas::api::model::TypeId>()), the JSON value is unserialized using the specified JsonType.
Else, attempts to recursively unserialize the JSON value with from_json<AgentTypes...>(j, ptr)
. Notice that the last value of AgentTypes
must be void to reach the recursion base case (see from_json<void>).
j | json |