[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IMP-dev] IO support with boost



I was just checking out the boost serialization library. It looks like the simplest way to get code to save and restore the model state. It also supports XML io, so you can relatively easily generate an XML file. This makes it pretty useless in terms of human readability.

To read and write a DistanceRestraint using the library you just add code like
template <class Archive>
void serialize(Archive &ar, const unsigned int version)
{
	ar &boost::serialization::base_object<Restraint>(*this);
	ar &boost::make_nvp("scorefunction", sf_);
}

in addition, we need the macro "BOOST_CLASS_EXPORT(DistanceRestraint)" so it gets the names right.

That is pretty awesome as there is only one chuck of code, so there is less to keep synchronized.
It has support for stl containers so those get trivially serialized too.