fpmas 1.5
Static Public Member Functions | List of all members
fpmas::io::json::light_serializer< fpmas::api::utils::PtrWrapper< AgentType >, typename std::enable_if< std::is_base_of< fpmas::api::model::Agent, AgentType >::value &&!std::is_default_constructible< AgentType >::value &&std::is_same< AgentType, typename AgentType::FinalAgentType >::value >::type > Struct Template Reference

#include <json_serializer.h>

Static Public Member Functions

static void to_json (light_json &j, const fpmas::api::utils::PtrWrapper< AgentType > &agent)
 
static fpmas::api::utils::PtrWrapper< AgentType > from_json (const light_json &j)
 

Detailed Description

template<typename AgentType>
struct fpmas::io::json::light_serializer< fpmas::api::utils::PtrWrapper< AgentType >, typename std::enable_if< std::is_base_of< fpmas::api::model::Agent, AgentType >::value &&!std::is_default_constructible< AgentType >::value &&std::is_same< AgentType, typename AgentType::FinalAgentType >::value >::type >

A default light_serializer specialization for Agent types, when no default constructor is available. In this case, to_json() and from_json() methods falls back to the classic nlohmann::json serialization rules, what might be inefficient. A warning is also printed at runtime.

To avoid this inefficient behaviors, two things can be performed:

Template Parameters
AgentTypeconcrete type of Agent to serialize

Member Function Documentation

◆ to_json()

template<typename AgentType >
static void fpmas::io::json::light_serializer< fpmas::api::utils::PtrWrapper< AgentType >, typename std::enable_if< std::is_base_of< fpmas::api::model::Agent, AgentType >::value &&!std::is_default_constructible< AgentType >::value &&std::is_same< AgentType, typename AgentType::FinalAgentType >::value >::type >::to_json ( light_json j,
const fpmas::api::utils::PtrWrapper< AgentType > &  agent 
)
inlinestatic

Calls nlohmann::adl_serializer<fpmas::api::utils::PtrWrapper<AgentType>>::to_json().

Parameters
jjson output
agentagent to serialize

◆ from_json()

template<typename AgentType >
static fpmas::api::utils::PtrWrapper< AgentType > fpmas::io::json::light_serializer< fpmas::api::utils::PtrWrapper< AgentType >, typename std::enable_if< std::is_base_of< fpmas::api::model::Agent, AgentType >::value &&!std::is_default_constructible< AgentType >::value &&std::is_same< AgentType, typename AgentType::FinalAgentType >::value >::type >::from_json ( const light_json j)
inlinestatic

Calls nlohmann::adl_serializer<fpmas::api::utils::PtrWrapper<AgentType>>::from_json().

Parameters
jjson input
Returns
dynamically allocated AgentType

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