blob: 42101427383314f2bc581eebb5a4334708619799 (
plain)
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
|
#include "../include/odhtdb/Group.hpp"
#include "../include/odhtdb/User.hpp"
#include <cstring>
using namespace std;
namespace odhtdb
{
Group::Group(const string &_name, uint8_t _id[GROUP_ID_LENGTH], const Permission &_permission) :
name(_name),
permission(_permission)
{
if(name.size() > 255)
throw GroupNameTooLongException(name);
memcpy(id, _id, GROUP_ID_LENGTH);
}
Group::~Group()
{
}
void Group::addUser(const User *user)
{
users.push_back(user);
}
bool Group::removeUser(const User *user)
{
for(std::vector<const User*>::iterator it = users.begin(); it != users.end(); ++it)
{
if(*it == user)
{
users.erase(it);
return true;
}
}
return false;
}
const string& Group::getName() const
{
return name;
}
DataView Group::getId() const
{
return { (void*)id, GROUP_ID_LENGTH };
}
const Permission& Group::getPermission() const
{
return permission;
}
const vector<const User*>& Group::getUsers() const
{
return users;
}
}
|