   Game asset management in code, how do you manage yours?
  Every time I get myself into a big project that requires management of textures, models, audio buffers, sources, and other assets to be loaded in memory, I get indecisive about how to best tackle this.I think the problem lies with access to these asset managers in different parts of the code while still maintaining some level of abstraction. Singleton classes with global scope comes into my mind, or perhaps passing structures around by reference to methods that need access to those asset managers. Singleton approaches seem convenient, as I don't have to maintain parameter lists in the latter method, but surely there has to be better ways of doing this?Then you have MP environments, where data sharing problems become even more convoluted. I'm interested to know what approaches you people use for asset management in your projects? Also, any recommendations on good reading material on this subject?
  I usually make a "resource bank" with the resource being a template class. Within each "resource" i have an unordered map (STL or boost) that i use for storing the data. Sounds, images, polygons, etc.. The resource class looks like this in c++ (straight from my own source..). template < class T>class resource{public:resource(){}T  get_data(std::string str){T output = database[str];return output;};int insert_data(std::string identifier, T ptr){if(contains(identifier)){return -1;}database[identifier] = ptr;return 0;}int delete_data(std::string identifier){if(contains(identifier)){database.remove(identifier);return 0;}return -1;}bool contains(std::string str){if(database.find(str) != database.end()){return true;}return false;}private:boost::unordered_map <std::string, T> database;};used like this("pseudo-cpp-code")://Lets say we have some class "image". and a function "load_image" that returns the data. resource <image *> image_db;image_db.insert_data("player_sprite", load_image("images/player_sprite.png") );//maybe we have a function that can "draw" an image..draw(image_db.get_data("player_sprite")); hope this helps :)   ;  Thanks for sharing. I used similar techniques for setting up resource manager classes before, although not template classes specifically. I am curious, in what scope do you access the image_db instance throughout your code? ;  A templated abstract manager, which provides a generic resource resolution/loading interpreter. The concrete versions are specific to the resource/module and will generally have a 'default' global instance but the design does not assume that's the one you're using.   ;  I use a similar system to the one posted, except I utilize a string hashing technique to avoid doing strcmp calls in run code.   ;  I'm using a similar approach with my DLL based plugin framework. All plugins get passed an environment which itself is just a map of services (the asset loader being one of them).The environment is pretty much the same as in one of the game engine articles here on Gamedev.net.The plugins request the asset loader service on startup and load in all their asset types (as applicable).   