Hi, Is there a reason you ar doing it this way? Because your question now boils down to: "Why does it hurt, when I turn automatic template generation off?". As an user of an serializable class, I would never expect that my choice of archive would impact whether my code compiles or not. Especially since the interface states that i can (through template<class Archive>). Instead I would assume that i could safely add my own archives without checking weird macros in theird party libraries. Greetings, Oswin because it cna assume it to be there. On 2012-09-11 18:22, Brian Budge wrote:
On Tue, Sep 11, 2012 at 8:50 AM, Riccardo Murri
wrote: Hello,
On Tue, Sep 11, 2012 at 12:51 AM, Brian Budge
wrote: I've got a class hierarchy that can already be serialized into text or binary archives. I'm explicitly instantiating the template functions for serialize and/or load/save.
I'm trying to add the capability to have boost mpi perform the serialization through send/recv/broadcast.
If your class has serialization support, that's enough. You should not provide specialization for mpi::detail classes.
(Of course, YMMV - since you didn't provide any code, my comment above could be completely off ...)
Cheers, Riccardo
Thanks for the replies. Here are the macros I made to perform the explicit instantiation:
#define INSTANTIATE_FUNCTION_FOR_INPUT_ARCHIVES(FUNC) \ template void FUNC(boost::archive::binary_iarchive &archive, \ const unsigned int version); \ template void FUNC(boost::mpi::packed_iarchive &archive, \ const unsigned int version); \ template void FUNC(boost::archive::text_iarchive &archive, \ const unsigned int version)
#define INSTANTIATE_FUNCTION_FOR_OUTPUT_ARCHIVES(FUNC) \ template void FUNC(boost::archive::binary_oarchive &archive, \ const unsigned int version); \ template void FUNC(boost::mpi::packed_oarchive &archive, \ const unsigned int version); \ template void FUNC(boost::mpi::detail::mpi_datatype_oarchive &archive, \ const unsigned int version); \ template void FUNC(boost::archive::text_oarchive &archive, \ const unsigned int version)
#define MAKE_SERIALIZE_FUNCTIONS(CLASS) \ INSTANTIATE_FUNCTION_FOR_INPUT_ARCHIVES(CLASS::serialize); \ INSTANTIATE_FUNCTION_FOR_OUTPUT_ARCHIVES(CLASS::serialize)
Then, along with implementing the templatized versions of serialize for each class, I will call the MAKE_SERIALIZE_FUNCTIONS(myclass) in each myclass.cpp.
So to Robert's question, I don't think this is something that could be baked into the boost_mpi.so library, since they rely on my own classes. I was just surprised to find that I needed to explicitly instantiate with something from detail rather than just the packed archives.
Thanks, Brian
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users