Leosac  0.8.0
Open Source Access Control
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
Leosac::Auth::UserGroupMembership::group
const GroupLWPtr group() const
Definition: UserGroupMembership.cpp:51
Leosac::Auth::UserGroupMembership::id_
UserGroupMembershipId id_
Definition: UserGroupMembership.hpp:61
Leosac::Auth::UserGroupMembership::user
const UserLWPtr & user() const
Definition: UserGroupMembership.cpp:41
database.hpp
Leosac::Auth::UserGroupMembership::group_id
GroupId group_id() const
Definition: UserGroupMembership.cpp:81
AuthFwd.hpp
Leosac::Auth::UserLWPtr
odb::lazy_weak_ptr< User > UserLWPtr
Definition: AuthFwd.hpp:33
Leosac::Auth::UserPtr
std::shared_ptr< User > UserPtr
Definition: AuthFwd.hpp:31
Leosac::Auth::UserGroupMembership::timestamp_
boost::posix_time::ptime timestamp_
Definition: UserGroupMembership.hpp:72
User.hpp
Leosac::Auth::UserGroupMembership::user_id
UserId user_id() const
Definition: UserGroupMembership.cpp:76
Leosac::Auth::UserGroupMembership::rank_
GroupRank rank_
Definition: UserGroupMembership.hpp:75
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Auth::UserGroupMembership::UserGroupMembership
UserGroupMembership()
Definition: UserGroupMembership.cpp:28
Leosac::Auth::UserGroupMembershipId
unsigned long UserGroupMembershipId
Definition: AuthFwd.hpp:82
Group.hpp
Leosac::Auth::UserGroupMembership::version_
const size_t version_
Definition: UserGroupMembership.hpp:78
Leosac::Auth::UserGroupMembership::access
friend class odb::access
Definition: UserGroupMembership.hpp:80
Leosac::Auth::GroupPtr
std::shared_ptr< Group > GroupPtr
Definition: AuthFwd.hpp:37
Leosac::Auth::UserGroupMembership::timestamp
const boost::posix_time::ptime & timestamp() const
Definition: UserGroupMembership.cpp:61
Leosac::Auth::UserGroupMembershipPtr
std::shared_ptr< UserGroupMembership > UserGroupMembershipPtr
Definition: AuthFwd.hpp:81
Leosac::Auth::UserGroupMembershipComparator::operator()
bool operator()(const UserGroupMembershipPtr &m1, const UserGroupMembershipPtr &m2) const
Definition: UserGroupMembership.cpp:87
Leosac::Auth::UserGroupMembership::rank
GroupRank rank() const
Definition: UserGroupMembership.cpp:66
Leosac::Auth::UserGroupMembershipComparator
Compares 2 UserGroupMembership object.
Definition: UserGroupMembership.hpp:89
Leosac::Auth::UserGroupMembershipSet
std::set< UserGroupMembershipPtr, UserGroupMembershipComparator > UserGroupMembershipSet
Definition: UserGroupMembership.hpp:96
Leosac::Auth::GroupId
unsigned long GroupId
Definition: AuthFwd.hpp:41
Leosac::Auth::UserGroupMembership::user_
UserLWPtr user_
Definition: UserGroupMembership.hpp:65
Leosac::Auth::UserGroupMembership::group_
GroupLWPtr group_
Definition: UserGroupMembership.hpp:69
Leosac::Auth::UserId
unsigned long UserId
Definition: AuthFwd.hpp:34
Leosac::Auth::GroupRank
GroupRank
The rank of an User inside a Group.
Definition: AuthFwd.hpp:49
Leosac::Auth::GroupLWPtr
odb::lazy_weak_ptr< Group > GroupLWPtr
Definition: AuthFwd.hpp:39
Leosac::Auth::UserGroupMembership
Describe the membership of an User with regroup to a Group.
Definition: UserGroupMembership.hpp:39
Leosac::Auth::UserGroupMembership::id
const UserGroupMembershipId & id() const
Definition: UserGroupMembership.cpp:36