mirror-chatterino2/src/providers/twitch/TwitchEmotes.hpp

34 lines
821 B
C++
Raw Normal View History

#pragma once
2018-08-02 14:23:27 +02:00
#include <QString>
#include <unordered_map>
#include "common/Aliases.hpp"
2018-08-02 14:23:27 +02:00
#include "common/UniqueAccess.hpp"
2018-06-26 14:09:39 +02:00
#include "providers/twitch/TwitchEmotes.hpp"
2018-08-06 21:17:03 +02:00
#define TWITCH_EMOTE_TEMPLATE \
"https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}"
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
class TwitchEmotes
{
public:
TwitchEmotes();
2018-08-02 14:23:27 +02:00
EmotePtr getOrCreateEmote(const EmoteId &id, const EmoteName &name);
Url getEmoteLink(const EmoteId &id, const QString &emoteScale);
AccessGuard<std::unordered_map<EmoteName, EmotePtr>> accessAll();
private:
2018-08-02 14:23:27 +02:00
UniqueAccess<std::unordered_map<EmoteName, EmotePtr>> twitchEmotes_;
2018-08-06 21:17:03 +02:00
UniqueAccess<std::unordered_map<EmoteId, std::weak_ptr<Emote>>>
twitchEmotesCache_;
};
} // namespace chatterino