aboutsummaryrefslogtreecommitdiff
path: root/src/GlobalCache.cpp
blob: b28773853fb3806ea4ac4dbfd2df989944527ef2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "../include/GlobalCache.hpp"
#include "../include/GtkGif.hpp"
#include "../include/GtkScaledImage.hpp"

namespace dchat
{
    static Cache *cache = nullptr;
    Cache& getGlobalCache()
    {
        if(!cache)
        {
            auto createGifFunc = [](StringView fileContent)
            {
                return new GtkGif(fileContent);
            };

            auto createStaticImageFunc = [](const boost::filesystem::path &filepath)
            {
                return new GtkScaledImage(filepath);
            };

            cache = new Cache(createGifFunc, createStaticImageFunc);
        }
        return *cache;
    }
}