Actually, I would try to make it more generic than this. The simulation class doesn't really need to know about external classes; it simply needs callback function pointers. These could all belong to the same facade class, could be multiple classes, could be standalone C++ functions, could be function objects (each of which implements a single callback method). The simulation shouldn't know or care, if you want to make things as decoupled as possible.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.
But if you have control over both ends of the code (simulation and controller), you can make whatever level of dependence you want. If you are interfacing to a third-party library where you have no ability to change the simulation code, then you are forced to decouple in one of the ways above.
Bookmarks