-----Original Message-----
From: boost-users-bounces@lists.boost.org [mailto:boost-users-
bounces@lists.boost.org] On Behalf Of Robert Ramey
Sent: 20 January 2012 17:05
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] mpi/serialization: broadcasting derivedclass
through base pointer
MM wrote:
-----Original Message-----
...
Hello Matthias, Robert Ramey,
I am revisiting the topic of mpi broadcast-receiving a polymorphic
object through a base class null pointer:
void recv_histodata(boost::mpi::communicator& world)
{
historical_data_base* hd = nullptr;
boost::mpi::broadcast(world, hd, master_process);
}
historical_data_base has 3 derived classes.
I get the unregistered class exception from the serialization
library, and so I am trying to register the derived type as shown in
the serialization doc at /libs/serialization/doc/index.html :
reference
ar.template register_type<derived_one>();
but where do I put that?
invoke that any time after the archive is created but before the
"derived_one" is serialized.
make sure you do it in the same place on saving an loading. I believe
the
following would work.
binary_oarchive oa(...)
oa.template register_type<derived_one>;
...
binary_iarchive ia(...)
ia.template register_type<derived_one>;
...
I went with the export guid route. It builds but it seems to go into an infinite loop. This is: interface_archive.hpp template<class T> Archive & operator>>(T & t){
this->This()->load_override(t, 0);
return * this->This(); } which calls itself again after a couple of in-between calls to other functions. Here is a stack:
nhcomp.exe!boost::archive::detail::interface_iarchive<boost::mpi::packed_iar chive>::operator>><boost::archive::class_id_type>(boost::archive::class_id_t ype & t) Line 60 C++ nhcomp.exe!boost::archive::detail::common_iarchive<boost::mpi::packed_iarchi ve>::vload(boost::archive::class_id_type & t) Line 52 C++ nhcomp.exe!boost::archive::detail::basic_iarchive_impl::load<boost::archive: :class_id_type>(boost::archive::detail::basic_iarchive & ar, boost::archive::class_id_type & t) Line 198 C++ nhcomp.exe!boost::archive::detail::basic_iarchive_impl::load_pointer(boost:: archive::detail::basic_iarchive & ar, void * & t, const boost::archive::detail::basic_pointer_iserializer * bpis_ptr, const boost::archive::detail::basic_pointer_iserializer * (const boost::serialization::extended_type_info &)* finder) Line 411 C++ nhcomp.exe!boost::archive::detail::basic_iarchive::load_pointer(void * & t, const boost::archive::detail::basic_pointer_iserializer * bpis_ptr, const boost::archive::detail::basic_pointer_iserializer * (const boost::serialization::extended_type_info &)* finder) Line 551 C++ nhcomp.exe!boost::archive::detail::load_pointer_type<boost::mpi::packed_iarc hive>::invoke<nicohich::histodatas::historical_data_base *>(boost::mpi::packed_iarchive & ar, nicohich::histodatas::historical_data_base * & t) Line 524 + 0x15 bytes C++ nhcomp.exe!boost::archive::load<boost::mpi::packed_iarchive,nicohich::histod atas::historical_data_base *>(boost::mpi::packed_iarchive & ar, nicohich::histodatas::historical_data_base * & t) Line 592 + 0xd bytes C++ nhcomp.exe!boost::archive::detail::common_iarchive<boost::mpi::packed_iarchi ve>::load_override<nicohich::histodatas::historical_data_base *>(nicohich::histodatas::historical_data_base * & t, int __formal) Line 66 + 0x15 bytes C++ nhcomp.exe!boost::mpi::packed_iarchive::load_override<nicohich::histodatas:: historical_data_base *>(nicohich::histodatas::historical_data_base * & x, int version, boost::mpl::bool_<0> __formal) Line 102 C++ nhcomp.exe!boost::mpi::packed_iarchive::load_override<nicohich::histodatas:: historical_data_base *>(nicohich::histodatas::historical_data_base * & x, int version) Line 119 C++ nhcomp.exe!boost::archive::detail::interface_iarchive<boost::mpi::packed_iar chive>::operator>><nicohich::histodatas::historical_data_base *>(nicohich::histodatas::historical_data_base * & t) Line 61 C++ rds,