Leosac  0.7.0
OpenSourceAccessControl
UserGroupMembershipEvent.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 "AuditEntry.hpp"
24 
25 namespace Leosac
26 {
27 namespace Audit
28 {
32 #pragma db object polymorphic callback(odb_callback)
34  public AuditEntry
35 {
36  private:
37  UserGroupMembershipEvent() = default;
38 
39  friend class Factory;
40 
45 
46  public:
47  virtual ~UserGroupMembershipEvent() = default;
48 
49  virtual void target_user(Auth::UserPtr user) override;
50 
51  virtual void target_group(Auth::GroupPtr grp) override;
52 
53  Auth::UserId target_user_id() const override;
54 
55  Auth::GroupId target_group_id() const override;
56 
57  std::string generate_description() const override;
58 
59  private:
60  std::string generate_target_user_description() const;
61  std::string generate_target_group_description() const;
62 
63 #pragma db on_delete(set_null)
65 
66 #pragma db on_delete(set_null)
68 
76 
81 
82  friend class odb::access;
83 };
84 }
85 }
Implementation of IAuditEntry, backed by ODB.
Definition: AuditEntry.hpp:45
static UserGroupMembershipEventPtr create(const DBPtr &database, Auth::GroupPtr target_group, Auth::UserPtr target_user, AuditEntryPtr parent)
This is the header file for a generated source file, GitSHA1.cpp.
Interface to audit object that take care of tracking user/group membership change.
virtual IAuditEntryPtr parent() const override
Retrieve the parent of this entry.
Definition: AuditEntry.cpp:140
unsigned long GroupId
Definition: AuthFwd.hpp:41
Auth::GroupId target_group_id_
This is equals to target_group_->id().
unsigned long UserId
Definition: AuthFwd.hpp:34
std::shared_ptr< Group > GroupPtr
Definition: AuthFwd.hpp:37
std::shared_ptr< UserGroupMembershipEvent > UserGroupMembershipEventPtr
Definition: AuditFwd.hpp:99
std::shared_ptr< AuditEntry > AuditEntryPtr
Definition: AuditFwd.hpp:81
std::shared_ptr< User > UserPtr
Definition: AuthFwd.hpp:31
Auth::GroupId target_group_id() const override
Auth::UserId target_user_id_
Set to target_user_->id()
odb::lazy_weak_ptr< Group > GroupLWPtr
Definition: AuthFwd.hpp:39
virtual void target_user(Auth::UserPtr user) override
The user that joined or left the group.
odb::lazy_weak_ptr< User > UserLWPtr
Definition: AuthFwd.hpp:33
std::string generate_description() const override
Generate a description for this event.
Provides an implementation of IUserGroupMembershipEvent.
virtual void target_group(Auth::GroupPtr grp) override
The group that gained or lost an user.
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
void database(DBPtr db)
Set the database pointer.
Definition: AuditEntry.cpp:145
Provide static methods to instanciate various Audit objects.