Boost logo

Boost Users :

From: Markus Bernhardt (Markus.Bernhardt_at_[hidden])
Date: 2007-07-06 05:05:15


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Small typo:

Markus Bernhardt schrieb:
> Hi Anders,
>
> I had exactly the same problem three days ago. I have found no way to
> prevent the compiler from instantiating some templates with
> serialization code in multiple DLLs. My solution was to switch from
> intrusive to non intrusive serialization and putting all serialization
> binaries in a third DLL.
>
> How it works (for me):
>
> 1. Rename all
> template <class Archive>
> void serialize(Archive& ar, const unsigned int version) { ... }
> to
> template <class Archive>
> void my_serialize(Archive& ar, const unsigned int version) { ... }
> and make it public.
>
> 2. Remove all serialization headers and macros from the existing code.
>
> 3. Create a new DLL.
>
> 4. For every serializable class I have there a .cpp file which looks like:
>
> #include <boost/archive/binary_oarchive.hpp>
> #include <boost/archive/binary_iarchive.hpp>
> #include <boost/serialization/base_object.hpp>
> #include <boost/serialization/export.hpp>
> #include "abstracts.h"
>
> namespace boost
> {
> namespace serialization
> {
> template <class Archive> void serialize(Archive& ar, MyClass& obj,
> const unsigned int version) {
> obj.template bm_serialize<Archive>(ar, version);

       obj.template my_serialize<Archive>(ar, version); // Correct

> }
> }
> }
>
> BOOST_CLASS_EXPORT(MyClass);
> BOOST_SHARED_POINTER_EXPORT(MyClass);
>
> 5. One additional file abstracts.h which looks like:
>
> #ifndef BM_SERIALITATION_ABSTRACTS_H_
> #define BM_SERIALITATION_ABSTRACTS_H_
>
> BOOST_IS_ABSTRACT(MyBaseClass)
>
> #endif
>
> #########################
>
> I'm not sure this is the preferred way to handle things, but at least it
> works for me.
>
> Best regards,
> Markus
>
> Anders Wang Kristensen schrieb:
>>> Hi,
>>>
>>> I'm trying to serialize a class using two functions located in different
>>> DLLs.
>>>
>>> I can serialize fine by calling one function, but when I call the second it
>>> triggers
>>> an assertion in extended_type_info.cpp:
>>>
>>> // make sure that attempt at registration is done only once
>>> assert(lookup(eti) == m_self->m_map.end());
>>>
>>> Apparently the class is registered twice, but how do I avoid that?
>>>
>>> -- Anders
>>>
>>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
> --
> Software Consulting
> Markus Bernhardt GmbH
> Spieljochstr. 34
> 81825 München
>
> Fon: +49-89-420903-14
> Fax: +49-89-420903-20
> www: http://www.scmb.de
>
> Geschäftsführung Markus Bernhardt
> Handelsregister AG München HRB 125966
> USt-Id DE201885231
>

- --
Software Consulting
Markus Bernhardt GmbH
Spieljochstr. 34
81825 München

Fon: +49-89-420903-14
Fax: +49-89-420903-20
www: http://www.scmb.de

Geschäftsführung Markus Bernhardt
Handelsregister AG München HRB 125966
USt-Id DE201885231

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGjgXLdnooMonJSYkRAqNjAJ9o5L66WJqa0EIE6NyHsn0eqcl3OQCeJbM6
BJoKVmpudhyz90rmBxI/IAw=
=tyTm
-----END PGP SIGNATURE-----


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