-
Notifications
You must be signed in to change notification settings - Fork 0
/
Definitions.h
140 lines (133 loc) · 2.09 KB
/
Definitions.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
#include <string>
#include <iostream>
#include <set>
#include <fstream>
#include <thread>
#include <string.h>
#include <netinet/in.h>
#include <openssl/sha.h>
using namespace std;
size_t PIECE_SIZE = 512 * 1024;
class pending_request_data_base
{
public:
pending_request_data_base()
{
grpname = "";
adminname = "";
}
pending_request_data_base(string gName, string admin, set<string> members)
{
grpname = gName;
adminname = admin;
pendingID = members;
}
pending_request_data_base(const pending_request_data_base &g)
{
grpname = g.grpname;
adminname = g.adminname;
pendingID = g.pendingID;
}
string grpname;
string adminname;
set<string> pendingID;
};
class user
{
public:
user() {}
user(string userID, string password)
{
this->userID = userID;
this->password = password;
}
string userID;
string password;
};
class peer
{
public:
peer()
{
ip = "";
port = 0;
userID = "";
}
peer(string ip, int port, string userID)
{
this->ip = ip;
this->port = port;
this->userID = userID;
}
/*peer &operator=(const peer &t)
{
this->ip = ip;
this->port = port;
this->userID = userID;
}*/
bool operator<(const peer &rhs) const
{
return port < rhs.port;
}
peer(const peer &p)
{
ip = p.ip;
port = p.port;
userID = p.userID;
}
string ip;
int port;
string userID;
};
class group
{
public:
group(string name, string adminID)
{
this->name = name;
this->adminID = adminID;
}
string name;
string adminID;
set<string> members;
};
class file_data_base
{
public:
int id;
string name;
string path;
string groupName;
int pieces;
set<peer> seederList;
string hash;
file_data_base()
{
id = -1;
name = "";
path = "";
groupName = "";
pieces = 0;
hash = "";
}
file_data_base(int i, string n, string p, string grp, int pi, string hh, set<peer> seedList)
{
id = i;
name = n;
path = p;
groupName = grp;
pieces = pi;
hash = hh;
seederList = seedList;
}
file_data_base(const file_data_base &f)
{
id = f.id;
name = f.name;
path = f.path;
groupName = f.groupName;
pieces = f.pieces;
hash = f.hash;
seederList = f.seederList;
}
};