mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-22 14:20:35 +08:00
Add wxIMPLEMENT_DYNAMIC_TEMPLATE_SPECIALIZATION()
This will be used in the upcoming commit.
This commit is contained in:
@@ -226,6 +226,25 @@ WXDLLIMPEXP_BASE wxObject *wxCreateDynamicObject(const wxString& name);
|
||||
wxObject* name::wxCreateObject() \
|
||||
{ return new name; }
|
||||
|
||||
// Template specialization with one base class.
|
||||
#define wxIMPLEMENT_DYNAMIC_TEMPLATE_SPECIALIZATION(name, arg, basename) \
|
||||
template <> \
|
||||
wxObject* name<arg>::wxCreateObject() { return new name<arg>; } \
|
||||
template <> \
|
||||
wxClassInfo \
|
||||
name<arg>::ms_classInfo \
|
||||
( \
|
||||
wxT(#name) L"<" wxT(#arg) L">", \
|
||||
&basename::ms_classInfo, \
|
||||
nullptr, \
|
||||
static_cast<int>(sizeof(name<arg>)), \
|
||||
name<arg>::wxCreateObject \
|
||||
); \
|
||||
template <> \
|
||||
wxClassInfo* name<arg>::GetClassInfo() const { return &ms_classInfo; }
|
||||
|
||||
|
||||
|
||||
// -----------------------------------
|
||||
// for abstract classes
|
||||
// -----------------------------------
|
||||
|
||||
@@ -797,6 +797,36 @@ public:
|
||||
*/
|
||||
#define wxIMPLEMENT_DYNAMIC_CLASS2( className, baseClassName1, baseClassName2 )
|
||||
|
||||
/**
|
||||
Used in a C++ implementation file to complete the declaration of a class
|
||||
that has run-time type information, and whose instances can be created
|
||||
dynamically. Use this for template specializations.
|
||||
|
||||
Please note that @a arg must be the template parameter the primary template
|
||||
@a templateName is being specialized for, e.g.
|
||||
|
||||
@code
|
||||
template <typename T>
|
||||
class MyWindow : public wxWindow
|
||||
{
|
||||
public:
|
||||
MyWindow() = default; // Must have a default ctor for dynamic creation.
|
||||
|
||||
private:
|
||||
T m_value;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(MyWindow);
|
||||
};
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_TEMPLATE_SPECIALIZATION(MyWindow, int, wxWindow);
|
||||
@endcode
|
||||
|
||||
@header{wx/object.h}
|
||||
|
||||
@since 3.3.2
|
||||
*/
|
||||
#define wxIMPLEMENT_DYNAMIC_TEMPLATE_SPECIALIZATION( templateName, arg, baseClassName )
|
||||
|
||||
/**
|
||||
Synonym for wxIMPLEMENT_ABSTRACT_CLASS().
|
||||
|
||||
|
||||
Reference in New Issue
Block a user