template<typename AgentType>
struct fpmas::io::datapack::LightSerializer< fpmas::api::utils::PtrWrapper< AgentType >, typename std::enable_if< std::is_base_of< fpmas::api::model::Agent, AgentType >::value &&!std::is_default_constructible< AgentType >::value &&std::is_same< AgentType, typename AgentType::FinalAgentType >::value >::type >
A default LightSerializer specialization for Agent types, when no default constructor is available. In this case, to_datapack() and from_datapack() methods falls back to the classic io::datapack::Serializer serialization rules, what might be inefficient. A warning is also printed at runtime.
To avoid this inefficient behaviors, two things can be performed:
- Defining a default constructor for
AgentType. Notice that the default constructed AgentType will never be used by FPMAS (since AgentType transmitted in a LightObjectPack are completely passive, a complete DistributedNode transfer is always performed when the Agent data is required).
- Specializing the LightSerializer with
AgentType: namespace fpmas {
namespace io {
namespace datapack {
template<>
struct LightSerializer<
fpmas::api::utils::PtrWrapper<CustomAgentType>> {
...
}
...
return new CustomAgentType(...);
}
};
}}}
Definition: ptr_wrapper.h:21
BasicObjectPack< LightSerializer > LightObjectPack
Definition: datapack.h:1366
static fpmas::api::utils::PtrWrapper< AgentType > from_datapack(const LightObjectPack &pack)
Definition: datapack_serializer.h:500
static void to_datapack(LightObjectPack &pack, const fpmas::api::utils::PtrWrapper< AgentType > &agent)
Definition: datapack_serializer.h:476
- Template Parameters
-
| AgentType | concrete type of Agent to serialize |