fpmas 1.5
Public Types | Static Public Member Functions | List of all members
nlohmann::adl_serializer< fpmas::api::utils::PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > > Struct Template Reference

#include <spatial_model.h>

Public Types

typedef fpmas::api::utils::PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > Ptr
 

Static Public Member Functions

static void to_json (nlohmann::json &j, const Ptr &ptr)
 
static Ptr from_json (const nlohmann::json &j)
 

Detailed Description

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.

Member Typedef Documentation

◆ Ptr

template<typename SpatialAgentInterface , typename AgentType , typename CellType , typename Derived >
typedef fpmas::api::utils::PtrWrapper<fpmas::model::SpatialAgentBase<SpatialAgentInterface, AgentType, CellType, Derived> > nlohmann::adl_serializer< fpmas::api::utils::PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > >::Ptr

Pointer wrapper to a polymorphic SpatialAgentBase.

Member Function Documentation

◆ to_json()

template<typename SpatialAgentInterface , typename AgentType , typename CellType , typename Derived >
static void nlohmann::adl_serializer< fpmas::api::utils::PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > >::to_json ( nlohmann::json &  j,
const Ptr ptr 
)
inlinestatic

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
jjson output
ptrpointer to a polymorphic SpatialAgentBase to serialize

◆ from_json()

template<typename SpatialAgentInterface , typename AgentType , typename CellType , typename Derived >
static Ptr nlohmann::adl_serializer< fpmas::api::utils::PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > >::from_json ( const nlohmann::json &  j)
inlinestatic

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
jjson input
Returns
unserialized pointer to a polymorphic SpatialAgentBase

The documentation for this struct was generated from the following file: