Boost logo

Boost Users :

From: Vincent Agnus (vincent.agnus_at_[hidden])
Date: 2007-10-05 09:41:49


Hi,

I have some trouble about extended_type_info registration using
BOOST_CLASS_EXPORT macro with shared library. Indeed an assertion
forbides the registration of the same extended_type_info many times.
This cases occurs when defining serialization of derivated classes in
different libraries for example considers the 2 libraries :
* the first one define a class and its serialization scheme
* the second one define a class derived from the class in the first libs
and its serialization scheme
A program using this two libraries to serialize classes raise an
assertion at runtime due to double registration of the base class
[
file serialization/extended_type_info.cpp line 74
// make sure that attempt at registration is done only once
         assert(lookup(eti) == m_self->m_map.end());
]

Here the detail implementation of libraries

LIB1
* files : Base.hpp ; Base.cpp defining a base class ( no serialization
code here)
* file : BaseSerilization.hxx which contains the definition of the non
intrusive template function serialize ( no macro BOOST_CLASS_EXPORT here )
* file BaseSerilizationInstanciation.cpp which explicit instanciate the
previous function with a fixed Archive class, this file also contain the
macro BOOST_CLASS_EXPORT(Base)

LIB2
* file Derivated.hpp, Derivated.cpp defining derivated class from Base
( no serialization code here)
* file : DerivatedSerilization.hxx which contains the definition of the
non intrusive template function serialize ( no macro BOOST_CLASS_EXPORT
here )
** #include "lib1/BaseSerilization.hxx"
** in fonction serialize .... use of base_object< lib1::Base >
* file DerivatedInstanciation.cpp which explicit instanciate the
previous function with a fixed Archive class, this file also contain the
macro BOOST_CLASS_EXPORT(Derivated)

a program using these 2 libraries raise an assertion
file serialization/extended_type_info.cpp line 74. Indeed the macro
BOOST_CLASS_EXPORT(Base) register the extended_type_info of Base. the
macro BOOST_CLASS_EXPORT(Derivated) register the extended_type_info of
Base *and* the void_caster register in serialize(... Derivated ...)
register *again* Base class raising the assertion.

So I have some questions

1. Is my design correct ? My programme work fine (Linux&Windows) in
release mode.

2. why forbides multi-registration of the same extended_type_info ?

3. what is the interest using std::multiset for unique element instead
std::set for tkmap::m_map type ?

Regards,

Vincent Agnus


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