Added wxVariantData::Clone and wxVariant::Unshare

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49246 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2007-10-19 15:01:54 +00:00
parent b0d7707bc4
commit c8058a09e5
4 changed files with 82 additions and 11 deletions

View File

@@ -81,6 +81,10 @@ public:
// If it based on wxObject return the ClassInfo.
virtual wxClassInfo* GetValueClassInfo() { return NULL; }
// Implement this to make wxVariant::AllocExcusive work. Returns
// a copy of the data.
virtual wxVariantData* Clone() const { return NULL; }
void IncRef() { m_count++; }
void DecRef()
{
@@ -104,7 +108,7 @@ private:
* wxVariant can store any kind of data, but has some basic types
* built in.
*/
class WXDLLIMPEXP_FWD_BASE wxVariant;
WX_DECLARE_LIST_WITH_DECL(wxVariant, wxVariantList, class WXDLLIMPEXP_BASE);
@@ -146,6 +150,9 @@ public:
// destroy a reference
void UnRef();
// ensure that the data is exclusive to this variant, and not shared
bool Unshare();
// Make NULL (i.e. delete the data)
void MakeNull();
@@ -365,6 +372,8 @@ public:\
\
virtual wxString GetType() const; \
virtual wxClassInfo* GetValueClassInfo(); \
\
virtual wxVariantData* Clone() const { return new classname##VariantData(m_value); } \
\
protected:\
classname m_value; \
@@ -436,6 +445,9 @@ bool classname##VariantData::Eq(wxVariantData& data) const \
((classname*)(var.IsValueKindOf(&classname::ms_classInfo) ?\
var.GetWxObjectPtr() : NULL));
// Replacement for using wxDynamicCast on a wxVariantData object
#define wxDynamicCastVariantData(data, classname) dynamic_cast<classname*>(data)
extern wxVariant WXDLLIMPEXP_BASE wxNullVariant;
#endif // wxUSE_VARIANT