C++ Resource Manager
Accomplishments and Techniques:
Created a resoure manager and associated cache holder to quickly load game object resources for a mockup roleplaying game.
Created a custom freelist-style memory allocator to load unique object pointers from the cache.
Created a custom buddy-style memory allocator to load shared object pointers from the cache.
Utilized multi-threading and garbage collection to remove unused objects from the cache.
Used polymorphism to implement and store a family of serializeable game resource classes, including text file objects, weapon data, and player spell inventories.
Implemented thorough exception handling to mitigate loading errors.
Project Overview:
For this project, I created a resource manager system responsible for loading, owning, caching, unloading, and providing access to various game resources for a mock roleplaying game. The resource manager acts as both a loader and cache, which stores objects such as text assets or textures and then provides either shared or unique pointers to objects on request. I created this system as my final submission for a C++ programming course, with th e desire to better understand custom memory allocation.
The below snippet showcases the central ResourceManager class, which acts as an interface for the CachHolder struct. When requesting an object to be loaded, objects will call one of two templated functions contained in the ResourceManager class:
shared_load
unique_load
Shared load returns a shared pointer to the requested object stored in the cache. This pointed object is const and intended to be used for data reading rather than writing (for example, if an object wanted to copy some canned dialogue from a text file). Unique_load returns a unique pointer to a copy of the object stored in the cache. This pointed object can be edited as the requester sees fit (for example, a weapon object could be requested, and later have its damage stats increased).
Language: C++
IDE: Visual Studio 2022
Production Time: 2 weeks
Link To Github: Put github code link here!
Cache Holder:
The CacheHolder struct is responsible for managing access to resources currently being held in memory. These resources are stored in an unordered map in the below format:
std::unorderedmap<std::string, std::pair<timet, std::shared_ptr<const Resource>>>
The CacheHolder has three primary functions:
Freelist Allocator:
For this project, I created a resource manager system responsible for loading, owning, caching, unloading, and providing access to various game assets for a mock roleplaying game. The resource manager acts as both a loader and cache, which stores objects such as text assets or textures and then provides either shared or unique pointer references to objects on request. I created this system as my final submission for a C++ programming course, and am immensely proud of the programming and optimization skills I was able to exhibit!
Here, break down each aspect of the project and explain in detail before displaying the .c main
Buddy Allocator:
For this project, I created a resource manager system responsible for loading, owning, caching, unloading, and providing access to various game assets for a mock roleplaying game. The resource manager acts as both a loader and cache, which stores objects such as text assets or textures and then provides either shared or unique pointer references to objects on request. I created this system as my final submission for a C++ programming course, and am immensely proud of the programming and optimization skills I was able to exhibit!
Here, break down each aspect of the project and explain in detail before displaying the .c main
Resource Classes:
For this project, I created a resource manager system responsible for loading, owning, caching, unloading, and providing access to various game assets for a mock roleplaying game. The resource manager acts as both a loader and cache, which stores objects such as text assets or textures and then provides either shared or unique pointer references to objects on request. I created this system as my final submission for a C++ programming course, and am immensely proud of the programming and optimization skills I was able to exhibit!
Here, break down each aspect of the project and explain in detail before displaying the .c main
Exception Handling:
For this project, I created a resource manager system responsible for loading, owning, caching, unloading, and providing access to various game assets for a mock roleplaying game. The resource manager acts as both a loader and cache, which stores objects such as text assets or textures and then provides either shared or unique pointer references to objects on request. I created this system as my final submission for a C++ programming course, and am immensely proud of the programming and optimization skills I was able to exhibit!
Here, break down each aspect of the project and explain in detail before displaying the .c main
Wrapping Up:
For this project, I created a resource manager system responsible for loading, owning, caching, unloading, and providing access to various game assets for a mock roleplaying game. The resource manager acts as both a loader and cache, which stores objects such as text assets or textures and then provides either shared or unique pointer references to objects on request. I created this system as my final submission for a C++ programming course, and am immensely proud of the programming and optimization skills I was able to exhibit!
Here, break down each aspect of the project and explain in detail before displaying the .c main