persistence/persistent_xref.hpp
1: #ifndef STLPLUS_PERSISTENT_XREF
2: #define STLPLUS_PERSISTENT_XREF
3: ////////////////////////////////////////////////////////////////////////////////
4:
5: // Author: Andy Rushton
6: // Copyright: (c) Andy Rushton, 2007
7: // License: BSD License, see ../docs/license.html
8:
9: // Persistence for cross-references to persistent objects
10:
11: // A cross-reference is a pointer to an object that has definitely been dumped
12: // already by one of dump_pointer, dump_interface or dump_callback, i.e. by
13: // one of the dump routines for pointers to objects.
14:
15: // These are typically used in data structures as back-pointers or pointers
16: // between nodes.
17:
18: // For example, you may have a tree with cross links. Dump the tree as the
19: // primary data structure first, then dump the cross links as cross-references
20: // afterwards. The whole tree must be dumped before any cross-references to
21: // ensure that all cross-references are known to the persistence system.
22:
23: // These functions will throw an exception if the cross-reference points to
24: // something not dumped before.
25:
26: ////////////////////////////////////////////////////////////////////////////////
27: #include "persistence_fixes.hpp"
28: #include "persistent_contexts.hpp"
29:
30: ////////////////////////////////////////////////////////////////////////////////
31:
32: namespace stlplus
33: {
34:
35: template<typename T>
36: void dump_xref(dump_context&, const T* const data)
37: throw(persistent_dump_failed);
38:
39: template<typename T>
40: void restore_xref(restore_context&, T*& data)
41: throw(persistent_restore_failed);
42:
43: } // end namespace stlplus
44:
45: ////////////////////////////////////////////////////////////////////////////////
46: #include "persistent_xref.tpp"
47: #endif