Here’s the problem: I’m developing a framework (CLCuda, not the most creative name out there) where the programmer instantiates one object, and depending on what the system supports (CUDA or AMD OpenCL), will use the corresponding methods, without having to change any line of code to that.
I have a abstract class named CLCuda (pure virtual methods, but could be just virtual), and the two classes that implement its methods are CLCudaCUDA and CLCudaOPENCL.
I wanted to have something like this: instantiate one object that will iniciatlizate CUDA or OpenCL, depending on what graphics card the user have, that can access the methods of the available platform (through the class CLCudaCUDA or CLCudaOPENCL).
I already coded the methods of CLCudaOpenCL and CLCudaCUDA (hard times doing that), so my problem is with OOP.
How could I structure my classes?
If anyone can help… thanks very much!
Your problem seems to suggest a “Factory” design pattern. Presumably you have a method to determine which is supported on the current host, so you should leverage that in the implementation of your factory.