Original Post
I'm trying to make a resource manager which would take care of loading all of the loadable game objects i'm using such as images, sounds and 3d models. Now i want to have all of these share some properties so i'm going to make them inherit a resource base class:
class VResource
{
public:
VResource();
string GetName() { return FileName; }
string SetName(string name) { FileName = name; }
unsigned GetReferenceCount() { return ReferenceCount; }
void IncrementCount() { ReferenceCount++; }
void DecrementCount() { ReferenceCount--; }
virtual void Destroy() = 0;
virtual void LoadFromFile(string fname) = 0;
private:
string FileName;
unsigned ReferenceCount; //this should be incremented for every load, and decremented for every destroy
};
Now the resource manager should load any type of resource which inherits this base class. I've thought of having the resource manager call the LoadFromFile function of each resource but since it doesn't know what type of resource this is it can't cast it to the right type of class. How do you think it should it be designed?