![]() |
fpmas 1.6
|
Go to the source code of this file.
Namespaces | |
namespace | fpmas |
Macros | |
#define | FPMAS_AGENT_PTR_DATAPACK_JSON_FALLBACK() |
#define | FPMAS_AGENT_PTR_JSON_DATAPACK_FALLBACK() |
#define | FPMAS_JSON_SET_UP(...) |
#define | FPMAS_DEFAULT_JSON_SET_UP() |
#define | FPMAS_DATAPACK_SET_UP(...) |
#define | FPMAS_DEFAULT_DATAPACK_SET_UP() |
#define | FPMAS_REGISTER_AGENT_TYPES(...) fpmas::register_types<__VA_ARGS__ , void>(); |
Functions | |
template<typename _T , typename... T> | |
void | fpmas::register_types () |
template<> | |
void | fpmas::register_types< void > () |
Agent serialization related objects.
#define FPMAS_AGENT_PTR_DATAPACK_JSON_FALLBACK | ( | ) |
Defines a json based implementation of AgentPtr fpmas::io::datapack::Serializer and fpmas::io::datapack::LightSerializer implementation, that can be used instead of definitions provided by FPMAS_BASE_DATAPACK_SET_UP().
This allows to use the object pack serialization for DistributedNodes for example, even if ObjectPack serialization rules are not provided for AgentPtr (i.e. FPMAS_BASE_DATAPACK_SET_UP() is not used).
#define FPMAS_AGENT_PTR_JSON_DATAPACK_FALLBACK | ( | ) |
Defines an object pack based implementation of AgentPtr nlohmann::adl_serializer and fpmas::io::json::light_serializer implementation, that can be used instead of definitions provided by FPMAS_BASE_JSON_SET_UP().
This allows to use the json serialization for DistributedNodes for example, even if JSON serialization rules are not provided for AgentPtr (i.e. FPMAS_BASE_JSON_SET_UP() is not used).
#define FPMAS_JSON_SET_UP | ( | ... | ) |
Sets up json based Agent serialization rules.
This macro must be invoked exactly once from a source file and should not be called together with FPMAS_DATAPACK_SET_UP().
It is possible to call the FPMAS_DEFAULT_JSON_SET_UP() macro to set up the JSON serialization without specifying any Agent.
The same set of Agent types must be registered at runtime using the FPMAS_REGISTER_AGENT_TYPES(...) macro at runtime.
ObjectPack Agent serialization is set up so that Agent are serialized into JSON, stored in an ObjectPack field. To prevent this behavior, FPMAS_BASE_JSON_SET_UP() and FPMAS_BASE_DATAPACK_SET_UP() can be used together to enable both Agent serialization techniques.
Notice that all of this only affect AgentPtr serialization: serialization of any other object, with JSON or ObjectPack, is not altered by those macros.
See the nlohmann::adl_serializer<fpmas::api::utils::PtrWrapper<AgentType>> documentation to learn how to enable Agent datapack serialization.
#define FPMAS_DEFAULT_JSON_SET_UP | ( | ) |
Can be used instead of FPMAS_JSON_SET_UP() to set up json serialization without specifying any Agent type.
#define FPMAS_DATAPACK_SET_UP | ( | ... | ) |
Sets up object pack based Agent serialization rules.
This macro must be invoked exactly once from a source file and should not be called together with FPMAS_JSON_SET_UP().
It is possible to call the FPMAS_DEFAULT_DATAPACK_SET_UP() macro to set up the object pack serialization without specifying any Agent.
The same set of Agent types must be registered at runtime using the FPMAS_REGISTER_AGENT_TYPES(...) macro at runtime.
ObjectPack Agent serialization is set up so that Agent are serialized into JSON, stored in an ObjectPack field. To prevent this behavior, FPMAS_BASE_JSON_SET_UP() and FPMAS_BASE_DATAPACK_SET_UP() can be used together to enable both Agent serialization techniques.
Notice that all of this only affect AgentPtr serialization: serialization of any other object, with JSON or ObjectPack, is not altered by those macros.
See the fpmas::io::datapack::Serializer<api::utils::PtrWrapper<AgentType>> documentation to learn how to enable Agent datapack serialization.
#define FPMAS_DEFAULT_DATAPACK_SET_UP | ( | ) |
Can be used instead of FPMAS_DATAPACK_SET_UP() to set up object pack serialization without specifying any Agent type.
#define FPMAS_REGISTER_AGENT_TYPES | ( | ... | ) | fpmas::register_types<__VA_ARGS__ , void>(); |
Registers the specified Agent types so that they can be serialized as JSON using the nlohmann
library.
More particularly, registers Agents types so that their TypeId (i.e. their corresponding std::type_index) can be serialized. Serialization rules (to_json and from_json methods) for each type must still be specified.
This macro must be called at runtime, as soon as possible, before any Agent serialization occurs.