Boost logo

Boost Users :

Subject: [Boost-users] Problem with serialization, load_wrapper
From: Mikael Carlsson (mika_at_[hidden])
Date: 2009-08-28 04:53:03


Dear group,

I am working with a observer pattern in a simulator and would like to
restore the simulators state. This means that I need to restore the
pointers to the observers in the subject.

My simple example contains a composite that holds pointers to base class
of the observers. The observable hold one of the observers using a base
class pointer.

The save part is OK but when I introduce restore I get compile time errors.

Compiling (dbg) main.cpp obj/main.o
/home/ecarmik/boost/include/boost-1_39/boost/archive/detail/iserializer.hpp:
In function 'void boost::archive::load(Archive&, const T&) [with Archive
= boost::archive::text_iarchive, T = composite]':
/home/ecarmik/boost/include/boost-1_39/boost/archive/detail/common_iarchive.hpp:59:
   instantiated from 'void
boost::archive::detail::common_iarchive<Archive>::load_override(T&, int)
[with T = const composite, Archive = boost::archive::text_iarchive]'
/home/ecarmik/boost/include/boost-1_39/boost/archive/basic_text_iarchive.hpp:62:
   instantiated from 'void
boost::archive::basic_text_iarchive<Archive>::load_override(T&, int)
[with T = const composite, Archive = boost::archive::text_iarchive]'
/home/ecarmik/boost/include/boost-1_39/boost/archive/text_iarchive.hpp:65:
   instantiated from 'void
boost::archive::text_iarchive_impl<Archive>::load_override(T&, int)
[with T = const composite, Archive = boost::archive::text_iarchive]'
/home/ecarmik/boost/include/boost-1_39/boost/archive/detail/interface_iarchive.hpp:61:
   instantiated from 'Archive&
boost::archive::detail::interface_iarchive<Archive>::operator>>(T&)
[with T = const composite, Archive = boost::archive::text_iarchive]'
main.cpp:24: instantiated from here
/home/ecarmik/boost/include/boost-1_39/boost/archive/detail/iserializer.hpp:560:
error: no matching function for call to
'load_wrapper(boost::archive::text_iarchive&, const composite&,
boost::serialization::is_wrapper<composite>)'
make: *** [obj/main.o] Error 1

Is it possible to re-create objects during restore from file. Please
note that composite class only contains base class pointers. Do I need
to create a separate load to do this with constructors? Where can I read
  about this or even better, find an example?

Please find the files included.

   / Mikael




Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net