Game Resource Management

Game Resource Manager

  • Sound understanding C++, pointer, and template.
  • basic understanding of std::vector and std::map. 

Depending on your level of programming in C++ this tutorial maybe easy or hard to comprehend. I will try to explain things in a way that is simple to understand. Note that the resource manager here uses C++ template. If you don’t know what a template is in C++, it is highly recommend that you review and understand it before you read this article. This is a general-purpose resource manager; C++ templates will allow us to use the same class to create many different resource-manager to manage different objects of different type. The core resource manager will be used to create manage resource managers automatically, and manage them. 

@Note ds::dlist is my own custom linked list. std::vector can be used instead. 
@Note ds::astring is my own custom string. std::string can be used instead.


What is a Game Resource Manager? A game resource manager manages objects in the fallowing way. Adding a resource to its list, removing a resource from its list, deleting a resource from its list, creating and loading a resource to its list. Every resource in its list should be unique and has only one of it. It keeps track of how many copies of a resource are being used. When the number of a resource being use drop to zero the resource is then deleted. If the list containing resources size is zero that list is deleted. For this implementation of a resource manager, there are 5 main classes to the whole system. 
  1. Manager - the manager class is used to destroy a manager.
  2. Resource - a data structure use as a container for an asset and its name. This binds a name to an asset. Each resource must have a unique name so that the correct asset can be fetch when queried.
  3. ResLoader - are used to load a specific resource into the manager it is attached to. The ResourceLoader is the only class leave for the programmer to implement. Loaders are added to ResourceManagers so that a manager can load a specific file. One ResourceManager can contain multiple loaders, giving it the capability to load multiple files.
  4. ResMgr - ResourceManagers is the class that manages the Resources and Loaders.
  5. CoreResMgr - CoreResourceManagers will contain and manage all the ResourceManagers ever create in a program lifetime. CoreResourceManagers is use to create new ResourceManager automatically and retrieve ResourceManager. 
Included Article Links: