template<typename SpatialAgentInterface, typename AgentType, typename CellType, typename Derived>
struct nlohmann::adl_serializer< fpmas::api::utils::PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > >
Polymorphic SpatialAgentBase nlohmann json serializer specialization.
template<typename SpatialAgentInterface , typename AgentType , typename CellType , typename Derived >
Serializes the pointer to the polymorphic SpatialAgentBase using the following JSON schema:
[<Derived json serialization>, ptr->locationId()]
The <Derived json serialization> is computed using the adl_serializer<fpmas::api::utils::PtrWrapper<Derived>> specialization, that can be defined externally without additional constraint.
- Parameters
-
| j | json output |
| ptr | pointer to a polymorphic SpatialAgentBase to serialize |
template<typename SpatialAgentInterface , typename AgentType , typename CellType , typename Derived >
Unserializes a polymorphic SpatialAgentBase from the specified Json.
First, the Derived part, that extends SpatialAgentBase by definition, is unserialized from j[0] using the adl_serializer<fpmas::api::utils::PtrWrapper<Derived> specialization, that can be defined externally without any constraint. During this operation, a Derived instance is dynamically allocated, that might leave the SpatialAgentBase members undefined. The specific SpatialAgentBase member location_id is then initialized from j[1], and the unserialized Derived instance is returned in the form of a polymorphic SpatialAgentBase pointer.
- Parameters
-
- Returns
- unserialized pointer to a polymorphic
SpatialAgentBase