-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin.h
202 lines (174 loc) · 5.75 KB
/
admin.h
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//
// Created by joaog on 10/23/2020.
//
#ifndef PROJETO1_ADMIN_H
#define PROJETO1_ADMIN_H
#include <string>
#include <algorithm>
#include "user.h"
#include "streamZ.h"
/**
* @brief Class which has access to private methods of StreamZ, used to get statistics
*/
class Admin{
private:
/**
* @brief Name of the Admin
*/
std::string name;
/**
* @brief Pointer to the StreamZ website the Admin is operating in
*/
StreamZ* site; // pointer so we can delete admin
public:
/**
* @brief Creates an Admin with given name and site
* @param name Name of the Admin
* @param site Site in which the Admin operates
*/
Admin(const std::string& name, StreamZ* site);
/**
* @brief Gets the number of active Streams at the moment
* @return Integer containing the number of Streams
*/
int getNumStreams() const;
/**
* @brief Gets the number of Streams created in a given interval of time: [from, to]
* @param from Start Date
* @param to End Date
* @throw badDateComp If start date is after end date
* @return Integer containing the number of created Streams in the interval
*/
int getNumCreatedStreams(Date& from, const Date& to) const;
/**
* @brief Gets the average views for all the active Streams
* @throw NoActiveStreams If there are no active Streams
* @return Float containing the average views
*/
float getAvgViews() const;
/**
* @brief Gets the average views of the Streams created in a given interval: [from, to]
* @param from Start Date
* @param to End Date
* @throw badDateComp If start date is after end date
* @return Float containing the average views
*/
float getAvgViews(Date& from, const Date& to) const;
/**
* @brief Gets the number of active PublicStreams at the moment
* @return Integer containing the number of PublicStreams
*/
int getNumPublicStreams() const;
/**
* @brief Gets the number of PublicStreams created in a given interval of time: [from, to]
* @param from Start Date
* @param to End Date
* @throw badDateComp If start date is after end date
* @return Integer containing the number of created PublicStreams in the interval
*/
int getNumPublicStreams(Date& from, const Date& to) const;
/**
* @brief Gets the number of active PrivateStreams at the moment
* @return Integer containing the number of PrivateStreams
*/
int getNumPrivateStreams() const;
/**
* @brief Gets the number of PrivateStreams created in a given interval of time: [from, to]
* @param from Start Date
* @param to End Date
* @throw badDateComp If start date is after end date
* @return Integer containing the number of created PrivateStreams in the interval
*/
int getNumPrivateStreams(Date& from, const Date& to) const;
/**
* @brief Gets the name of the Admin
* @return String containing the name of the Admin
*/
string getName() const;
/**
* @brief Updates the name of the Admin
* @param name Name of the Admin
*/
void setName(const std::string& name);
/**
* @brief Gets the preferred language in a given vector of Streams
* @param streams Vector of Stream* with the Streams which will be analyzed
* @throw NoActiveStreams If there are no active Streams
* @return String containing the preferred language
*/
std::string getPreferredLanguage(std::vector<Stream*>& streams) const;
/**
* @brief Gets the preferred stream type of the active Streams
* @throw NoActiveStreams If there are no active Streams
* @return String containing the preferred Stream type
*/
std::string getPreferredStreamType() const;
/**
* @brief Gets the pointer to the most viewed Streamer at the moment
* @throw NoActiveStreams If there are no active Streams
* @return Streamer* to the most viewed Streamer
*/
Streamer* getMostViewedStreamer() const;
/**
* @brief Lists all the donations in the site, by decreasing order
*/
void listDonations() const;
/**
* @brief Lists the donations in a given interval of ratings, by decreasing order
* @param aval1 Lower bound of the interval
* @param aval2 Upper bound of the interval
* @throw badDateComp if the lower bound is higher than the upper bound
*/
void listDonations(int rate1, int rate2) const;
/**
* @brief Lists the top 10 donations, by decreasing order
*/
void listTopDonations() const;
/**
* @brief Opens a menu which lets the admin search streamers by their Nickname and see if they're active or not
*/
void searchStreamers() const;
};
/**
* @brief Exception class which should be thrown when an interval of Dates is faulty
*/
class badDateComp{
private:
/**
* @brief Reason the exception was thrown
*/
string reason;
public:
/**
* @brief Creates a badDateComp exception with a given reason
* @param reason Reason of the exception
*/
badDateComp(const string& reason);
/**
* @brief Gets the reason of the exception
* @return String containing the reason
*/
string what() const;
};
/**
* @brief Exception class which should be thrown when there are unexpectedly no active Streams
*/
class NoActiveStreams{
private:
/**
* @brief Reason the exception was thrown
*/
string reason;
public:
/**
* @brief Creates a noActiveStreams exception with a given reason
* @param reason Reason of the exception
*/
NoActiveStreams(const string& reason);
/**
* @brief Gets the reason of the exception
* @return String containing the reason
*/
string what() const;
};
#endif //PROJETO1_ADMIN_H