#ifndef RESOURCE_MANAGER_HPP
#define RESOURCE_MANAGER_HPP

#if defined(LINUX) || defined(MINGW)
    #include <SDL2/SDL.h>
#else // This works for Mac
    #include <SDL.h>
#endif

#include <unordered_map>
#include <string>

/**
 * A Singleton class to hold all loaded files in the game.
 * The purpose of the ResourceManager is to avoid wasting memory on duplicate textures, audio files, and any other things that need to be loaded.
 */
class ResourceManager{
    private:
        /**
         * Construct a new Resource Manager object.
         * Not used, according to the Singleton Pattern.
         */
        ResourceManager();  // Private Singleton
        ResourceManager(ResourceManager const&); // Avoid copy constructor
        void operator=(ResourceManager const&); // Don't allow assignment.

        std::unordered_map<std::string, SDL_Surface*> surfaces;
    
    public:
        /**
         * Get the Singleton instance of the ResourceManager.
         * 
         * @return the only ResourceManager instance
         */
        static ResourceManager &GetInstance();
        
        /**
         * Load a file into memory.
         * 
         * @param image_filename the name of the file to be loaded
         * @return the SDL_Surface created by loading the file
         */
        SDL_Surface* LoadResource(std::string image_filename);

        // TODO SPRINT 1 (April 5): Create LoadResource overload for audio files
        
        /**
         * Get a resource from the ResourceManager.
         * If the resource is not already loaded, calls #LoadResource()
         * 
         * @param key the filename to be loaded
         * @return the SDL_Surface created by loading the file
         */
        SDL_Surface* GetResource(std::string key);
        
        /**
         * Initialize the Singleton.
         */
        int StartUp();
        
        /**
         * Destroy the Singleton
         */
        int ShutDown();
};

#endif