How can we serialize pointer of type base abstract class pointing to Derived concrete class
We have a situation where there is BaseAbstract class and Derived concrete
class.
Interface requires that we pass BaseAbstractClassPointer, using which user
can provide any of Derived Concrete class pointer and Interface remain
generic to them.
However serializing BaseAbstractPointer is throwing following error -
*A unregistered class*
How do we handle this situation ?
#include <iostream>
#include <fstream>
#include
"Piyush Kapadia"
I could not find any documents for Reference >> Pointers >> Pointers to
Objects of Derived Classes ??
Can you please send html link, thanks
On 11/1/05, Jeff Flinn
"Piyush Kapadia"
wrote in message news:7e7bf0020511010615t8c92a2asfe149a43ba845080@mail.gmail.com... We have a situation where there is BaseAbstract class and Derived concrete class. Interface requires that we pass BaseAbstractClassPointer, using which user can provide any of Derived Concrete class pointer and Interface remain generic to them. However serializing BaseAbstractPointer is throwing following error - *A unregistered class* How do we handle this situation ? See Reference >> Pointers >> Pointers to Objects of Derived Classes in the serialization docs. You'll have to explicitly register your derived classes.
Jeff Flinn
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Piyush, Could you post in plain text please. It's difficult to avoid top positing otherwise.
I could not find any documents for Reference >> Pointers >> Pointers to Objects of Derived Classes ?? Can you please send html link, thanks
http://www.boost.org/libs/serialization/doc/index.html Will get you to the serialization docs. This looks like it changed since I first responded. There is a tree on the left side. Expand Reference >> Serializable Concept >> Pointers >> Pointers to Objects of Derived Classes to get to the pertinent section. The html organization and/or Internet Explorer are not allowing me to easily get you a more detailed link. Jeff Flinn
Jeff Flinn
Piyush, Could you post in plain text please. It's difficult to avoid top positing otherwise.
I could not find any documents for Reference >> Pointers >> Pointers to Objects of Derived Classes ?? Can you please send html link, thanks http://www.boost.org/libs/serialization/doc/index.html Will get you to the serialization docs. This looks like it changed since I first responded. There is a tree on the left side. Expand Reference >> Serializable Concept >> Pointers >> Pointers to Objects of Derived Classes to get to the pertinent section. The html organization and/or
Internet
Explorer are not allowing me to easily get you a more detailed link. Jeff Flinn
_______________________________________________ Boost-users mailing list Boost-users <at> lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Piyush I have had the same problem using a polymorphic collection of boost shared pointers. The collection contains (boost shared) pointers to the abstract base class which point to derived concrete classes. I use boost version 1.32 and MSVC version 7. At first I included the macro BOOST_CLASS_EXPORT_GUID for each derived concrete class. Tracing through with the debugger, I saw that although the derived concrete class was being serialized, an unregistered class exception was being thrown subsequently when boost tried to serialize the reference count part of the shared pointer itself. This is a structure which, it turns out, also needs to be registered. The solution was to use the macro BOOST_SHARED_POINTER_EXPORT instead of the previous macro. This correctly serializes both the object and the shared pointer to the object. I hope this helps you. Regards Alan Afif
participants (3)
-
Alan Afif
-
Jeff Flinn
-
Piyush Kapadia