\r
// globally disable restoring or saving the persistent properties (both are\r
// enabled by default)\r
- bool DisableSaving() { m_doSave = false; }\r
- bool DisableRestoring() { m_doRestore = false; }\r
+ void DisableSaving() { m_doSave = false; }\r
+ void DisableRestoring() { m_doRestore = false; }\r
\r
\r
// register an object with the manager: when using the first overload,\r
\r
// methods used by the persistent objects to save and restore the data\r
//\r
- // currently these methods simply use wxConfig::Get()\r
- //\r
- // TODO: make this customizable by allowing\r
- // (a) specifying custom wxConfig object to use\r
- // (b) allowing to use something else entirely\r
- template <typename T>\r
- bool\r
- SaveValue(const wxPersistentObject& who, const wxString& name, T value)\r
- {\r
- wxConfigBase * const conf = GetConfig();\r
- if ( !conf )\r
- return false;\r
-\r
- return conf->Write(GetKey(who, name), value);\r
- }\r
-\r
- template <typename T>\r
- bool\r
- RestoreValue(const wxPersistentObject& who, const wxString& name, T *value)\r
- {\r
- wxConfigBase * const conf = GetConfig();\r
- if ( !conf )\r
- return false;\r
-\r
- return conf->Read(GetKey(who, name), value);\r
- }\r
+ // currently these methods simply use wxConfig::Get() but they may be\r
+ // overridden in the derived class (once we allow creating custom\r
+ // persistent managers)\r
+#define wxPERSIST_DECLARE_SAVE_RESTORE_FOR(Type) \\r
+ virtual bool SaveValue(const wxPersistentObject& who, \\r
+ const wxString& name, \\r
+ Type value); \\r
+ \\r
+ virtual bool \\r
+ RestoreValue(const wxPersistentObject& who, \\r
+ const wxString& name, \\r
+ Type *value)\r
+\r
+ wxPERSIST_DECLARE_SAVE_RESTORE_FOR(bool);\r
+ wxPERSIST_DECLARE_SAVE_RESTORE_FOR(int);\r
+ wxPERSIST_DECLARE_SAVE_RESTORE_FOR(long);\r
+ wxPERSIST_DECLARE_SAVE_RESTORE_FOR(wxString);\r
+\r
+#undef wxPERSIST_DECLARE_SAVE_RESTORE_FOR\r
\r
private:\r
// ctor is private, use Get()\r
m_doRestore = true;\r
}\r
\r
- // helpers of Save/Restore(), will be customized later\r
+ // helpers of Save/Restore()\r
+ //\r
+ // TODO: make this customizable by allowing\r
+ // (a) specifying custom wxConfig object to use\r
+ // (b) allowing to use something else entirely\r
wxConfigBase *GetConfig() const { return wxConfigBase::Get(); }\r
wxString GetKey(const wxPersistentObject& who, const wxString& name) const;\r
\r