That's the way I have taken until now. Except I have no facade for my simulation class, but just a function pointer directly in the simulation class that is called whenever the application should process its events.
It was when I had to print output from the simulation into a text browser I have in my main window that I ran into problems. Since the text browser is a member of the window class, I can't access it from any function I can access from the simulation class.
I guess a facade will do the job. If I have a facade class for the simulation class, I can derive another class from it in my Qt application, which in turn contains a pointer to the window object. In the simulation class, I store a pointer to a facade object in which I call a virtual function whenever I want to provide the application with output. If the derived facade wants to write to the text browser, it will simply use the window pointer and access the text browser that way. Nice.
Thank you for the help. A facade it will be!
P.S. I like vanilla
Edit: Forget what I said about a virtual function, I just realized that it can't make up for the hidden argument corresponding to the this pointer that has to be provided if it's supposed to be able to access non-static members...
Edit 2: Never mind, I realized it's not the virtual function that is supposed to make up for the this pointer, but the pointer to the facade object that is stored in the simulation class ... a brain fart. :P






Reply With Quote

Bookmarks