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

#include <grid.h>

Public Types

typedef fpmas::api::utils::PtrWrapper< fpmas::model::GridAgent< 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 AgentType, typename CellType, typename Derived>
struct nlohmann::adl_serializer< fpmas::api::utils::PtrWrapper< fpmas::model::GridAgent< AgentType, CellType, Derived > > >

Polymorphic GridAgent nlohmann json serializer specialization.

Member Typedef Documentation

◆ Ptr

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

Pointer wrapper to a polymorphic GridAgent.

Member Function Documentation

◆ to_json()

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

Serializes the pointer to the polymorphic GridAgent using the following JSON schema:

[<Derived json serialization>, ptr->locationPoint(), ptr->rd()]

The <Derived json serialization> is computed using the adl_serializer<fpmas::api::utils::PtrWrapper<Derived>> specialization, that can be user defined without additional constraint.

Parameters
jjson output
ptrpointer to a polymorphic GridAgent to serialize

◆ from_json()

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

Unserializes a polymorphic GridAgent from the specified Json.

First, the Derived part, that extends GridAgent 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 GridAgent members undefined. The specific GridAgent member location_point is then initialized from j[1], the internal random number generator is unserialized from j[2], and the unserialized Derived instance is returned in the form of a polymorphic GridAgent pointer.

Parameters
jjson input
Returns
unserialized pointer to a polymorphic GridAgent

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