1 #ifndef STLPLUS_PERSISTENT_POINTER
2 #define STLPLUS_PERSISTENT_POINTER
3 ////////////////////////////////////////////////////////////////////////////////
5 // Author: Andy Rushton
6 // Copyright: (c) Southampton University 1999-2004
7 // (c) Andy Rushton 2004-2009
8 // License: BSD License, see ../docs/license.html
10 // Persistence for pointers to persistent objects
12 // Warning! The pointer must be a dynamically-allocated type, since the
13 // implementation uses new/delete
15 // Multiple pointers to the same object *will* be restored as multiple pointers
16 // to the same object. The object is dumped only the first time it is
17 // encountered along with a "magic key". Subsequent pointers to the same object
18 // cause only the magic key to be dumped. On restore, the object is only
19 // restored once and the magic keys are matched up so that the other pointers
20 // now point to the restored object.
22 // Supports null pointers too! If the data field to restore is null and the
23 // file format non-null, allocates a new T(). If the data field is non-null and
24 // the file format is null, deletes it and sets it null
26 ////////////////////////////////////////////////////////////////////////////////
27 #include "persistence_fixes.hpp"
28 #include "persistent_contexts.hpp"
30 ////////////////////////////////////////////////////////////////////////////////
35 template<typename T
, typename D
>
36 void dump_pointer(dump_context
&, const T
* const data
, D dump_fn
)
37 throw(persistent_dump_failed
);
39 template<typename T
, typename R
>
40 void restore_pointer(restore_context
&, T
*& data
, R restore_fn
)
41 throw(persistent_restore_failed
);
43 } // end namespace stlplus
45 ////////////////////////////////////////////////////////////////////////////////
46 #include "persistent_pointer.tpp"