Leosac  0.7.0
OpenSourceAccessControl
UserGroupMembership.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "core/auth/AuthFwd.hpp"
23 #include "tools/db/database.hpp"
24 #include <boost/date_time/posix_time/posix_time.hpp>
25 #include <set>
26 
27 namespace Leosac
28 {
29 namespace Auth
30 {
38 #pragma db object optimistic
40 {
41  public:
43 
44  const UserGroupMembershipId &id() const;
45 
46  const UserLWPtr &user() const;
47  UserId user_id() const;
48  void user(UserPtr user);
49 
50  const GroupLWPtr group() const;
51  GroupId group_id() const;
52  void group(GroupPtr group);
53 
54  const boost::posix_time::ptime &timestamp() const;
55 
56  GroupRank rank() const;
57  void rank(const GroupRank &rank);
58 
59  private:
60 #pragma db id auto
62 
63 #pragma db not_null
64 #pragma db on_delete(cascade)
66 
67 #pragma db not_null
68 #pragma db on_delete(cascade)
70 
71 #pragma db not_null
72  boost::posix_time::ptime timestamp_;
73 
74 #pragma db not_null
76 
77 #pragma db version
78  const size_t version_;
79 
80  friend class odb::access;
81 };
82 
90 {
91  bool operator()(const UserGroupMembershipPtr &m1,
92  const UserGroupMembershipPtr &m2) const;
93 };
94 
96  std::set<UserGroupMembershipPtr, UserGroupMembershipComparator>;
97 }
98 }
99 
100 #ifdef ODB_COMPILER
101 #include "core/auth/Group.hpp"
102 #include "core/auth/User.hpp"
103 #endif
This is the header file for a generated source file, GitSHA1.cpp.
const UserGroupMembershipId & id() const
unsigned long UserGroupMembershipId
Definition: AuthFwd.hpp:82
unsigned long GroupId
Definition: AuthFwd.hpp:41
unsigned long UserId
Definition: AuthFwd.hpp:34
std::shared_ptr< Group > GroupPtr
Definition: AuthFwd.hpp:37
std::shared_ptr< User > UserPtr
Definition: AuthFwd.hpp:31
GroupRank
The rank of an User inside a Group.
Definition: AuthFwd.hpp:49
std::shared_ptr< UserGroupMembership > UserGroupMembershipPtr
Definition: AuthFwd.hpp:81
Compares 2 UserGroupMembership object.
odb::lazy_weak_ptr< Group > GroupLWPtr
Definition: AuthFwd.hpp:39
std::set< UserGroupMembershipPtr, UserGroupMembershipComparator > UserGroupMembershipSet
Describe the membership of an User with regroup to a Group.
const boost::posix_time::ptime & timestamp() const
odb::lazy_weak_ptr< User > UserLWPtr
Definition: AuthFwd.hpp:33