src/checkpoint/dispatch/vrt/virtual_serialize.h file

Namespaces

namespace checkpoint
namespace checkpoint::dispatch
namespace checkpoint::dispatch::vrt

Classes

template<typename T, typename SerializerT, typename _enabled = void>
struct checkpoint::SerializeVirtualTypeIfNeeded
Do a static trait test on type to check for virtual serializability.
template<typename T, typename SerializerT>
struct checkpoint::SerializeVirtualTypeIfNeeded<T, SerializerT, typename std::enable_if_t<dispatch::vrt::VirtualSerializeTraits<T>::has_not_virtual_serialize>>
template<typename T, typename SerializerT>
struct checkpoint::SerializeVirtualTypeIfNeeded<T, SerializerT, typename std::enable_if_t<dispatch::vrt::VirtualSerializeTraits<T>::has_virtual_serialize>>
template<typename T, typename SerializerT, typename _enabled = void>
struct checkpoint::ReconstructAsVirtualIfNeeded
Do a static trait test on type to check for virtual serializability. If virtually serializable, we need to perform some extra work to register the type, allocate, and construct the proper type. Otherwise, we go through the normal path for allocating memory for T and serializing what the pointer points to.
template<typename T, typename SerializerT>
struct checkpoint::ReconstructAsVirtualIfNeeded<T, SerializerT, typename std::enable_if_t<dispatch::vrt::VirtualSerializeTraits<T>::has_not_virtual_serialize and not checkpoint::is_footprinter_v<SerializerT>>>
template<typename T, typename SerializerT>
struct checkpoint::ReconstructAsVirtualIfNeeded<T, SerializerT, typename std::enable_if_t<dispatch::vrt::VirtualSerializeTraits<T>::has_not_virtual_serialize and checkpoint::is_footprinter_v<SerializerT>>>
template<typename T, typename SerializerT>
struct checkpoint::ReconstructAsVirtualIfNeeded<T, SerializerT, typename std::enable_if_t<dispatch::vrt::VirtualSerializeTraits<T>::has_virtual_serialize>>

Functions

template<typename T, typename SerializerT>
void virtualSerialize(T*& base, SerializerT& s)
A function to handle serialization of objects of a mix of types in a virtual inheritance hierarchy.
template<typename SerializerT, typename T>
void reconstructPointedToObjectIfNeeded(SerializerT& s, T*& target)
Allocate and construct memory for a pointer with type T.

Function documentation

template<typename T, typename SerializerT>
void virtualSerialize(T*& base, SerializerT& s)

A function to handle serialization of objects of a mix of types in a virtual inheritance hierarchy.

This will automatically record the exact derived type at serialization, and reconstruct objects accordingly at deserialization.

template<typename SerializerT, typename T>
void reconstructPointedToObjectIfNeeded(SerializerT& s, T*& target)

Allocate and construct memory for a pointer with type T.

Parameters
in the serializer
target in a reference to a pointer to the target object

This function automatically handles allocating and constructing the right type for virtually serialized pointers or non-virtual static allocation and construction.

An example of how to use this to properly serialize a std::shared_ptr<T>:

template <typename t>=""> struct X { std::shared_ptr<T> a;

template <typename serializert>=""> void serialize(SerializerT& s) { T* raw = elm.get(); checkpoint::reconstructPointedToObjectIfNeeded(s, raw); if (s.isUnpacking()) { a = std::shared_ptr<T>(raw); } s | *a; } };