Leosac  0.7.0
OpenSourceAccessControl
UserGroupMembership.cpp
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 
21 #include "core/auth/Group_odb.h"
22 #include "core/auth/User_odb.h"
23 #include "tools/log.hpp"
24 
25 using namespace Leosac;
26 using namespace Leosac::Auth;
27 
29  : id_(0)
30  , version_(0)
31 {
32  timestamp_ = boost::posix_time::second_clock::local_time();
34 }
35 
37 {
38  return id_;
39 }
40 
42 {
43  return user_;
44 }
45 
47 {
48  user_ = user;
49 }
50 
52 {
53  return group_;
54 }
55 
57 {
58  group_ = group;
59 }
60 
61 const boost::posix_time::ptime &UserGroupMembership::timestamp() const
62 {
63  return timestamp_;
64 }
65 
67 {
68  return rank_;
69 }
70 
72 {
73  rank_ = rank;
74 }
75 
77 {
78  return user_.object_id();
79 }
80 
82 {
83  return group_.object_id();
84 }
85 
88 {
89  if (m1->user_id() == 0 || m1->group_id() == 0 || m2->user_id() == 0 ||
90  m2->group_id() == 0)
91  return std::addressof(m1) < std::addressof(m2);
92 
93  return std::make_pair(m1->user_id(), m1->group_id()) <
94  std::make_pair(m2->user_id(), m2->group_id());
95 }
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
Holds classes relevant to the Authentication and Authorization subsystem.
Definition: AccessPoint.hpp:27
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
odb::lazy_weak_ptr< Group > GroupLWPtr
Definition: AuthFwd.hpp:39
bool operator()(const UserGroupMembershipPtr &m1, const UserGroupMembershipPtr &m2) const
const boost::posix_time::ptime & timestamp() const
odb::lazy_weak_ptr< User > UserLWPtr
Definition: AuthFwd.hpp:33