fpmas 1.5
Static Public Member Functions | List of all members
fpmas::io::datapack::Serializer< std::type_index > Struct Reference

#include <datapack_serializer.h>

Static Public Member Functions

static FPMAS_TYPE_INDEX register_type (const std::type_index &type)
 
template<typename PackType >
static FPMAS_TYPE_INDEX size (const PackType &pack)
 
template<typename PackType >
static FPMAS_TYPE_INDEX size (const PackType &o, const std::type_index &)
 
template<typename PackType >
static void to_datapack (PackType &pack, const std::type_index &index)
 
template<typename PackType >
static std::type_index from_datapack (const PackType &pack)
 

Detailed Description

A Serializer specialization to allow ObjectPack serialization of std:type_index, that is used as Agents TypeId.

Each registered std::type_index is automatically mapped to a unique std::size_t integer to allow serialization.

Member Function Documentation

◆ register_type()

static FPMAS_TYPE_INDEX fpmas::io::datapack::Serializer< std::type_index >::register_type ( const std::type_index &  type)
inlinestatic

Register an std::type_index instance so that it can be serialized.

A unique integer id is internally associated to the type and used for serialization.

The fpmas::register_types() function template and the FPMAS_REGISTER_AGENT_TYPES(...) macro can be used to easily register types.

Parameters
typetype to register

◆ size() [1/2]

template<typename PackType >
static FPMAS_TYPE_INDEX fpmas::io::datapack::Serializer< std::type_index >::size ( const PackType &  pack)
inlinestatic

Returns the buffer size required to serialize an std::type_index instance, i.e. pack.size<FPMAS_TYPE_INDEX>();

◆ size() [2/2]

template<typename PackType >
static FPMAS_TYPE_INDEX fpmas::io::datapack::Serializer< std::type_index >::size ( const PackType &  o,
const std::type_index &   
)
inlinestatic

Equivalent to size().

◆ to_datapack()

template<typename PackType >
static void fpmas::io::datapack::Serializer< std::type_index >::to_datapack ( PackType &  pack,
const std::type_index &  index 
)
inlinestatic

Serializes an std::type_index instance into the specified ObjectPack.

Parameters
packdestination BasicObjectPack
indextype index to serialize
Exceptions
fpmas::exceptions::BadTypeExceptionif the type was not register using register_type()

◆ from_datapack()

template<typename PackType >
static std::type_index fpmas::io::datapack::Serializer< std::type_index >::from_datapack ( const PackType &  pack)
inlinestatic

Unserializes an std::type_index instance from the specified ObjectPack.

Parameters
packsource BasicObjectPack
Exceptions
fpmas::exceptions::BadIdExceptionif the id does not correspond to a type registered using register_type()

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