Refactoring of RemovableDriveManager

1) On Windows and Linux, polling of removable drives is done at a background
   thread, not at a UI thread.
2) On OSX, there is no polling, but a OS notification callback.
3) Refactored for clarity of the RemovableDriveManager interface.
This commit is contained in:
bubnikv
2020-03-06 14:49:21 +01:00
parent fa00180170
commit baad542d15
11 changed files with 640 additions and 753 deletions

View File

@@ -40,11 +40,19 @@ template<class T, size_t N> struct ArrayEvent : public wxEvent
return new ArrayEvent<T, N>(GetEventType(), data, GetEventObject());
}
};
template<class T> struct ArrayEvent<T, 1> : public wxEvent
template<class T> struct Event : public wxEvent
{
T data;
ArrayEvent(wxEventType type, T data, wxObject* origin = nullptr)
Event(wxEventType type, const T &data, wxObject* origin = nullptr)
: wxEvent(0, type), data(std::move(data))
{
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
SetEventObject(origin);
}
Event(wxEventType type, T&& data, wxObject* origin = nullptr)
: wxEvent(0, type), data(std::move(data))
{
m_propagationLevel = wxEVENT_PROPAGATE_MAX;
@@ -53,13 +61,10 @@ template<class T> struct ArrayEvent<T, 1> : public wxEvent
virtual wxEvent* Clone() const
{
return new ArrayEvent<T, 1>(GetEventType(), data, GetEventObject());
return new Event<T>(GetEventType(), data, GetEventObject());
}
};
template <class T> using Event = ArrayEvent<T, 1>;
}
}