fpmas 1.6
Static Public Member Functions | List of all members
fpmas::io::datapack::LightSerializer< AgentPtr > Struct Reference

#include <model.h>

Static Public Member Functions

static std::size_t size (const LightObjectPack &pack, const AgentPtr &ptr)
 
static void to_datapack (LightObjectPack &pack, const AgentPtr &pointer)
 
static AgentPtr from_datapack (const LightObjectPack &pack)
 

Detailed Description

fpmas::api::model::AgentPtr fpmas::io::datapack::LightSerializer serialization rules declaration.

to_datapack and from_datapack methods must be defined by the user at compile time, depending on its own Agent types, using the FPMAS_DATAPACK_SET_UP() macro, that must be called from a source file. Otherwise, linker errors will be thrown.

Member Function Documentation

◆ size()

static std::size_t fpmas::io::datapack::LightSerializer< AgentPtr >::size ( const LightObjectPack pack,
const AgentPtr ptr 
)
static

◆ to_datapack()

static void fpmas::io::datapack::LightSerializer< AgentPtr >::to_datapack ( LightObjectPack pack,
const AgentPtr pointer 
)
static

Serializes the Agent represented by pointer to the specified LightObjectPack.

The LightObjectPack version of the to_datapack() method attempts to serialize the agent with the less data possible, i.e. possibly nothing if the Agent is default constructible, and no user defined LightObjectPack serialization rules have been provided.

If Agent is not default constructible, the classic io::datapack::Serializer<PtrWrapper<AgentType>> is used, what might be inefficient.

See also
LightSerializer<PtrWrapper<AgentType>>::to_datapack() (default constructible AgentType)
LightSerializer<PtrWrapper<AgentType>>::to_datapack() (not default constructible AgentType)
Parameters
packdestination LightObjectPack
pointerpointer to polymorphic Agent

◆ from_datapack()

static AgentPtr fpmas::io::datapack::LightSerializer< AgentPtr >::from_datapack ( const LightObjectPack pack)
static

Unserializes an Agent from the specified LightObjectPack.

The built Agent is dynamically allocated, but is automatically managed by the fpmas::api::model::AgentPtr wrapper.

Since Agent is polymorphic, the concrete type that should be instantiated from the input LightObjectPack is determined at runtime.

The LightObjectPack version of the from_datapack() method attempts to build the Agent using a default constructor, to bypass the classical ObjectPack serialization process.

If Agent is not default constructible, the classic io::datapack::Serializer<PtrWrapper<AgentType>> is used, what might be inefficient.

See also
light_serializer<PtrWrapper<AgentType>>::from_datapack() (default constructible AgentType)
light_serializer<PtrWrapper<AgentType>>::from_datapack() (not default constructible AgentType)
Parameters
packsource LightObjectPack
Returns
dynamically allocated Agent, unserialized from o, wrapped in an fpmas::api::model::AgentPtr instance

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