I have a data class to be saved and loaded using boost serializer.
The class includes two members En *sender
, En *receiver
to two objects that are already created in my system.
I don't need them to be created again. I just need to send(serialize) their address
, to be used as reference at the other end.
If I use normal pointers like En *sender
, En *receiver
, boost will serialize the entire objects(which I don't want).
So I figured I should use En **sender
, En **receiver
which generates error. May I know how I should modify the class to serve my purpose?
thanks very much.
class dataMessage
{
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive &ar, const unsigned int version)
{
ar & sender;
ar & receiver;
}
//I figured I should user pointer to pointer coz in case of the normal pointer,
//the serilizer would serializes the object that the pointer is pointing to;
//whereas I just need to save the 'pointer' to object so that we
//can use it as a reference at the other end.
En **sender;
En **receiver;
public:
dataMessage(){
sender = receiver = 0;
}
void setDataClassType();
virtual void registerType(boost::archive::text_oarchive &oa)
{
oa.register_type(static_cast<dataMessage *>(NULL));
}
virtual void registerType(boost::archive::text_iarchive &ia)
{
ia.register_type(static_cast<dataMessage *>(NULL));
}
};
part of the error :
error: request for member ‘serialize’ in ‘t’, which is of pointer type ‘En*’ (maybe you meant to use ‘->’ ?)