1 #ifndef STLPLUS_PERSISTENT_CALLBACK
2 #define STLPLUS_PERSISTENT_CALLBACK
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 polymorphic classes using the callback approach.
12 // This works on a set of classes. Each subclass has a set of callback
13 // (non-method) functions that enable create/dump/restore operations. Each
14 // subclass must be registered with the persistence dump/restore context so
15 // that the system knows how to handle it.
17 // This approach is suited to classes that cannot be modified to add
18 // persistence methods. See persistent_interface for a more C++-like way of
19 // handling polymorphism.
21 // Objects are always dumped/restored as pointers to the superclass T.
23 // Multiple pointers to the same object are handled in the same way as for
26 // Only classes registered with the context can be dumped and restored as
27 // polymorphic types - see dump_context::register_callback and
28 // restore_context::register_callback. Attempting to use any unrecognised class
29 // will throw an exception.
31 ////////////////////////////////////////////////////////////////////////////////
33 #include "persistence_fixes.hpp"
34 #include "persistent_contexts.hpp"
36 ////////////////////////////////////////////////////////////////////////////////
42 void dump_callback(dump_context
&, const T
* const data
)
43 throw(persistent_dump_failed
);
46 void restore_callback(restore_context
&, T
*& data
)
47 throw(persistent_restore_failed
);
49 } // end namespace stlplus
51 ////////////////////////////////////////////////////////////////////////////////
52 #include "persistent_callback.tpp"