diff --git a/src/checkpoint/dispatch/vrt/object_registry.h b/src/checkpoint/dispatch/vrt/object_registry.h index d5d6dc05..ce1664e0 100644 --- a/src/checkpoint/dispatch/vrt/object_registry.h +++ b/src/checkpoint/dispatch/vrt/object_registry.h @@ -59,22 +59,25 @@ namespace objregistry { template struct ObjectEntry { - template + template ObjectEntry( TypeIdx in_idx, std::size_t in_size, Allocator&& in_allocator, - Constructor&& in_constructor + Constructor&& in_constructor, + Caster&& in_caster ) : idx_(in_idx), size_(in_size), allocator_(in_allocator), - constructor_(in_constructor) + constructor_(in_constructor), + caster_(in_caster) { } TypeIdx idx_ = no_type_idx; /**< The type index for this ObjT */ std::size_t size_ = 0; /**< The registered object size */ std::function allocator_; /**< Do standard allocation for object */ std::function constructor_; /**< Construct object on memory */ + std::function caster_; /**< Try to dynamic_cast */ }; template @@ -111,7 +114,8 @@ Registrar::Registrar() { index, sizeof(ObjT), []() -> void* { return std::allocator{}.allocate(1); }, - [](void* buf) -> BaseType* { return dispatch::Reconstructor::constructAllowFail(buf); } + [](void* buf) -> BaseType* { return dispatch::Reconstructor::constructAllowFail(buf); }, + [](void* buf) -> ObjT* { return dynamic_cast(buf); } } ); }