#include <wx/persist.h>
Provides support for automatically saving and restoring object properties to persistent storage.
This class is the central element of wxWidgets persistence framework, see Persistent Objects Overview for its overview.
This is a singleton class and its unique instance can be retrieved using Get() method.
Public Member Functions | |
bool | DisableSaving () |
Globally disable saving the persistence object properties. | |
bool | DisableRestoring () |
Globally disable restoring the persistence object properties. | |
template<class T > | |
wxPersistentObject * | Register (T *obj) |
Register an object with the manager automatically creating a persistence adapter for it. | |
wxPersistentObject * | Register (void *obj, wxPersistentObject *po) |
Register an object with the manager. | |
wxPersistentObject * | Find (void *obj) const |
Check if the object is registered and return the associated wxPersistentObject if it is or NULL otherwise. | |
void | Unregister (void *obj) |
Unregister the object and delete the associated wxPersistentObject. | |
void | Save (void *obj) |
Save the object properties to persistent storage. | |
bool | Restore (void *obj) |
Restore the object properties previously saved by Save(). | |
void | SaveAndUnregister (void *obj) |
Combines both Save() and Unregister() calls. | |
template<class T > | |
bool | RegisterAndRestore (T *obj) |
Combines both Register() and Restore() calls. | |
bool | RegisterAndRestore (void *obj, wxPersistentObject *po) |
Combines both Register() and Restore() calls. | |
Static Public Member Functions | |
static wxPersistenceManager & | Get () |
Returns the unique persistence manager object. |
bool wxPersistenceManager::DisableRestoring | ( | ) |
Globally disable restoring the persistence object properties.
By default, restoring properties in Restore() is enabled but this function allows to disable it. This is mostly useful for testing.
bool wxPersistenceManager::DisableSaving | ( | ) |
Globally disable saving the persistence object properties.
By default, saving properties in Save() is enabled but the program may wish to disable if, for example, it detects that it is running on a system which shouldn't be modified in any way and so configuration file (or Windows registry) shouldn't be written to.
wxPersistentObject* wxPersistenceManager::Find | ( | void * | obj | ) | const |
Check if the object is registered and return the associated wxPersistentObject if it is or NULL otherwise.
static wxPersistenceManager& wxPersistenceManager::Get | ( | ) | [static] |
Returns the unique persistence manager object.
wxPersistentObject* wxPersistenceManager::Register | ( | void * | obj, | |
wxPersistentObject * | po | |||
) |
Register an object with the manager.
Note that registering the object doesn't do anything except allowing to call Restore() for it later. If you want to register the object and restore its properties, use RegisterAndRestore().
The manager takes ownership of po and will delete it when it is unregistered.
obj | The object to register. | |
po | The wxPersistentObject to use for saving and restoring this object properties. |
wxPersistentObject* wxPersistenceManager::Register | ( | T * | obj | ) | [inline] |
Register an object with the manager automatically creating a persistence adapter for it.
This is equivalent to calling Register(void *, wxPersistentObject *) with wxCreatePersistentObject(obj) as the second argument.
obj | The object to register. wxCreatePersistentObject() overload must be defined for the objects of this class. |
bool wxPersistenceManager::RegisterAndRestore | ( | void * | obj, | |
wxPersistentObject * | po | |||
) |
Combines both Register() and Restore() calls.
bool wxPersistenceManager::RegisterAndRestore | ( | T * | obj | ) | [inline] |
Combines both Register() and Restore() calls.
bool wxPersistenceManager::Restore | ( | void * | obj | ) |
Restore the object properties previously saved by Save().
This method does nothing if DisableRestoring() had been called.
obj | An object previously registered with Register(). |
void wxPersistenceManager::Save | ( | void * | obj | ) |
Save the object properties to persistent storage.
This method does nothing if DisableSaving() had been called.
obj | An object previously registered with Register(). |
void wxPersistenceManager::SaveAndUnregister | ( | void * | obj | ) |
Combines both Save() and Unregister() calls.
void wxPersistenceManager::Unregister | ( | void * | obj | ) |
Unregister the object and delete the associated wxPersistentObject.
For the persistent windows this is done automatically (via SaveAndUnregister()) when the window is destroyed so you only need to call this function explicitly if you are using custom persistent objects or if you want to prevent the object properties from being saved.
obj | An object previously registered with Register(). |
![]() |
[ top ] |