Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost Serialization calling a customserialize method
From: Pooyan Dadvand (pooyan_at_[hidden])
Date: 2010-08-25 09:12:42


First of all thank you for your kind suggestion. I completely agree
about suggested methodology for optimizing. (Indeed this is the
methodology I use in my work) However here my concern is the performance
in normal use of container and not in seriliaztion and optimizing the
serialization will be a secondary objective.

What I need to know is how to call a MyCostumSerialize method of my
derive object with an additional parameter via a pointer to the base class:

Class VariableData{
     std::size_t m_Key;

     template<class TArchiveType>
     MyCostumSerialize(TArchiveType&rArchive, const unsigned int Version, void* pValue) {}


template<class TDataType>
class Veriable : public VariableData {

     template<class TArchiveType>
     MyCostumSerialize(TArchiveType&rArchive, const unsigned int Version, void* pValue)
         rArchive& static_cast<TDataType *>(pVAlue);


Let say I don't how to call the MyCostumSerialize method of "Variable"
class above when I have a "VariableData*" pointer in my container:

std::vector<std::pair<const VariableData*, void*> >




Dr. Pooyan Dadvand
International Center for Numerical Methods in Engineering - CIMNE
Campus Norte, Edificio C1
c/ Gran Capitán s/n
08034 Barcelona, Spain
Tel: (+34) 93 401 56 96
Fax: (+34) 93 401 65 17
web: < <>>

*Los datos de carácter personal contenidos en el mensaje, se registrarán
en un fichero para facilitar la gestión de las comunicaciones de CIMNE.
Se pueden ejercitar los derechos de acceso, rectificación, cancelación y
oposición por escrito, dirigiéndose a nuestras oficinas de CIMNE, Gran
Capitán s/n, Edificio C1 - Campus Norte UPC, 08034 Barcelona, España.

*Les dades de caràcter personal contingudes en aquest missatge es
registraran en un fitxer per facilitar la gestió de les comunicacions
del CIMNE. Es poden exercir els drets d'accés, rectificació,
cancel·lació i oposició, per escrit a les nostres oficines del CIMNE,
Gran Capità s/n, Edifici C1, Campus Nord UPC, 08034 Barcelona, Espanya.

*All personal data contained in this mail will be processed
confidentially and stored in a file property of CIMNE in order to manage
corporate communications. You may exercise the right of access,
rectification, deletion and objection by letter sent to CIMNE, Gran
Capitán, Edificio C1 - Campus Norte UPC, 08034 Barcelona, Spain.

On 08/20/2010 06:57 PM, Robert Ramey wrote:
>> Consider that the data.first is a pointer to the base class and I
>> want to call the serialize of the derived class which is not virtual
>>> which still looks like a bad idea to me. But it might be what you
>>> want.
>> Really I'm not aware of a storage mechanism for a heterogeneous
>> container without using virtual functions in time of accessing data
>> which means less performace for us. In this sudo code the accessing
>> mechanism is not menssioned but it is fast and typesafe (it can be
>> seen here
>> Of course any suggestion will be very welcome!!
> First of all - focusing on this aspect of performance at this stage in
> development is a bad idea. Try the following:
> a) Make your container interface.
> b) Implement it using the the easiest method
> c) Make a test program for it
> d) Profile it
> e) Enhance the implementation to improve performance bottlenecks.
> That is the fastest way to make the fastest code.
> To do this (e), you need to know more about how the serialization library
> works internally. Most of this is available in the documentation - but it
> would also require investment of effort in studying some of the dozens of
> examples and tests included with the library. The serialization library
> only uses virtual types for a couple of special types inside the library
> implemenation. Even re-constitution of virtual types created by the user
> don't use any calls to virtual functions. This should be apparent from study
> of the document tests and examples.
> Also, for a heterogenous container, you might look at several approaches.
> One is a container of boost.variant or boost.any. The former doesn't use
> virtual functions at all.
> Study of all of this seems like a lot of work - and it is. But ultimately it
> will be faster and give a better result than trying to speculate on an
> optimal solution and then trying to make the serialization library fit it.
> The easiest and best way to make a 12 inch telescope lens is to make a 2
> inch one first.
> Robert Ramey
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at