![]() |
fpmas 1.5
|
#include <model.h>
Static Public Member Functions | |
| static void | to_json (light_json &j, const fpmas::api::model::AgentPtr &pointer) |
| static fpmas::api::model::AgentPtr | from_json (const light_json &j) |
fpmas::api::model::AgentPtr fpmas::io::json::light_json serialization rules declaration.
to_json and from_json methods must be defined by the user at compile time, depending on its own Agent types, using the FPMAS_JSON_SET_UP() macro, that must be called from a source file. Otherwise, linker errors will be thrown.
|
static |
Serializes the Agent represented by pointer to the specified light_json j.
Notice that since Agent is polymorphic, the actual to_json call that corresponds to the most derived type of the specified Agent is resolved at runtime.
The light_json version of the to_json() method attempts to serialize the agent with the less data possible, i.e. possibly nothing if the Agent is default constructible, and no user defined light_json serialization rules have been provided.
If Agent is not default constructible, the classic nlohmann::adl_serializer<PtrWrapper<AgentType>> is used, what might be inefficient.
| j | json output |
| pointer | pointer to polymorphic Agent |
|
static |
Unserializes an Agent from the specified light_json j.
The built Agent is dynamically allocated, but is automatically managed by the fpmas::api::model::AgentPtr wrapper.
Since Agent is polymorphic, the concrete type that should be instantiated from the input light_json j is determined at runtime.
The light_json version of the from_json() method attempts to build the Agent using a default constructor, to bypass the classical json serialization process.
If Agent is not default constructible, the classic nlohmann::adl_serializer<PtrWrapper<AgentType>> is used, what might be inefficient.
| j | input json |
j, wrapped in an fpmas::api::model::AgentPtr instance