Posted 13 March 2014 - 09:44 PM
In general, a content manager's primary responsibility is to prevent a resource from being loaded more than once if its unnecessary. If it receives a second request for a resource its already loaded, it just passes out a reference to the data it loaded the first time. Of coarse, this means that no one that shares a resource, or might, can modify it.
So parts if the game request a resource using some kind of unique ID -- that could be the path name of the file, a guid, some kind of hash, or maybe a byte offset in a Pak file. When its loaded the first time the content manager creates a record with that ID and a pointer to the loaded data. When another request comes in to load a file, it first checks those records to see if its already been loaded -- if it has, it hands out a reference to the data, otherwise it loads the file as usual, creates a record for that file, and passes out that data.
At some point, you need to be able to unload resources that are no longer in use. To know what's in use, you maintain a counter that says how many users are sharing the resource, and they can say they're done in some way so that you can decrement the counter. One way to unload the resources is to periodically sweep for resources whose counts are zero. Another way is to perform the check each time the counter is decremented and delete the resource (and its record) immediately when it reaches zero. Std::shared_ptr in c++ does all of this for you, except removing the record, but you can also supply your own deleted to shared_ptr that can remove the record and then finish deleting itself.
If you really want to get fancy, instead of deleting the data, you can remove it from the "hot" resource list and place it in a "cold" list. The idea of a cold list is to keep inactive resources in memory while its not a problem, but if you ever run out of memory you can dump everything in the cold list immediately.