1 #ifndef CondFormats_SerializationHelper_SerializationHelper_h 2 #define CondFormats_SerializationHelper_SerializationHelper_h 22 #include <string_view> 39 return std::make_unique<T>();
48 template <
typename T,
bool IsAbstract,
typename... INHERITING>
54 template <
typename T,
typename INIT = NoInitializer>
66 using BaseClassAndInheriting =
68 return deserialize_impl<BaseClassAndInheriting>(iBuff, iClassName);
70 return deserialize_impl<typename BaseClassInfo<T>::inheriting_classes_t>(iBuff, iClassName);
74 std::string_view
serialize(std::streambuf& oBuff,
void const* iObj)
const final {
75 auto iTypedObjectPtr =
static_cast<T const*
>(iObj);
77 return serialize_impl<typename BaseClassInfo<T>::inheriting_classes_t>(oBuff, iTypedObjectPtr);
79 using BaseClassAndInheriting =
81 return serialize_impl<BaseClassAndInheriting>(oBuff, iTypedObjectPtr);
85 const std::type_info&
type()
const final {
return typeid(
T); }
88 template <
typename TYPELIST>
95 std::unique_ptr<CheckType>
tmp = makeClass<CheckType>();
99 if constexpr (not std::is_same_v<INIT, NoInitializer>) {
103 return unique_void_ptr(
tmp.release(), [](
const void* iPtr) {
delete static_cast<const T*
>(iPtr); });
106 return deserialize_impl<typename edm::mpl::Pop<TYPELIST>::Remaining>(iBuff, iClassName);
110 template <
typename TYPELIST>
118 oa << *iTypedObjectPtr;
123 return serialize_impl<typename edm::mpl::Pop<TYPELIST>::Remaining>(oBuff, iObj);
eos::portable_oarchive OutputArchive
const std::type_info & type() const final
const SerializationHelper & operator=(const SerializationHelper &)=delete
eos::portable_iarchive InputArchive
std::unique_ptr< T > makeClass()
static constexpr bool kAbstract
std::string_view serialize(std::streambuf &oBuff, void const *iObj) const final
unique_void_ptr deserialize(std::streambuf &iBuff, const std::string_view iClassName) const final
static constexpr bool kAbstract
static std::string_view serialize_impl(std::streambuf &oBuff, T const *iObj)
SerializationHelper()=default
static unique_void_ptr deserialize_impl(std::streambuf &iBuff, const std::string_view iClassName)