Original Post
Hello all! I have developed a GLTextureManager in the hope to make my engine API independent. The GLTextureManager inherites from TextureManager which inherites from ResourceManager. But now I have encountered a problem. I can't simply contruct the manager as I wanted: TextureManager tm = new GLTextureManager(); I must do: TextureManager tm = new GLTextureManager(); I must create some kind of GenericObjectCreater: ( I just came up with this. Not tested and no documentation. ) I would use it now like this: That doesn't look so great and I don't even know if that works. Do you guys have any other Ideas? Please help me! Thank you very much. :D Riddle Here the manager class hirachy: PS.: I just come up witht that I could remove the gneric param. from the TextureManager and the GLTextureManager simply returns Texture objects. [Edited by - Riddle on January 24, 2005 8:15:36 AM]
public static class ObjectCreator<Type>
{
public delegate Type Creater();
private static Creator _creator;
public static Creator CreatorDelegate
{
get{ return _creator; }
set{ _creator = value; }
}
public static Type Create()
{
return _creator();
}
}
Type t = GetTextureType();
TextureManager<t> tm = ObjectCreator<t>.Create();
public abstract class ResourceManager<Type> where Type : Resource
{
}
public abstract class Resource
{
}
public abstract class TextureManager<Type> : ResourceManager<Type> where Type : Texture
{
}
public abstract class Texture : Resource
{
}
public class GLTextureManager : TextureManager<GLTexture>
{
}
public class GLTexture : Texture
{
}