Background
I am working on a platform independent (Linux, macOS and Windows) scientific imaging application which implements various specialist cameras and each of these cameras has a manufacturer provided SDK. I am currently implementing a selection of new cameras that are manufactured by a single company but are branded by other manufactures with separate SDKs.
Aside form minor differences in the SDK function names, the public interfaces are identical. That is to say, everything is the same (function return type and signature etc). The only difference is the start of the function name.
Example of the public interface of the SDKs
int company_1_count_cameras();
bool company_1_init_camera(...);
bool company_1_connect_camera(...);
And:
int company_2_count_cameras();
bool company_2_init_camera(...);
bool company_2_connect_camera(...);
I would like to be able to use one implementation for all the OEM cameras but take into account the function name differences. I have experimented with using function pointers in preprocessor defines and this partly works. So far, I have done the following:
I have placed the following into the include file:
#define FP( func ) company_2 ## func
And in the implementation, I have done:
int count = FP(count());
However, I am unsure of how to do this so that I can compile my project to support all the different cameras. Can anybody offer any suggestions on the best way to achieve this?
Many thanks Amanda