X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fstlplus%2Fpersistence%2Fpersistent_interface.hpp;fp=src%2Fstlplus%2Fpersistence%2Fpersistent_interface.hpp;h=366954ce012007214dabbe5a707796a533c44b19;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hp=0000000000000000000000000000000000000000;hpb=85783316365181491a3e3c0c63659972477cebba;p=chaz%2Fyoink diff --git a/src/stlplus/persistence/persistent_interface.hpp b/src/stlplus/persistence/persistent_interface.hpp new file mode 100644 index 0000000..366954c --- /dev/null +++ b/src/stlplus/persistence/persistent_interface.hpp @@ -0,0 +1,54 @@ +#ifndef STLPLUS_PERSISTENT_INTERFACE +#define STLPLUS_PERSISTENT_INTERFACE +//////////////////////////////////////////////////////////////////////////////// + +// 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 polymorphic classes using the interface approach. + +// This works on a set of classes derived from a common superclass called +// persistent which is declared as an interface. Each subclass has a set of +// methods that enable clone/dump/restore operations. Each subclass must be +// registered with the persistence dump/restore context so that the system +// knows how to dump it. + +// This approach is suited to classes that can be modified to add persistence +// methods. See persistent_callback for a non-invasive way of handling +// polymorphism. + +// Objects are always dumped/restored as pointers to the superclass T. + +// Multiple pointers to the same object are handled in the same way as for +// simple pointers + +// Only classes registered with the context can be dumped and restored as +// polymorphic types - see dump_context::register_interface and +// restore_context::register_interface. Attempting to use any unrecognised class +// will throw an exception. + +//////////////////////////////////////////////////////////////////////////////// +#include "persistence_fixes.hpp" +#include "persistent_contexts.hpp" +#include "persistent.hpp" + +//////////////////////////////////////////////////////////////////////////////// + +namespace stlplus +{ + + template + void dump_interface(dump_context&, const T* const data) + throw(persistent_dump_failed); + + template + void restore_interface(restore_context&, T*& data) + throw(persistent_restore_failed); + +} // end namespace stlplus + + //////////////////////////////////////////////////////////////////////////////// +#include "persistent_interface.tpp" +#endif