#include <wx/persist.h>
Base class for persistent object adapters.
wxWidgets persistence framework is non-intrusive, i.e. can work with the classes which have no relationship to nor knowledge of it. To allow this, an intermediate persistence adapter is used: this is just a simple object which provides the methods used by wxPersistenceManager to save and restore the object properties and implements them using the concrete class methods.
You may derive your own classes from wxPersistentObject to implement persistence support for your common classes, see Defining Custom Persistent Windows.
Public Member Functions | |
wxPersistentObject (void *obj) | |
Constructor takes the object which we're associated with. | |
virtual | ~wxPersistentObject () |
Trivial but virtual destructor. | |
void * | GetObject () const |
Return the associated object. | |
Methods to be implemented in the derived classes. | |
Notice that these methods are only used by wxPersistenceManager normally and shouldn't be called directly. | |
virtual void | Save () const =0 |
Save the object properties. | |
virtual bool | Restore ()=0 |
Restore the object properties. | |
virtual wxString | GetKind () const =0 |
Returns the string uniquely identifying the objects supported by this adapter. | |
virtual wxString | GetName () const =0 |
Returns the string uniquely identifying the object we're associated with among all the other objects of the same type. | |
Protected Member Functions | |
template<typename T > | |
bool | SaveValue (const wxString &name, T value) const |
Save the specified value using the given name. | |
template<typename T > | |
bool | RestoreValue (const wxString &name, T *value) |
Restore the value saved by Save(). | |
wxPersistentObject::wxPersistentObject | ( | void * | obj | ) |
Constructor takes the object which we're associated with.
This object must have life-time greater than ours as we keep a pointer to it.
|
virtual |
Trivial but virtual destructor.
|
pure virtual |
Returns the string uniquely identifying the objects supported by this adapter.
This method is called from SaveValue() and RestoreValue() and normally returns some short (but not too cryptic) strings, e.g. "Checkbox"
.
|
pure virtual |
Returns the string uniquely identifying the object we're associated with among all the other objects of the same type.
This method is used together with GetKind() to construct the unique full name of the object in e.g. a configuration file.
Implemented in wxPersistentWindow< T >, wxPersistentWindow< wxBookCtrlBase >, and wxPersistentWindow< wxTopLevelWindow >.
void* wxPersistentObject::GetObject | ( | ) | const |
Return the associated object.
|
pure virtual |
Restore the object properties.
The implementation of this method should use RestoreValue().
Implemented in wxPersistentBookCtrl, wxPersistentTreeBookCtrl, and wxPersistentTLW.
|
protected |
Restore the value saved by Save().
name | The same name as was used by Save(). |
value | Non-NULL pointer which will be filled with the value if it was read successfully or not modified if it wasn't. |
|
pure virtual |
Save the object properties.
The implementation of this method should use SaveValue().
Implemented in wxPersistentBookCtrl, wxPersistentTLW, and wxPersistentTreeBookCtrl.
|
protected |
Save the specified value using the given name.
name | The name of the value in the configuration file. |
value | The value to save, currently must be a type supported by wxConfig. |