diff --git a/lib/serializer/BinarySerializer.h b/lib/serializer/BinarySerializer.h index 2a247153b..b86cc9cf6 100644 --- a/lib/serializer/BinarySerializer.h +++ b/lib/serializer/BinarySerializer.h @@ -85,7 +85,7 @@ class BinarySerializer : public CSaverBase class CBasicPointerSaver { public: - virtual void savePtr(CSaverBase &ar, const void *data) const =0; + virtual void savePtr(CSaverBase &ar, const Serializeable *data) const =0; virtual ~CBasicPointerSaver() = default; template static CBasicPointerSaver *getApplier(const T * t=nullptr) @@ -99,10 +99,10 @@ class BinarySerializer : public CSaverBase class CPointerSaver : public CBasicPointerSaver { public: - void savePtr(CSaverBase &ar, const void *data) const override + void savePtr(CSaverBase &ar, const Serializeable *data) const override { auto & s = static_cast(ar); - const T *ptr = static_cast(data); + const T *ptr = dynamic_cast(data); //T is most derived known type, it's time to call actual serialize const_cast(ptr)->serialize(s); @@ -283,7 +283,7 @@ public: if(!tid) save(*data); //if type is unregistered simply write all data in a standard way else - applier.getApplier(tid)->savePtr(*this, static_cast(data)); //call serializer specific for our real type + applier.getApplier(tid)->savePtr(*this, static_cast(data)); //call serializer specific for our real type } template < typename T, typename std::enable_if_t < is_serializeable::value, int > = 0 >