Boost logo

Boost Users :

Subject: Re: [Boost-users] boost transfer pointers by serialize
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-08-29 14:27:57


Jack Bryan wrote:
> Thanks
>
>
> Is the m_sd a pointer that points to a double variable ?

no

>
>
> How to refer to the values pointed by m_sd ?

if you use BOOST_SERIALIZE_STRONG_TYPEDEF then
the serializable_double can be handled exactly like a double.
(note: this is the way it is for integer types. As I write this
I'm not sure it applies to floating point types but I think it does.

think of strong typedef as the same as a typedef except that
it actually creates a new identifiable type.

> For example, I transfer myClass from process 1 to process 2 :
>
>
> In process 1, I declear
>
>
> myClass
> {
> serializable_double m_sd;
>
>
> serializable_int m_sint;
>
>
> template<class Archive>
> void serialize(Archive &ar, const unsigned int version){
> ar & m_sd & m_sint;;
> }
> } myObject;
>

so far so good.

> In process 1 , I use
>
>
> world.isend(destRank, downStreamTaskTag, myObject);
>
>
> In process 2, I use
>
>
> world.recv(sourceRank, downStreamTaskTag, myObjectRecv);
>
>
> How to refer to the values pointed by m_sd in myClass ?

just like you would doubles.

>
>
> May I use it in this way ?
>
>
> *(myObjectRecv.m_sd) ;

you could.

> If myObjectRecv.m_sd is an address of a primitive variable,
> the address should be in process 1's memory space.
>
>
> How does the process 2 can modify the value of the variable
> pointed by a pointer with address in process 1's memory space ?

no it will be in the address space of the process that does
the de-serialization.

>
> I can use the similar way to do it for pointer's pointer ?
> such as double** ?

unfortunately, pointers to pointers are not currently serializable.
There is a track item on this. This is an oversight in the implementation
which is non-trivial to fix.

> Any help is appreciated ?

it is?

Robert Ramey



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