Leosac  0.7.0
OpenSourceAccessControl
GroupEvent.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"
23 #include "IGroupEvent.hpp"
24 
25 namespace Leosac
26 {
27 namespace Audit
28 {
32 #pragma db object polymorphic callback(odb_callback)
33 class GroupEvent : virtual public IGroupEvent, public AuditEntry
34 {
35  private:
36  GroupEvent() = default;
37 
38  friend class Factory;
39 
40  static std::shared_ptr<GroupEvent>
41  create(const DBPtr &database, Auth::GroupPtr target_group, AuditEntryPtr parent);
42 
43  public:
44  virtual ~GroupEvent() = default;
45 
46  static std::shared_ptr<GroupEvent> create_empty();
47 
48  virtual void target(Auth::GroupPtr grp) override;
49 
50  virtual void before(const std::string &repr) override;
51 
52  virtual void after(const std::string &repr) override;
53 
54  Auth::GroupId target_id() const override;
55 
56  const std::string &before() const override;
57 
58  const std::string &after() const override;
59 
60  std::string generate_description() const override;
61 
62  private:
67  std::string generate_target_description() const;
68 
69 #pragma db on_delete(set_null)
71 
79 
83  std::string before_;
84 
88  std::string after_;
89 
90  friend class odb::access;
91 };
92 }
93 }
virtual void target(Auth::GroupPtr grp) override
Set the group that is targeted by the event.
Definition: GroupEvent.cpp:55
const std::string & before() const override
Definition: GroupEvent.cpp:85
Implementation of IAuditEntry, backed by ODB.
Definition: AuditEntry.hpp:45
const std::string & after() const override
Definition: GroupEvent.cpp:90
Provides an implementation of IGroupEvent.
Definition: GroupEvent.hpp:33
This is the header file for a generated source file, GitSHA1.cpp.
static std::shared_ptr< GroupEvent > create(const DBPtr &database, Auth::GroupPtr target_group, AuditEntryPtr parent)
Definition: GroupEvent.cpp:30
std::string before_
Optional JSON dump of the object before the event took place.
Definition: GroupEvent.hpp:83
Interface that describes an Audit object for group related event.
Definition: IGroupEvent.hpp:36
Auth::GroupId target_id() const override
Definition: GroupEvent.cpp:76
virtual IAuditEntryPtr parent() const override
Retrieve the parent of this entry.
Definition: AuditEntry.cpp:140
unsigned long GroupId
Definition: AuthFwd.hpp:41
std::shared_ptr< Group > GroupPtr
Definition: AuthFwd.hpp:37
static std::shared_ptr< GroupEvent > create_empty()
Definition: GroupEvent.cpp:122
std::shared_ptr< AuditEntry > AuditEntryPtr
Definition: AuditFwd.hpp:81
std::string generate_description() const override
Generate a description for this event.
Definition: GroupEvent.cpp:95
odb::lazy_weak_ptr< Group > GroupLWPtr
Definition: AuthFwd.hpp:39
Auth::GroupLWPtr target_
Definition: GroupEvent.hpp:70
std::string after_
Optional JSON dump of the object after the event took place.
Definition: GroupEvent.hpp:88
virtual ~GroupEvent()=default
friend class odb::access
Definition: GroupEvent.hpp:90
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
std::string generate_target_description() const
Generate a small json-string description about the targeted group.
Definition: GroupEvent.cpp:110
Auth::GroupId target_group_id_
This is equals to target_->id().
Definition: GroupEvent.hpp:78
void database(DBPtr db)
Set the database pointer.
Definition: AuditEntry.cpp:145
Provide static methods to instanciate various Audit objects.