I am just starting out in large scale C++ software development. I am facing a design issue which I have no idea how to solve. The issue revolves around the following entities: an executable A and 3 libraries Q, W, E. Now, Library Q is on the lowest level meaning W, E, and A make calls into Q (independent/ standalone). In the current workflow, A makes calls into W; W makes calls into E and Q; and E makes calls into Q. The logical and physical dependencies are described below:
A -> W, Q;
W -> E, Q;
E -> Q
Everything was simple and straight forward and one directional until now. I started working on a feature in library 'E' for which I have identified a huge dependency on the executable 'A' itself. Dependency is in the form of processing which is currently done by 'A' and which is a lot.
E -> A
To solve the issue I am referring to Large-Scale C++ Software Design by John Lakos. However, I am unable to apply the techniques mentioned in there related to package circular dependencies (chapter 7) because what I am working with is 95% C code without any components and structure (5% C++). The amount of code which needs to be reorganized break to this dependency is way too much (over a few thousand lines spread across at least 4-5 source files).
One solution that comes to my mind is to create a base class in the library E and a derived class in application A. Use polymorphism to call the function in A from E. I am not sure if I can do this though because 'A' does not call directly into 'E' but through 'W'. However, A does link with E so it should be possible. Another one is to use function pointers to call into A ( which does not seem right).
Question: Is there a good known way to solve such a problem? And of the solutions I have mentioned above are there any hidden catches in implementing either of them? Which one is better? Any help is appreciated. Thanks in advance.