Hi, im not really sure what the name of the thing im trying to do is, but basically I want to be able to have some overall object manager that creates other objects according to some global flag.
For example:
Manager->Initialize();
Manager->SetAPI(OPEN_GL);
Texture *t = Manager->CreateTexture();
t->LoadBMP("helo.bmp");
Manager->Shutdown();
but this would mean for each creation function I would have to include all the different possible api implementations, and make massive switch functions, like so:
#include <opengl_texture.h>
#include <directx_texture.h>
#include <software_texture.h>
class Manager {
CreateTexture() {
switch (api) {
case OPEN_GL:
return (Texture *) new OpenGL_Texture;
case DIRECTX:
return (Texture *) new DirectX_Texture;
case SOFTWARE:
reutrn (Texture *) new Software_Texture;
}
}
};
So my question basically is, is there a better/nicer way to do this? [so that i dont need to build big switch statements - im using this on a project which will probably use more than 5 different api's, and it would get quite annoying..]
Thanks!
[edited by - aboeing on September 25, 2003 4:23:03 AM]