fpmas 1.6
Static Public Member Functions | List of all members
fpmas::io::datapack::AgentPtrSerializer< PackType, Type, AgentTypes > Struct Template Reference

#include <datapack_serializer.h>

Static Public Member Functions

static std::size_t size (const PackType &p, const WeakAgentPtr &ptr)
 
static void to_datapack (PackType &p, const WeakAgentPtr &ptr)
 
static WeakAgentPtr from_datapack (const PackType &p)
 

Detailed Description

template<typename PackType, typename Type, typename... AgentTypes>
struct fpmas::io::datapack::AgentPtrSerializer< PackType, Type, AgentTypes >

Generic AgentPtr serializer, that recursively deduces the final and concrete types of polymorphic AgentPtr instances.

Template Parameters
PackTypetype of ObjectPack used for serialization
Typetype currently inspected
AgentTypesagent types not inspected yet (must end with void)

Member Function Documentation

◆ size()

template<typename PackType , typename Type , typename... AgentTypes>
static std::size_t fpmas::io::datapack::AgentPtrSerializer< PackType, Type, AgentTypes >::size ( const PackType &  p,
const WeakAgentPtr &  ptr 
)
inlinestatic

Recursive size method used to compute the buffer size required to serialize the polymorphic Agent pointed by ptr into p.

◆ to_datapack()

template<typename PackType , typename Type , typename... AgentTypes>
static void fpmas::io::datapack::AgentPtrSerializer< PackType, Type, AgentTypes >::to_datapack ( PackType &  p,
const WeakAgentPtr &  ptr 
)
inlinestatic

Recursive to_datapack method used to serialize the polymorphic Agent pointed by ptr into p.

Type corresponds to the currently examined Agent type. If this type id (i.e. Type::TYPE_ID) corresponds to the ptr Agent type (i.e. ptr->typedId()), the underlying agent is serialized using the specified PackType.

Else, attempts to recursively serialize ptr with AgentPtrSerializer<AgentTypes...>::to_datapack(p, ptr). Notice that the last value of AgentTypes must be void to reach the recursion base case (see to_datapack<void>).

Parameters
pdestination ObjectPack
ptrpolymorphic agent pointer to serialize

◆ from_datapack()

template<typename PackType , typename Type , typename... AgentTypes>
static WeakAgentPtr fpmas::io::datapack::AgentPtrSerializer< PackType, Type, AgentTypes >::from_datapack ( const PackType &  p)
inlinestatic

Recursive from_datapack method used to unserialize polymorphic Agent pointers from ObjectPacks.

Type corresponds to the currently examined Agent type. If this type id (i.e. Type::TYPE_ID) corresponds to the ObjectPack type id value , the ObjectPack is unserialized using the specified PackType.

Else, attempts to recursively unserialize the ObjectPack with AgentPtrSerializer<AgentTypes...>::from_datapack(p, ptr). Notice that the last value of AgentTypes must be void to reach the recursion base case (see from_datapack<void>).

Parameters
psource ObjectPack
Returns
ptr unserialized polymorphic agent pointer

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