aboutsummaryrefslogtreecommitdiff
path: root/include/odhtdb/Group.hpp
blob: 890b2fce14a53dec09681b28d4c8f65d62ae2a03 (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
#pragma once

#include "types.hpp"
#include "DataView.hpp"
#include "Permission.hpp"
#include <string>
#include <vector>
#include <stdexcept>

namespace odhtdb
{
    class User;

    class GroupNameTooLongException : public std::runtime_error
    {
    public:
        GroupNameTooLongException(const std::string &groupName) : 
            std::runtime_error(std::string("The group name ") + groupName + " is longer than 255 bytes")
        {

        }
    };
    
    const int GROUP_ID_LENGTH = 16;

    class Group
    {
        friend class User;
    public:
        Group(const std::string &name, uint8_t id[GROUP_ID_LENGTH], const Permission &permission);
        ~Group();

        const std::string& getName() const;
        DataView getId() const;
        const Permission& getPermission() const;
        const std::vector<const User*>& getUsers() const;
    private:
        void addUser(const User *user);
    private:
        std::string name;
        uint8_t id[GROUP_ID_LENGTH];
        Permission permission;
        std::vector<const User*> users;
    };
}