From 66cc4b3cc7c7170bd7ff0347ed377d317dcdce91 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Sun, 6 Sep 2020 21:28:07 -0400 Subject: refactor (store) --- discord/store.hpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 discord/store.hpp (limited to 'discord/store.hpp') diff --git a/discord/store.hpp b/discord/store.hpp new file mode 100644 index 0000000..c0cbf40 --- /dev/null +++ b/discord/store.hpp @@ -0,0 +1,45 @@ +#pragma once +#include "objects.hpp" +#include +#include + +#ifdef GetMessage // fuck you windows.h + #undef GetMessage +#endif + +class Store { +public: + void SetUser(Snowflake id, const UserData &user); + void SetChannel(Snowflake id, const ChannelData &channel); + void SetGuild(Snowflake id, const GuildData &guild); + void SetRole(Snowflake id, const RoleData &role); + void SetMessage(Snowflake id, const MessageData &message); + void SetGuildMemberData(Snowflake guild_id, Snowflake user_id, const GuildMemberData &data); + + const UserData *GetUser(Snowflake id) const; + const ChannelData *GetChannel(Snowflake id) const; + const GuildData *GetGuild(Snowflake id) const; + const RoleData *GetRole(Snowflake id) const; + const MessageData *GetMessage(Snowflake id) const; + const GuildMemberData *GetGuildMemberData(Snowflake guild_id, Snowflake user_id) const; + + using users_type = std::unordered_map; + using channels_type = std::unordered_map; + using guilds_type = std::unordered_map; + using roles_type = std::unordered_map; + using messages_type = std::unordered_map; + using members_type = std::unordered_map>; + + const channels_type &GetChannels() const; + const guilds_type &GetGuilds() const; + + void ClearAll(); + +private: + users_type m_users; + channels_type m_channels; + guilds_type m_guilds; + roles_type m_roles; + messages_type m_messages; + members_type m_members; +}; -- cgit v1.2.3