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

#include <graph.h>

Public Types

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

Polymorphic GraphCellBase nlohmann json serializer specialization.

Member Typedef Documentation

◆ Ptr

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

Pointer wrapper to a polymorphic SpatialAgentBase.

Member Function Documentation

◆ to_json()

template<typename AgentType , typename Derived >
static void nlohmann::adl_serializer< fpmas::api::utils::PtrWrapper< fpmas::model::GraphCellBase< AgentType, 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->reachableNodes()]

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 AgentType , typename Derived >
static Ptr nlohmann::adl_serializer< fpmas::api::utils::PtrWrapper< fpmas::model::GraphCellBase< AgentType, Derived > > >::from_json ( const nlohmann::json &  j)
inlinestatic

Unserializes a polymorphic GraphCellBase from the specified Json.

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

Parameters
jjson input
Returns
unserialized pointer to a polymorphic GraphCellBase

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