fpmas 1.5
Public Types | Static Public Member Functions | List of all members
fpmas::io::datapack::Serializer< PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > > Struct Template Reference

#include <spatial_model.h>

Public Types

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

Static Public Member Functions

static std::size_t size (const ObjectPack &p, const Ptr &ptr)
 
static void to_datapack (ObjectPack &pack, const Ptr &ptr)
 
static Ptr from_datapack (const ObjectPack &pack)
 

Detailed Description

template<typename SpatialAgentInterface, typename AgentType, typename CellType, typename Derived>
struct fpmas::io::datapack::Serializer< PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > >

Polymorphic SpatialAgentBase ObjectPack serializer specialization.

Serialization Scheme
Derived ObjectPack serialization SpatialAgentBase::locationId()

The Derived part is serialized using the Serializer<PtrWrapper<Derived>> serialization, that can be defined externally without additional constraint. The input GridAgent pointer is cast to Derived when required to call the proper Serializer specialization.

Template Parameters
AgentTypefinal fpmas::api::model::SpatialAgent type to serialize
CellTypetype of cells used by the spatial model
Derivednext derived class in the polymorphic serialization chain

Member Typedef Documentation

◆ Ptr

template<typename SpatialAgentInterface , typename AgentType , typename CellType , typename Derived >
typedef PtrWrapper<fpmas::model::SpatialAgentBase<SpatialAgentInterface, AgentType, CellType, Derived> > fpmas::io::datapack::Serializer< PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > >::Ptr

Pointer wrapper to a polymorphic SpatialAgentBase.

Member Function Documentation

◆ size()

template<typename SpatialAgentInterface , typename AgentType , typename CellType , typename Derived >
static std::size_t fpmas::io::datapack::Serializer< PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > >::size ( const ObjectPack p,
const Ptr ptr 
)
inlinestatic

Returns the buffer size required to serialize the polymorphic SpatialAgentBase pointed by ptr to p.

◆ to_datapack()

template<typename SpatialAgentInterface , typename AgentType , typename CellType , typename Derived >
static void fpmas::io::datapack::Serializer< PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > >::to_datapack ( ObjectPack pack,
const Ptr ptr 
)
inlinestatic

Serializes the pointer to the polymorphic SpatialAgentBase into the specified ObjectPack.

Parameters
packdestination ObjectPack
ptrpointer to a polymorphic SpatialAgentBase to serialize

◆ from_datapack()

template<typename SpatialAgentInterface , typename AgentType , typename CellType , typename Derived >
static Ptr fpmas::io::datapack::Serializer< PtrWrapper< fpmas::model::SpatialAgentBase< SpatialAgentInterface, AgentType, CellType, Derived > > >::from_datapack ( const ObjectPack pack)
inlinestatic

Unserializes a polymorphic SpatialAgentBase from the specified ObjectPack.

First, the Derived part, that extends SpatialAgentBase by definition, is unserialized using the Serializer<fpmas::api::utils::PtrWrapper<Derived> specialization. During this operation, a Derived instance is dynamically allocated, that might leave the SpatialAgentBase members undefined. The specific SpatialAgentBase member location_id is then unserialized, and the unserialized Derived instance is returned in the form of a polymorphic SpatialAgentBase pointer.

Parameters
packsource ObjectPack
Returns
unserialized pointer to a polymorphic SpatialAgentBase

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