The question may be hard to understand but the problem is quite simple and I will describe it here in simple words.
Right now, my resource managment is:
cResMgr<cTexture> textures;
cResMgr<cSound> sounds;
What I want to do is:
cResMgr resources;
resources.add<cTexture>(...);
resources.get<cSound>(...);
Basically, my resource manager has “get” and “add” functions. I want it that when I call function for cWhatever type first time, it creates a container for it. When it is called for the next times, it is just is there (it’s similar to static variable in function)
The question is, how can I implement it? The only solution I can think of is to have every resource deriving from empty base class cResource, so that way I can have one container of pointers to cResource. The problem is, that the resource types aren’t mine (they are from external lib)
Any solutions?
I don’t really know why you wouldn’t just use different resourcemanagers per resource type.
Also, if it’s okay for the collections to be globally static, why do you need an instance of a resource manager?
Anyways, this should do what you describe: