Todd Seiler wrote
I've been pulling my hair out for a couple of days trying to get this to work.
When I serialize something from a base pointer, it throws an "unregistered_class" exception.
On save or on load? I presume its on load.
I know the type of object that's being serialized and that class has "BOOST_CLASS_EXPORT_KEY" in the header and "BOOST_CLASS_EXPORT_IMPLEMENT" in the cpp file with the same name.
For all of the derived classes - right?
Each derived class should serialize it's base with
.... base_object
should not be necessary if you're serialization all the base objects < /quote The base class is an abstract base class with one pure virtual function method. But here are the differences: <quote > 1) I tried using the "ASSUME_ABSTRACT....." macro. That didn't do anything for me.
shouldn't make any difference these days
2) The abstract base class also has a cpp file with some code in it. I'm not sure if that matters or not...
Shouldn't be a problem. Just make sure all the save/load functions serialize their base objects.
Here's the thing. I can get the derived class's "save" method to be called with this code:
std::ofstream o(case_path_ + "/" + file_name); if (o.good()) {
// MUST HAVE THIS boost::serialization::void_cast_register<Derived, Base>( static_cast<Derived*>(NULL), static_cast<Base*>(NULL));
boost::archive::polymorphic_text_oarchive oa(o); boost::archive::polymorphic_oarchive & oa_interface = oa; oa_interface << base_ptr; } Having the void_cast_register() there sort of defeats the purpose though. I shouldn't need to pre-register them. In all the examples, I see the void_cast_register() inside of the "save" and "load" methods, which is what I have already.
which examples?
All my serialization code resides in cpp files.
Also, the serialization code resides in a static lib. But the archive creation and the action to serialize is performed in a dynamic lib.
REDFLAG - in some environments this is a big no-no as static and dynamic libraries have different c library implementations. There is no guarantee that mixing static and dynamic libraries will work. I recommend using either all one or all the other. Since you're interested in polymorphic archives - you'll likely want to use all dynamic.
I am also using polymorphic archives everywhere.
where? in another application? on another planet?
I've also forced template instantiation of all serialization code and polymorphic archive interface stuff.
But most linkers strip out code which is known to be called. This is particularly problematic for dlls. The serialization library does bunch of stuff to make sure such code is not dropped.
Any clue?
Look at more of the tests and example relating to export. Robert Ramey -- View this message in context: http://boost.2283326.n4.nabble.com/Serialization-1-56-0-unregistered-class-e... Sent from the Boost - Users mailing list archive at Nabble.com.