I have a header file with about 400 function declarations and its corresponding source file with the definitions.
In order to replace the implementation with a mock at runtime, I want to replace the implementation with calls to an object that will contain the implementation instead (pointer to implementation - pImpl).
This means I will have the following files:
- mainFile.h - contains the method declarations as before (must remain as I cannot replace the interface with the client code)
- IImpl.h - Abstract base (interface) for the implementation object
- mainFile.cpp - Will contain method definitions where all it does it call the corresponding method on IImpl*
- SpecificImpl.cpp - Contains the declaration and definition of the specific implementation
- MockImpl.cpp - Contains the declaration and definition of the implementation used during testing
The main problem with this is the duplication of the 400 method declarations which appear in the main header file and again in each class definition.
Is there any way I can avoid this duplication? I was trying with macros, but then the order of the includes became too specific...