-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.h
92 lines (76 loc) · 1.76 KB
/
user.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
#ifndef USER_H
#define USER_H
#include <string>
#include <set>
#include <list>
#include <vector>
/* Forward Declaration to avoid #include dependencies */
class Tweet;
class User {
public:
/**
* Constructor
*/
User(std::string name);
/**
* Destructor
*/
~User();
/**
* Gets the name of the user
*
* @return name of the user
*/
std::string name() const;
/**
* Gets all the followers of this user
*
* @return Set of Users who follow this user
*/
std::set<User*> followers() const;
/**
* Gets all the users whom this user follows
*
* @return Set of Users whom this user follows
*/
std::set<User*> following() const;
/**
* Gets all the tweets this user has posted
*
* @return List of tweets this user has posted
*/
std::list<Tweet*> tweets() const;
/**
* Adds a follower to this users set of followers
*
* @param u User to add as a follower
*/
void addFollower(User* u);
/**
* Adds another user to the set whom this User follows
*
* @param u User that the user will now follow
*/
void addFollowing(User* u);
/**
* Adds the given tweet as a post from this user
*
* @param t new Tweet posted by this user
*/
void addTweet(Tweet* t);
/**
* Produces the list of Tweets that represent this users feed/timeline
* It should contain in timestamp order all the tweets from
* this user and all the tweets from all the users whom this user follows
*
* @return vector of pointers to all the tweets from this user
* and those they follow in timestamp order
*/
std::vector<Tweet*> getFeed();
private:
std::string name_;
std::set<User*> followers_;
std::set<User*> following_;
std::list<Tweet*> tweets_;
};
#endif