-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathRole.hpp
101 lines (81 loc) · 1.6 KB
/
Role.hpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#pragma once
#include "Singleton.hpp"
#include "types.hpp"
#include <string>
#include <atomic>
#include <json.hpp>
using json = nlohmann::json;
class Role
{
public:
Role(RoleId_t pawn_id, json const &data);
~Role() = default;
private:
const RoleId_t m_PawnId;
Snowflake_t m_Id;
std::string m_Name;
unsigned int m_Color;
bool m_Hoist;
unsigned int m_Position;
unsigned long long int m_Permissions;
bool m_Mentionable;
bool _valid = false;
public:
inline RoleId_t GetPawnId() const
{
return m_PawnId;
}
inline Snowflake_t const &GetId() const
{
return m_Id;
}
inline std::string const &GetName() const
{
return m_Name;
}
inline unsigned int GetColor() const
{
return m_Color;
}
inline bool IsHoist() const
{
return m_Hoist;
}
inline unsigned int GetPosition() const
{
return m_Position;
}
inline decltype(m_Permissions) GetPermissions() const
{
return m_Permissions;
}
inline bool IsMentionable() const
{
return m_Mentionable;
}
inline bool IsValid() const
{
return _valid;
}
inline operator bool() const
{
return IsValid();
}
void Update(json const &data);
};
class RoleManager : public Singleton<RoleManager>
{
friend class Singleton<RoleManager>;
private:
RoleManager() = default;
~RoleManager() = default;
private:
const unsigned int m_InitValue = 1;
std::atomic<unsigned int> m_Initialized{ 0 };
std::map<RoleId_t, Role_t> m_Roles; //PAWN role-id to actual channel map
public:
RoleId_t AddRole(json const &data);
void RemoveRole(Role_t const &role);
Role_t const &FindRole(RoleId_t id);
Role_t const &FindRoleById(Snowflake_t const &sfid);
};