/******************************************************************************
*	File		-	asset_manager.h
*	Author		-	Joey Pollack
*	Date		-	2021/10/25 (y/m/d)
*	Mod Date	-	2021/10/25 (y/m/d)
*	Description	-	Manages loading/unloading of all data/assets
******************************************************************************/

#ifndef ASSET_MANAGER_H_
#define ASSET_MANAGER_H_

#include <utils/op_res.h>

#include <vector>
#include <map>
#include <string>

namespace lunarium
{
    class Asset;

    class AssetManager
    {
    public:
        static AssetManager& GetInstance();

        OpRes Initialize();
        void Shutdown();

        // Used for preloading a list of assets
        OpRes LoadAssets(std::vector<std::string> names);
        Asset* GetAsset(std::string name);
        void ReturnAsset(Asset* pAsset)
        void UnloadAsset(std::string name);

    private:

        static AssetManager* mpInstance;

        struct AssetBox
        {
            Asset* asset;
            int references;
        };

        // Assets stored by name
        std::map<std::string, AssetBox> mAssets;
    
    private:
        AssetManager();
        AssetManager(const AssetManager&) = delete;
        AssetManager& operator=(const AssetManager&) = delete;
    };

}

#endif  // ASSET_MANAGER_H_