diff options
Diffstat (limited to 'include/dchat')
-rw-r--r-- | include/dchat/Cache.hpp | 16 | ||||
-rw-r--r-- | include/dchat/StaticImage.hpp | 12 |
2 files changed, 22 insertions, 6 deletions
diff --git a/include/dchat/Cache.hpp b/include/dchat/Cache.hpp index 62df621..4d37b54 100644 --- a/include/dchat/Cache.hpp +++ b/include/dchat/Cache.hpp @@ -21,6 +21,7 @@ namespace TinyProcessLib namespace dchat { class Gif; + class StaticImage; class WebPagePreview; struct ContentByUrlResult @@ -35,20 +36,20 @@ namespace dchat enum class CachedType { NONE, - TEXTURE_FILEPATH, + STATIC_IMAGE, GIF, WEB_PAGE_PREVIEW }; - ContentByUrlResult() : textureFilePath(nullptr), type(Type::DOWNLOADING), cachedType(CachedType::NONE) {} - ContentByUrlResult(boost::filesystem::path *_textureFilePath, Type _type) : textureFilePath(_textureFilePath), type(_type), cachedType(CachedType::TEXTURE_FILEPATH) {} + ContentByUrlResult() : staticImage(nullptr), type(Type::DOWNLOADING), cachedType(CachedType::NONE) {} + ContentByUrlResult(StaticImage *_staticImage, Type _type) : staticImage(_staticImage), type(_type), cachedType(CachedType::STATIC_IMAGE) {} ContentByUrlResult(Gif *_gif, Type _type) : gif(_gif), type(_type), cachedType(CachedType::GIF) {} ContentByUrlResult(WebPagePreview *_webPagePreview, Type _type) : webPagePreview(_webPagePreview), type(_type), cachedType(CachedType::WEB_PAGE_PREVIEW) {} // @texture is null if @type is DOWNLOADING or FAILED_DOWNLOAD union { - boost::filesystem::path *textureFilePath; + StaticImage *staticImage; Gif *gif; WebPagePreview *webPagePreview; }; @@ -62,13 +63,15 @@ namespace dchat // @fileContent contains data allocated with new[], deallocate it with delete[] fileContent.data; // Returned gif should be allocated with @new using CreateGifFunc = std::function<Gif*(StringView fileContent)>; + using CreateStaticImageFunc = std::function<StaticImage*(const boost::filesystem::path &filepath)>; class Cache { DISABLE_COPY(Cache) public: - // @createGifFunc can't be nullptr - Cache(CreateGifFunc createGifFunc); + // @createGifFunc can't be null + // @createStaticImageFunc can't be null + Cache(CreateGifFunc createGifFunc, CreateStaticImageFunc createStaticImageFunc); ~Cache(); // Creates directory if it doesn't exist (recursively). Throws boost exception on failure @@ -100,5 +103,6 @@ namespace dchat bool alive; std::unordered_map<std::string, ContentByUrlResult> contentUrlCache; CreateGifFunc createGifFunc; + CreateStaticImageFunc createStaticImageFunc; }; } diff --git a/include/dchat/StaticImage.hpp b/include/dchat/StaticImage.hpp new file mode 100644 index 0000000..372f7ce --- /dev/null +++ b/include/dchat/StaticImage.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include <boost/filesystem/path.hpp> + +namespace dchat +{ + class StaticImage + { + public: + virtual ~StaticImage(){} + }; +}
\ No newline at end of file |