aboutsummaryrefslogtreecommitdiff
path: root/src/User.cpp
blob: d157c74e2133aaa89260428f2a567b26b57198ec (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
#include "../include/odhtdb/User.hpp"
#include "../include/odhtdb/Group.hpp"

namespace odhtdb
{
    User::User(Type _type, const std::string &_name, Group *group) : type(_type), name(_name)
    {
        if(name.size() > 255)
            throw UserNameTooLongException(name);
        addToGroup(group);
    }
    
    User::~User()
    {
        for(Group *group : groups)
        {
            group->removeUser(this);
        }
    }
    
    void User::addToGroup(Group *group)
    {
        if(group)
        {
            groups.emplace_back(group);
            group->addUser(this);
        }
    }
}