#include <wx/persist.h>
Base class for persistent object adapters.
See Persistent Objects Overview for an overview of persistent objects within wxWidgets.
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. More... | |
virtual | ~wxPersistentObject () |
Trivial but virtual destructor. More... | |
void * | GetObject () const |
Return the associated object. More... | |
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. More... | |
virtual bool | Restore ()=0 |
Restore the object properties. More... | |
virtual wxString | GetKind () const =0 |
Returns the string uniquely identifying the objects supported by this adapter. More... | |
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. More... | |
Protected Member Functions | |
template<typename T > | |
bool | SaveValue (const wxString &name, T value) const |
Save the specified value using the given name. More... | |
template<typename T > | |
bool | RestoreValue (const wxString &name, T *value) |
Restore a value saved by SaveValue(). More... | |
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 >, wxPersistentWindow< wxDataViewCtrl >, wxPersistentWindow< wxComboBox >, 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 wxPersistentDataViewCtrl, wxPersistentTreeBookCtrl, wxPersistentTLW, wxPersistentComboBox, and wxPersistentBookCtrl.
|
protected |
Restore a value saved by SaveValue().
name | The same name as was used by SaveValue(). |
value | Non-NULL pointer to the same type that was passed to SaveValue(). The pointed to object will be filled with the saved value if it was read successfully or not modified otherwise. |
|
pure virtual |
Save the object properties.
The implementation of this method should use SaveValue().
Implemented in wxPersistentDataViewCtrl, wxPersistentTreeBookCtrl, wxPersistentTLW, wxPersistentComboBox, and wxPersistentBookCtrl.
|
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. |