Serialization and BGL
Hello, I was wondering if one could use Boost serialization library with the Boost Graph Library. Specifically, if one my class holds a graph (for example, an adjacency_list class), is it possible to serialize it? From what I've read from the Boost serialization documentation, this doesn't seem possible as it eventually requires access to the class members; in the case of the BGL, the implementation of the classes is probably so complex that I wouldn't go through that route; plus, they may very well be private. I was wondering if there is any way to do serialization via the public interface of the BGL (ie, add_edge, etc...) ? If I understood the Serialization library correctly, everything works via the operator & which acts as >> and <<. If I define a << operator for the BGL classes, that implement the export / import operations, needed, would it be possible to use the BGL with serialization? Any help from knowledgeable people would be appreciated (I now have a quite good knowledge of the BGL but I am new to the serialization library). Jean-Noël
The serialization library is designed to make the possible - and hopefully easy - without modification of the BGL library. This depends on the BGL library exposing enough information in order to save and load back the state of the objects it uses. I can't know that it does this. Note that serialization is implemented totally non-intrusively for all std collections, variant and now shared_ptr. So what you want to do should be possible. Robert Ramey Jean-Noël Rivasseau wrote:
Hello,
I was wondering if one could use Boost serialization library with the Boost Graph Library. Specifically, if one my class holds a graph (for example, an adjacency_list class), is it possible to serialize it? From what I've read from the Boost serialization documentation, this doesn't seem possible as it eventually requires access to the class members; in the case of the BGL, the implementation of the classes is probably so complex that I wouldn't go through that route; plus, they may very well be private.
I was wondering if there is any way to do serialization via the public interface of the BGL (ie, add_edge, etc...) ? If I understood the Serialization library correctly, everything works via the operator & which acts as >> and <<. If I define a << operator for the BGL classes, that implement the export / import operations, needed, would it be possible to use the BGL with serialization?
Any help from knowledgeable people would be appreciated (I now have a quite good knowledge of the BGL but I am new to the serialization library).
Jean-Noël
On Jun 17, 2005, at 10:47 AM, Robert Ramey wrote:
The serialization library is designed to make the possible - and hopefully easy - without modification of the BGL library. This depends on the BGL library exposing enough information in order to save and load back the state of the objects it uses. I can't know that it does this. Note that serialization is implemented totally non-intrusively for all std collections, variant and now shared_ptr. So what you want to do should be possible.
The BGL graph types do expose enough information for serialization. One only needs access to the vertices, edges, and properties of the graph to serialize it. We would love to make the BGL serializable (it's been on by TODO list for ages), but it has never percolated to the top of the stack. Of course, we'd be happy to review and integrate any patches to make the BGL graph types serializable. Doug
If you want to make the BGL serializable, how would you proceed? Intrusively, meaning writing the serialize function as a class member, or non intrusively ? You are saying that "One only needs access to the vertices, edges, and properties of the graph to serialize it." However, that doesn't seem easy to get access to these vertices, since it would maybe mean looking at the implementation details for a *long* time. Do you think I could write the serialization patches in a reasonable amount of time? If you think so, I could give it a try, with some intial help. Jean-Noël Also, I didn't get a reply to my question about the >> and << operator, and if possible, I'd like to understand that.
On Jun 17, 2005, at 10:47 AM, Robert Ramey wrote:
The serialization library is designed to make the possible - and hopefully easy - without modification of the BGL library. This depends on the BGL library exposing enough information in order to save and load back the state of the objects it uses. I can't know that it does this. Note that serialization is implemented totally non-intrusively for all std collections, variant and now shared_ptr. So what you want to do should be possible.
The BGL graph types do expose enough information for serialization. One only needs access to the vertices, edges, and properties of the graph to serialize it. We would love to make the BGL serializable (it's been on by TODO list for ages), but it has never percolated to the top of the stack. Of course, we'd be happy to review and integrate any patches to make the BGL graph types serializable.
Doug
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On Fri, 17 Jun 2005 12:46:04 -0700, Jean-Noël Rivasseau wrote
If you want to make the BGL serializable, how would you proceed? Intrusively, meaning writing the serialize function as a class member, or non intrusively ? You are saying that "One only needs access to the vertices, edges, and properties of the graph to serialize it." However, that doesn't seem easy to get access to these vertices, since it would maybe mean looking at the implementation details for a *long* time. Do you think I could write the serialization patches in a reasonable amount of time? If you think so, I could give it a try, with some intial help.
You could look at some other boost examples for some help. Here's a link to the date-time serilization code. It is non-intrusive -- only using the public interface of the various types it serializes such as gregorian::date: http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/date_time/gregorian/greg_serialize.hpp?rev=1.7&view=markup http://tinyurl.com/bnexk or the multi_index code -- maybe more like BGL b/c it is a collection http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/multi_index/detail/index_saver.hpp?rev=1.3&view=auto http://tinyurl.com/9rp6y HTH, Jeff
participants (4)
-
Doug Gregor
-
Jean-Noël Rivasseau
-
Jeff Garland
-
Robert Ramey