Boost logo

Boost Users :

From: Matthias Troyer (troyer_at_[hidden])
Date: 2007-05-15 17:22:28


Another, maybe easier option, could be to overload the serialization
functions for std::vector<base *> .

Matthias Troyer

On 16 May 2007, at 01:02, Robert Ramey wrote:

> The code for serialization of a vector is found in serialization/
> vector.hpp.
>
> I implemented this code to reconstuct the vector items rather than
> just reload them. I did this for a number of reasons - which for
> this discussion are not important.
>
> If this doesn't suit your needs, I would suggest you make your own
> version of serialization.hpp which operates differently. Starting
> with the current version it wouldn't be at all hard to do.
>
> If you want to use both current ("standard") method in some
> places in addition to your "custom" method, you might consider
> making some sort of wrapper which tags your special
> vectors with a type which can be distinguished for special
> serialization treatment.
>
> Robert Ramey
>
> Ng Pan wrote:
>> Hi
>>
>> I am using boost serialization to synchronise objects between
>> different computers (network). The objects would be serializated as a
>> string instead of a file by using the class stringstream(instead of
>> fstream). The string would be transferred via TCP/IP layer.
>>
>> Let simpify the situation as only two computers (Master and Slave)
>> ,both of two computers have N objects and I wanna synchronise their
>> content. I create a vector of pointer ( std::vector<base *> m_vpBase
>> ) which points to the dirty objects. Both of two computers have this
>> vector. Let assume the vectors are already pointing to the
>> corresponding objects. For Tx side, it would serialize the objects as
>> a string. For Rx side, I want to update the content of the objects
>> that its vector is pointing to.
>>
>> Tx side:
>> oa << BOOST_SERIALIZATION_NVP(m_vpBase);
>>
>> Rx side:
>> oa >> BOOST_SERIALIZATION_NVP(m_vpBase );
>>
>> However, the above code would construct new objects.
>>
>> What i want is just update the content of the objects , not construct
>> new objects.
>>
>> I know how to update the content for one object by using pointer (
>> base * m_pBase).
>> Tx side:
>> oa << BOOST_SERIALIZATION_NVP(m_pBase);
>>
>> Rx side:
>> oa >> BOOST_SERIALIZATION_NVP(*m_pBase);
>>
>>
>> But, I don't know how to do for a vector of pointer. If you know,
>> please give me some hints. Thank you very much.
>>
>> Regards
>> Barr Ng
>> [I found Boost serialization is useful and easy to use. ]
>>
>> _________________________________________________________________
>> No masks required! Use MSN Messenger to chat with friends and family.
>> http://go.msnserver.com/HK/25382.asp
>
>
>
> _______________________________________________
> 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