
Hi, 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; public: template<class TArchiveType> MyCostumSerialize(TArchiveType&rArchive, const unsigned int Version, void* pValue) {} }; template<class TDataType> class Veriable : public VariableData { public: 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*> > Thanks, Pooyan. _______________________________________________________________________________________________________________________________________________________________________________ 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: www.cimne.com <http://www.cimne.com <http://www.cimne.com/>> _______________________________________________________________________________________________________________________________________________________________________________ *AVISO IMPORTANTE *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. *AVÍS IMPORTANT *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. *IMPORTANT NOTICE *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 http://kratos.cimne.upc.es/trac/browser/kratos/kratos/containers/data_value_...)
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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users