I am using boost to serialize\de-serialize several classes to disk. I am refactoring many classes which require changes the class hierarchy. I hope the following pseudo code is sufficiently clear in communicating my situation:
The original design was similar to the following:
class Alpha : public BaseOne, public BaseTwo
{
//member data omitted
void serialize(Archive & ar, const unsigned int version);
}
inline void Alpha::serialize(Archive & ar, const unsigned int version)
{
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseOne);
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseTwo);
// also serialize member data
}
class Beta: public Alpha
{
//member data omitted
void serialize(Archive & ar, const unsigned int version);
}
inline void Beta:::serialize(Archive & ar, const unsigned int version)
{
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Alpha);
// also serialize member data
}
The class hierarchy has changed to the following:
class Alpha : public BaseOne
{
void serialize(Archive & ar, const unsigned int version);
}
class Beta: public Alpha, public BaseTwo
{
void serialize(Archive & ar, const unsigned int version);
}
Is it possible to de-serialize data saved with previous class hierarchy into the new design?
Regards, John