Boost logo

Boost Users :

From: RIVASSEAU Jean Noel (JN.RIVASSEAU_at_[hidden])
Date: 2006-02-24 08:41:07


I forgot the code promised in last email sorry...

 

  _____

De : boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] De la part de Robert Ramey
Envoyé : jeudi 23 février 2006 17:44
À : boost-users_at_[hidden]
Objet : Re: [Boost-users] Serialization : unregistered_cast & otherquestions

 

Without actually seeing the code, its hard for me to give intelligent advice. Lucky for

you (maybe) that's not going to inhibit me from speculating. Here is what I recommend

for anyone making a very large program:

 

a) extended_type_info_no_rtti presumes that all classes serialized as pointers

have been exported. Should this not be the case, you'll get the error message indicated.

Double check this.

 

b) Serilaization traits should be in the header files so that they are not "missed" anytime

something like "ar << x" is invoked. Given you're situation I would recommend a file

structure like the following:

 

class.hpp - without seriaiization like you have now.

 

serialization/class.hpp - includes class.hpp. also includes BOOST_EXPORT and any

other traits for this "class".

 

serialization/class.cpp c - includes serialization/class.hpp and includes the

actual serialization code. Also this should include code instantiation for the archives that

you use. Look at demo_pimpl to see how this is done.

 

All the above code should be organized into a library. The reason is that this will generate

code for all the archives mentioned but your application may not use all the archives so

putting the above code in a library and linking to it will mean that your application will

always have what it actuallyuses but nothing it doesn't - avoids "code bloat". Note that

in compiling code for the library make sure to specify "function level linking".

 

Take the "least derived class" - that one at the top of the class hierarchy. Make a small

test program similar to the tests in the serialization library. This should be a very small

job. This code can be class_test.cpp. Run this test on all archives you use. When

this test passes, do the same for the other classes until something fails.

 

This might seem to be more work - believe me its not. It will

 

a) guarentee that you make progress toward a robust program

b) give you confidence that your program has minimum of hidden bugs

c) permit you to re-run the tests automatically when you make future changes.

d) should a problem arise with the serialization or other library, it will give

a lot more information in order to be helpful.

 

Robert Ramey

 

        Now, the problem is where to put the serialization code for these classes. If I just write them on the implementation file (the .cc) for the class, it does not work. At run time I have always errors telling me that either the class is not exported (unregistered_class exception) or an unregistered_cast happens.

         

         

         

         

        The only solution I have found is to put *ALL* serialization code into the same big .cc file. If I do just that, it works. However this file is becoming enormous and has to be recompiled every time I change only *one* of the class to be serialized. It is already taking a minute to compile on a fast machine, so I must really break it up into other parts.

         

        But everytime I do that everything stops working.

         

        Have you any ideas, Robert? I am using extended_type_info_no_rtti, this may be the cause of the problem...

         

        Jean-Noël

         

        Ps: I still have the std::string bug, which is also uncomprehensible for me.

        
  _____

        _______________________________________________
        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