|
|
SerializationException Safety |
The load function traps any exceptions that occur between the time an object is created and its pointer is stored. Should an exception occur while reading an archive, the created object is deleted and the de-serialized pointer is set to NULL. This ensures that there are no memory leaks. The fact that there are no other copies of this pointer ensures that no pointers are left invalid. The object's destructor should be able to delete any other existing objects in the normal manner without problem. test_delete_pointer.cpp illustrates this case.
try/catch block.
delete_created_pointers() to delete any pointers
created by the class load. Without out other action, objects created in
this way would end up as memory leaks as they are not considered owned
pointers and hence aren't destroyed.
boost::shared_ptr.
The library includes serialization of boost::shared_ptr. As
previously mentioned, this required a tiny alteration in one of the
boost::shared_ptr implementation files in order to permit
access by the serialization system.
Revised 24 January, 2004
© Copyright Robert Ramey 2002-2004. All Rights Reserved.