Boost logo

Boost Users :

Subject: Re: [Boost-users] [Serialization] unable to fix UNREGISTERED CLASSexception
From: David Graf (david.graf_at_[hidden])
Date: 2010-02-17 11:07:51


Hello Robert

I fixed the example. I had to add somewhere a virtual function. Otherwise, the polymorphism doesn't work.

Unfortunately, I have a new problem. If I put the code into a static library, the serialization from the outside doesn't work anymore. Then, I get a unregistered class exception. It only works when I put the code to execute the serialization into the cpp file where the classes are registered with BOOST_CLASS_EXPORT_GUID.

Again, I attached the example source code. The library is created with cmake. Therefore, you need to have cmake installed on your machine to test the example. The commands to build the example are
cd /path/to/unpacked/testfolder
mkdir build
cd build
cmake ..
make

Funnily enough, the serialization from the outside (from the main function) works if the serialization in the cpp file is executed in advance.

The example works if the library is a dynamic library. If you wanna see this, you need to replace STATIC in CMakeLists.txt with SHARED.

David


On Feb 16, 2010, at 8:37 PM, Robert Ramey wrote:

> David Graf wrote:
>> Hello Everybody
>>
>> I am using boost serialization heavily in my project to serialize C++
>> objects. Unfortunately, I have a big problem when I when polymorphic
>> pointers and non intrusive serialize functions are involved in the
>> serialization.
>> Therefore, I made a little project which demonstrates my usage of
>> boost functionality (see attachment). Basically, I have four classes
>> which are derived in the following way: Item <- AtomicItem <-
>> BooleanItem <- SpecialItem. SpecialItem contains an intrusive
>> serialized functions. The other three contain non intrusive serialize
>> functions.
>> In the main function (testing.cpp), I create a SpecialItem and the
>> stack and assign it to a pointer to an Item. Then, I serialize that
>> Item.
>>
>> Unfortunately, it doesn't work. Only the serialize function of the
>> class Item is invoked. Can you please tell me what I did wrong in my
>> example?
>
> I believe that taking the non_intrusive functions out of the namespace
> boost::serialization might work better.
>
> It seems to me that things should work as you have it, but I would
> have to look into it in more detail.
>
> Robert Ramey
>
>
>>
>> Note:
>> The example can be compiled with the command: g++
>> atomic_items_serialization.cpp testing.cpp -o testing
>> -lboost_serialization-mt
>> And the expected result is:
>> serializing Item
>> serializing AtomicItem
>> serializing BooleanItem
>> serializing SpecialItem
>>
>> Thanks in advance
>>
>> David
>>
>>
>>
>>
>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users



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