// Author: Vadim Zeitlin
// RCS-ID: $Id$
// Copyright: (c) 2009 Vadim Zeitlin <vadim@wxwidgets.org>
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
This is a singleton class and its unique instance can be retrieved using
Get() method.
+ @since 2.9.0
+
@library{wxcore}
*/
class wxPersistenceManager
defined for the objects of this class.
*/
template <class T>
- wxPersistentObject *Register(T *obj)
- {
- return Register(obj, wxCreatePersistentObject(obj));
- }
+ wxPersistentObject *Register(T *obj);
/**
Register an object with the manager.
@see SaveAndUnregister()
*/
void Save(void *obj);
-
+
/**
Restore the object properties previously saved by Save().
@true if the value was saved or @false if an error occurred.
*/
template <typename T>
- bool SaveValue(const wxString& name, T value) const
- {
- return wxPersistenceManager::Get().SaveValue(*this, name, value);
- }
+ bool SaveValue(const wxString& name, T value) const;
/**
Restore the value saved by Save().
found or an error occurred.
*/
template <typename T>
- bool RestoreValue(const wxString& name, T *value)
- {
- return wxPersistenceManager::Get().RestoreValue(*this, name, value);
- }
+ bool RestoreValue(const wxString& name, T *value);
};
/**
framework.
@see @ref persistence_defining
+
+ @header{wx/persist.h}
*/
template <class T>
wxPersistentObject *wxCreatePersistentObject(T *obj);
+
+/**
+ A shorter synonym for wxPersistenceManager::RegisterAndRestore().
+
+ This function simply calls wxPersistenceManager::RegisterAndRestore() but
+ using it results in slightly shorter code as it calls
+ wxPersistenceManager::Get() internally. As an additional convenience, this
+ function can also set the window name.
+
+ For the implementation reasons, this function @em must be used instead of
+ the template method when using Microsoft Visual C++ 6 compiler.
+
+ @param obj wxWindow-derived object to register with persistence manager and
+ to try to restore the settings for.
+ @param name If not empty, @a obj name is changed to the provided value
+ before registering it.
+ @return true if the settings were restored or false otherwise (this will
+ always be the case when the program runs for the first time, for
+ example).
+
+ @since 2.9.0, @a name is new in 2.9.1.
+
+ @header{wx/persist.h}
+ */
+template <class T>
+bool wxPersistentRegisterAndRestore(T *obj, const wxString& name = wxString());