I have some classes as follows:
- A data manager
- Something that requests modifications to the data
- Various views of the data
The data manager for example might look like this:
Code: Select all
class MyDataManager
{
public:
void Initialise (); // fills the vector with default values
void ChangeData (int position, int value); // allow objects in the same thread as myDataManager direct access
void ChangeData (const wxThreadEventSubclass& customEvent); // allow objects in other threads event based access to data
??? Subscribe (???);
??? Unsubscribe (???);
private:
wxVector data; // data store modified by ChangeData and viewable by subscribers via events
}
So for the classes that want to modify the data...
- Is there such a thing as an event queue? Are there lots of them, for example 1 per wxEvtHandler?
- Should I derive MyDataManager from wxEvtHandler?
- Can I have a wxEvtHandler instance as a member instead of deriving from it? Which is best and why?
- For the thread safe (event) version of ChangeData, which wxEvtHandler should the event get sent to?
- How should I post / queue the event to ChangeData from the class that wants to make a change?
- When to use the event handler belonging to wxTheApp?
- How to use Bind<> inside MyDataManager to register an external class (in a different thread) with MyDataManager?
- Which event handler should MyDataManager post events to to notify subscribed classes of updates? For example do subscribing classes have to be derived from wxEvtHandler with their own handlers (queues?)?
When is it preferable to use wxMessageQueue instead of events?
I appreciate that some of these are answered in the Wiki entry on inter-thread and inter-process communication but I would like to ask them here to get a really thorough understanding.