Leosac  0.8.0
Open Source Access Control
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 }
Leosac::Audit::GroupEvent::~GroupEvent
virtual ~GroupEvent()=default
Leosac::Audit::AuditEntryPtr
std::shared_ptr< AuditEntry > AuditEntryPtr
Definition: AuditFwd.hpp:81
Leosac::Audit::IGroupEvent
Interface that describes an Audit object for group related event.
Definition: IGroupEvent.hpp:36
AuditEntry.hpp
Leosac::Audit::AuditEntry::database
void database(DBPtr db)
Set the database pointer.
Definition: AuditEntry.cpp:144
Leosac::DBPtr
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
IGroupEvent.hpp
Leosac::Audit::GroupEvent::generate_description
std::string generate_description() const override
Generate a description for this event.
Definition: GroupEvent.cpp:95
Leosac::Audit::GroupEvent::before
const std::string & before() const override
Definition: GroupEvent.cpp:85
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Audit::GroupEvent::create
static std::shared_ptr< GroupEvent > create(const DBPtr &database, Auth::GroupPtr target_group, AuditEntryPtr parent)
Definition: GroupEvent.cpp:30
Leosac::Audit::GroupEvent::GroupEvent
GroupEvent()=default
Leosac::Audit::Factory
Provide static methods to instanciate various Audit objects.
Definition: AuditFactory.hpp:46
Leosac::Auth::GroupPtr
std::shared_ptr< Group > GroupPtr
Definition: AuthFwd.hpp:37
Leosac::Audit::GroupEvent::target_id
Auth::GroupId target_id() const override
Definition: GroupEvent.cpp:76
Leosac::Audit::AuditEntry::parent
virtual IAuditEntryPtr parent() const override
Retrieve the parent of this entry.
Definition: AuditEntry.cpp:139
Leosac::Audit::GroupEvent
Provides an implementation of IGroupEvent.
Definition: GroupEvent.hpp:33
Leosac::Audit::GroupEvent::target_group_id_
Auth::GroupId target_group_id_
This is equals to target_->id().
Definition: GroupEvent.hpp:78
Leosac::Audit::GroupEvent::create_empty
static std::shared_ptr< GroupEvent > create_empty()
Definition: GroupEvent.cpp:122
Leosac::Audit::GroupEvent::generate_target_description
std::string generate_target_description() const
Generate a small json-string description about the targeted group.
Definition: GroupEvent.cpp:110
Leosac::Auth::GroupId
unsigned long GroupId
Definition: AuthFwd.hpp:41
Leosac::Audit::GroupEvent::target
virtual void target(Auth::GroupPtr grp) override
Set the group that is targeted by the event.
Definition: GroupEvent.cpp:55
Leosac::Audit::AuditEntry
Implementation of IAuditEntry, backed by ODB.
Definition: AuditEntry.hpp:45
Leosac::Audit::GroupEvent::after_
std::string after_
Optional JSON dump of the object after the event took place.
Definition: GroupEvent.hpp:88
Leosac::Auth::GroupLWPtr
odb::lazy_weak_ptr< Group > GroupLWPtr
Definition: AuthFwd.hpp:39
Leosac::Audit::GroupEvent::access
friend class odb::access
Definition: GroupEvent.hpp:90
Leosac::Audit::GroupEvent::target_
Auth::GroupLWPtr target_
Definition: GroupEvent.hpp:70
Leosac::Audit::GroupEvent::after
const std::string & after() const override
Definition: GroupEvent.cpp:90
Leosac::Audit::GroupEvent::before_
std::string before_
Optional JSON dump of the object before the event took place.
Definition: GroupEvent.hpp:83