Public Member Functions | Static Public Member Functions

# wxPersistenceManager Class Reference

`#include <wx/persist.h>`

## Detailed Description

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.

Since:
  2.9.0

##

Library: wxCore

## 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.

List of all members.

## Member Function Documentation

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.

See also:
  DisableSaving()

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.

See also:
  DisableRestoring()

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.

template<class T >

wxPersistentObject* wxPersistenceManager::Register | ( | T * | obj | ) |

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.

Parameters:

  | obj | The object to register. wxCreatePersistentObject() overload must be defined for the objects of this class.

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.

Parameters:

  | obj | The object to register.
  | po | The wxPersistentObject to use for saving and restoring this object properties.

template<class T >

bool wxPersistenceManager::RegisterAndRestore | ( | T * | obj | ) |

Combines both Register() and Restore() calls.

bool wxPersistenceManager::RegisterAndRestore | ( | void * | obj,
|  | wxPersistentObject * | po |
| ) |  |  |

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.

Parameters:

  | obj | An object previously registered with Register().

Returns:
  true if the object properties were restored or false if nothing was found to restore or the saved settings were invalid.

See also:
  RegisterAndRestore()

void wxPersistenceManager::Save | ( | void * | obj | ) |

Save the object properties to persistent storage.

This method does nothing if DisableSaving() had been called.

Parameters:

  | obj | An object previously registered with Register().

See also:
  SaveAndUnregister()

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.

Parameters:

  | obj | An object previously registered with Register().

|  | [ top ]