You could define an abstract, non-templated interface for your TextureManagerType
, and use that to refer to the texture manager implementation from texture manager singleton object.
In order to do that, you also need a polymorphic representation for your Texture objects, which could be something as simple as a union type, or an abstract base class, with derived classes for different concrete texture types.
It may all look something like this:
union TextureContainer {
OpenGLTexture* oglt;
DirectXTexture* dxt;
};
class TextureManagerTypeBase
{
public:
virtual ~TextureManagerType() = 0;
virtual TextureContainer GetTexture(TEXTURE_ID texID) = 0;
virtual TextureContainer LoadTexture(const std::string& texturePath) = 0;
//this looks like it only refers to other public
// methods, so it's staying here
virtual bool Load(const std::string& texturePaths)
{
...
}
};
template <typename T>
class TextureManagerType : public TextureManagerTypeBase
{
public:
// pretty much the same as before
// minus Load wich is defined in the base class
// plus wrapping T into a TextureContainer
...
};
//Uncopyable is a base class with a disabled copy constructor
class TextureManager : public Uncopyable
{
private:
TheTextureManager();
public:
//T here is underlined in all three mentions as it is undefined
static TextureManagerTypeBase* Instance()
{
return m_pInstance;
}
static void SetDynamicType(TextureManagerTypeBase* type)
{
m_pInstance = type;
}
static TextureManagerTypeBase* m_pInstance;
};
That's a bit rough, but hopefully you get the idea.