fpmas 1.5
Static Public Member Functions | List of all members
fpmas::io::datapack::LightSerializer< 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 <datapack_serializer.h>

Static Public Member Functions

static std::size_t size (const LightObjectPack &p, const fpmas::api::utils::PtrWrapper< AgentType > &agent)
 
static void to_datapack (LightObjectPack &pack, const fpmas::api::utils::PtrWrapper< AgentType > &agent)
 
static fpmas::api::utils::PtrWrapper< AgentType > from_datapack (const LightObjectPack &pack)
 

Detailed Description

template<typename AgentType>
struct fpmas::io::datapack::LightSerializer< 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 LightSerializer specialization for Agent types, when no default constructor is available. In this case, to_datapack() and from_datapack() methods falls back to the classic io::datapack::Serializer 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

◆ size()

template<typename AgentType >
static std::size_t fpmas::io::datapack::LightSerializer< 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 >::size ( const LightObjectPack p,
const fpmas::api::utils::PtrWrapper< AgentType > &  agent 
)
inlinestatic

Returns the buffer size required to serialize agent into p using the default Serializer.

◆ to_datapack()

template<typename AgentType >
static void fpmas::io::datapack::LightSerializer< 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_datapack ( LightObjectPack pack,
const fpmas::api::utils::PtrWrapper< AgentType > &  agent 
)
inlinestatic

Serializes agent in a classical ObjectPack, and write this pack to the destination LightObjectPack.

Parameters
packdestination LightObjectPack
agentagent to serialize

◆ from_datapack()

template<typename AgentType >
static fpmas::api::utils::PtrWrapper< AgentType > fpmas::io::datapack::LightSerializer< 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_datapack ( const LightObjectPack pack)
inlinestatic

Read a classical ObjectPack from the source LightObjectPack, and unserializes an Agent from this pack.

Parameters
packsource LightObjectPack
Returns
dynamically allocated AgentType

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