fpmas 1.5
Static Public Member Functions | List of all members
nlohmann::adl_serializer< std::type_index > Struct Reference

#include <json_serializer.h>

Static Public Member Functions

static FPMAS_TYPE_INDEX register_type (const std::type_index &type)
 
template<typename JsonType >
static std::type_index from_json (const JsonType &j)
 
template<typename JsonType >
static void to_json (JsonType &j, const std::type_index &type)
 

Detailed Description

An nlohmann::adl_serializer specialization to allow JSON 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 nlohmann::adl_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

◆ from_json()

template<typename JsonType >
static std::type_index nlohmann::adl_serializer< std::type_index >::from_json ( const JsonType &  j)
inlinestatic

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

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

◆ to_json()

template<typename JsonType >
static void nlohmann::adl_serializer< std::type_index >::to_json ( JsonType &  j,
const std::type_index &  type 
)
inlinestatic

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

Parameters
jjson instance
typetype to serialize
Exceptions
fpmas::exceptions::BadTypeExceptionif the type was not register using register_type()

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