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

#include <grid.h>

Public Types

typedef PtrWrapper< fpmas::model::GridCellBase< GridCellType, 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 GridCellType, typename Derived>
struct fpmas::io::datapack::Serializer< PtrWrapper< fpmas::model::GridCellBase< GridCellType, Derived > > >

Polymorphic GridCellBase ObjectPack serializer specialization.

| Serialization Scheme || |-------------------—|| | Derived ObjectPack serialization | GridCellBase::location() | GridCellBase::rd() |

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

Template Parameters
GridCellTypefinal fpmas::api::model::GridCell type to serialize
Derivednext derived class in the polymorphic serialization chain

Member Typedef Documentation

◆ Ptr

template<typename GridCellType , typename Derived >
typedef PtrWrapper<fpmas::model::GridCellBase<GridCellType, Derived> > fpmas::io::datapack::Serializer< PtrWrapper< fpmas::model::GridCellBase< GridCellType, Derived > > >::Ptr

Pointer wrapper to a polymorphic GridCellBase.

Member Function Documentation

◆ size()

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

Returns the buffer size required to serialize the GridCellBase pointed by ptr in p.

◆ to_datapack()

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

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

Parameters
packdestination ObjectPack
ptrpointer to a polymorphic GridAgent to serialize

◆ from_datapack()

template<typename GridCellType , typename Derived >
static Ptr fpmas::io::datapack::Serializer< PtrWrapper< fpmas::model::GridCellBase< GridCellType, Derived > > >::from_datapack ( const ObjectPack pack)
inlinestatic

Unserializes a polymorphic GridCellBase from the specified ObjectPack.

First, the Derived part, that extends GridCellBase by definition, is unserialized from the ObjectPack using the Serializer<fpmas::api::utils::PtrWrapper<Derived> specialization. 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 the second ObjectPack field, the internal random number generator from the third, and the unserialized Derived instance is returned in the form of a polymorphic GridCellBase pointer.

Parameters
packsource ObjectPack
Returns
unserialized pointer to a polymorphic GridCellBase

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