attempt to fix DLL samples link with VC6 which has trouble instantiating template methods of dll-exported classes apparently
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58575 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -108,32 +108,25 @@ public:
|
|||||||
|
|
||||||
// methods used by the persistent objects to save and restore the data
|
// methods used by the persistent objects to save and restore the data
|
||||||
//
|
//
|
||||||
// currently these methods simply use wxConfig::Get()
|
// currently these methods simply use wxConfig::Get() but they may be
|
||||||
//
|
// overridden in the derived class (once we allow creating custom
|
||||||
// TODO: make this customizable by allowing
|
// persistent managers)
|
||||||
// (a) specifying custom wxConfig object to use
|
#define wxPERSIST_DECLARE_SAVE_RESTORE_FOR(Type) \
|
||||||
// (b) allowing to use something else entirely
|
virtual bool SaveValue(const wxPersistentObject& who, \
|
||||||
template <typename T>
|
const wxString& name, \
|
||||||
bool
|
Type value); \
|
||||||
SaveValue(const wxPersistentObject& who, const wxString& name, T value)
|
\
|
||||||
{
|
virtual bool \
|
||||||
wxConfigBase * const conf = GetConfig();
|
RestoreValue(const wxPersistentObject& who, \
|
||||||
if ( !conf )
|
const wxString& name, \
|
||||||
return false;
|
Type *value)
|
||||||
|
|
||||||
return conf->Write(GetKey(who, name), value);
|
wxPERSIST_DECLARE_SAVE_RESTORE_FOR(bool);
|
||||||
}
|
wxPERSIST_DECLARE_SAVE_RESTORE_FOR(int);
|
||||||
|
wxPERSIST_DECLARE_SAVE_RESTORE_FOR(long);
|
||||||
|
wxPERSIST_DECLARE_SAVE_RESTORE_FOR(wxString);
|
||||||
|
|
||||||
template <typename T>
|
#undef wxPERSIST_DECLARE_SAVE_RESTORE_FOR
|
||||||
bool
|
|
||||||
RestoreValue(const wxPersistentObject& who, const wxString& name, T *value)
|
|
||||||
{
|
|
||||||
wxConfigBase * const conf = GetConfig();
|
|
||||||
if ( !conf )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return conf->Read(GetKey(who, name), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ctor is private, use Get()
|
// ctor is private, use Get()
|
||||||
@@ -143,7 +136,11 @@ private:
|
|||||||
m_doRestore = true;
|
m_doRestore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// helpers of Save/Restore(), will be customized later
|
// helpers of Save/Restore()
|
||||||
|
//
|
||||||
|
// TODO: make this customizable by allowing
|
||||||
|
// (a) specifying custom wxConfig object to use
|
||||||
|
// (b) allowing to use something else entirely
|
||||||
wxConfigBase *GetConfig() const { return wxConfigBase::Get(); }
|
wxConfigBase *GetConfig() const { return wxConfigBase::Get(); }
|
||||||
wxString GetKey(const wxPersistentObject& who, const wxString& name) const;
|
wxString GetKey(const wxPersistentObject& who, const wxString& name) const;
|
||||||
|
|
||||||
|
@@ -107,3 +107,43 @@ bool wxPersistenceManager::Restore(void *obj)
|
|||||||
return it->second->Restore();
|
return it->second->Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline bool
|
||||||
|
DoSaveValue(wxConfigBase *conf, const wxString& key, T value)
|
||||||
|
{
|
||||||
|
return conf && conf->Write(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
bool
|
||||||
|
DoRestoreValue(wxConfigBase *conf, const wxString& key, T *value)
|
||||||
|
{
|
||||||
|
return conf && conf->Read(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
#define wxPERSIST_DEFINE_SAVE_RESTORE_FOR(Type) \
|
||||||
|
bool wxPersistenceManager::SaveValue(const wxPersistentObject& who, \
|
||||||
|
const wxString& name, \
|
||||||
|
Type value) \
|
||||||
|
{ \
|
||||||
|
return DoSaveValue(GetConfig(), GetKey(who, name), value); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
bool wxPersistenceManager::RestoreValue(const wxPersistentObject& who, \
|
||||||
|
const wxString& name, \
|
||||||
|
Type *value) \
|
||||||
|
{ \
|
||||||
|
return DoRestoreValue(GetConfig(), GetKey(who, name), value); \
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPERSIST_DEFINE_SAVE_RESTORE_FOR(bool)
|
||||||
|
wxPERSIST_DEFINE_SAVE_RESTORE_FOR(int)
|
||||||
|
wxPERSIST_DEFINE_SAVE_RESTORE_FOR(long)
|
||||||
|
wxPERSIST_DEFINE_SAVE_RESTORE_FOR(wxString)
|
||||||
|
|
||||||
|
#undef wxPERSIST_DEFINE_SAVE_RESTORE_FOR
|
||||||
|
Reference in New Issue
Block a user