#ifndef CPICTURECACHE_H #define CPICTURECACHE_H #include #include #include #include #include #include #include #include #include "viewGridNavigator.h" enum ImageResolution { SD384, SD480, HD720, HD1080 }; class cPictureCache { private: struct CacheInfo { CacheInfo(std::string Uri, int Width, int Height, std::function OnCached, cGridElement* Calle) { uri = Uri; width = Width; height = Height; onCached = OnCached; calle = Calle; }; std::string uri; int width; int height; std::function onCached; cGridElement* calle; bool downloaded; }; cPictureCache(); std::map m_mCached; std::vector> m_vFutures; volatile bool m_bAllInvalidated; std::string FileName(std::string uri, int width); std::string TranscodeUri(std::string uri, int width, int height); static bool DownloadFileAndSave(std::string uri, std::string localFile); bool Cached(std::string uri, int width); std::string m_cacheDir; public: static cPictureCache& GetInstance() { static cPictureCache instance; return instance; } std::string GetPath(std::string uri, int width, int height, bool& cached, std::function OnCached = NULL, cGridElement* calle = NULL); }; #endif // CPICTURECACHE_H