X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fstlplus%2Fpersistence%2Fpersistent_pointer.hpp;fp=src%2Fstlplus%2Fpersistence%2Fpersistent_pointer.hpp;h=02d0951530630131df6343f1573f8f396b36d7a7;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hp=0000000000000000000000000000000000000000;hpb=85783316365181491a3e3c0c63659972477cebba;p=chaz%2Fyoink diff --git a/src/stlplus/persistence/persistent_pointer.hpp b/src/stlplus/persistence/persistent_pointer.hpp new file mode 100644 index 0000000..02d0951 --- /dev/null +++ b/src/stlplus/persistence/persistent_pointer.hpp @@ -0,0 +1,47 @@ +#ifndef STLPLUS_PERSISTENT_POINTER +#define STLPLUS_PERSISTENT_POINTER +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004-2009 +// License: BSD License, see ../docs/license.html + +// Persistence for pointers to persistent objects + +// Warning! The pointer must be a dynamically-allocated type, since the +// implementation uses new/delete + +// Multiple pointers to the same object *will* be restored as multiple pointers +// to the same object. The object is dumped only the first time it is +// encountered along with a "magic key". Subsequent pointers to the same object +// cause only the magic key to be dumped. On restore, the object is only +// restored once and the magic keys are matched up so that the other pointers +// now point to the restored object. + +// Supports null pointers too! If the data field to restore is null and the +// file format non-null, allocates a new T(). If the data field is non-null and +// the file format is null, deletes it and sets it null + +//////////////////////////////////////////////////////////////////////////////// +#include "persistence_fixes.hpp" +#include "persistent_contexts.hpp" + +//////////////////////////////////////////////////////////////////////////////// + +namespace stlplus +{ + + template + void dump_pointer(dump_context&, const T* const data, D dump_fn) + throw(persistent_dump_failed); + + template + void restore_pointer(restore_context&, T*& data, R restore_fn) + throw(persistent_restore_failed); + +} // end namespace stlplus + + //////////////////////////////////////////////////////////////////////////////// +#include "persistent_pointer.tpp" +#endif