Boost logo

Boost Users :

From: Joseph Hosteny (jhosteny_at_[hidden])
Date: 2006-04-30 13:00:45


On Apr 30, 2006, at 12:07 PM, Robert Ramey wrote:

> Joseph Hosteny wrote:
>> Thanks for the response. I'd have continued the thread, but I didn't
>> get the original emails from the list to reply to.
>>
>> I tried an explicit registration, with the same results. Also, I did
>> step into the code where the EXPORT macros were being called, and I
>> verified that the pertinent classes were registered in the
>> boost::serialization::detail::ktmap, at least (not sure about the
>> tkmap). It seems like it just doesn't find the class in the
>> oserialization file where the exception is thrown.
>>
>> The serialization is invoked in a const public class method, via "oa
>> << this;" Is there anything tricky you might be aware of that could
>> cause the type comparisons to fail? Could I potentially be missing
>> something in my class?
>
> I would be curious as to the context in which one would use:
>
> oa << this;
>
> I don't know that its relevant. But off hand I can't see why anyone
> would ever want to do this rather than
>
> oa << x where x is the thing we want to save.

We're using swig to wrap the classes and provide an interface to them
through Tcl. So, I simply have a member function of the class that
gets auto-generated to a function that can be called in Tcl to do the
save.

There's actually no requirement that it be this way. I didn't really
think it was relevant, either, but I grasping for any little thing
that I may be doing wrong.

>
>> Unfortunately, the project is quite large and it'd fairly difficult
>> to strip out everything and add it back in incrementally.
>
> Which of course makes it almost impossible for me to be of
> much help. If its a big project, you might try the following.
>

Yes, I appreciate the feedback anyway.

> a) create a small test program. This program would include
> the class declarations for all your classes which include
> serializaition.
>
> b) invoke serialization on each one of your classes.
>
> So the result would look like:
>
> #include <boost/archive/text_archive.hpp>
>
> #include "my_class_a.hpp"
> #include "my_class_b.hpp"
> ...
>
> int
> main(int argc, char * argv[]){
> my_class_a a_out, a_in;
> my_class_b b_out, b_in;
> {
> std::fostream ofs("test");
> boost::archive::text_oarchive oa(ofs);
> oa << a_out;
> oa << b_out;
> ...
> }
> {
> std::fistream ifs("test");
> boost::archive::text_oarchive ia(ifs);
> oa >> a_in;
> oa >> b_in;
> ...
> }
> assert(a_in == a_out);
> assert(b_in == b_out);
> ...
> }
>

I did make a small test program, but using a similar class hierarchy,
and not the actual code. I may try this next, and start by trying to
simple serialize an instance of the base class.

> c) If some code re-factoring has to be done in order to make a test
> like the
> above, I would recommend that you just bite the bullet and do it. It
> will make your project much easier to develope and much more likely
> to be correct. In fact, you might make a test like the above for each
> one of your classes - take a look at how the serialization library
> tests
> are set up.
>

I probably will wind up doing some refactoring, so this thread may be
moot. I was just hoping to avoid putting that off for a while longer,
but it may no longer be feasible.

> d) I don't remember what your environment is - compiler, os, standard
> library, DLLS yes/no etc. So you might want to remind me again.
>

linux 2.6.12, amd64 smp
boost_1_33_1
gcc 3.3
stdlib++.so.5

> Robert Ramey
>

Thanks anyway for the help.

Joe

>
>
> _______________________________________________
> 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