Leosac  0.8.0
Open Source Access Control
UpdateEvent.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 "IUpdateEvent.hpp"
24 
25 namespace Leosac
26 {
27 namespace Audit
28 {
32 #pragma db object polymorphic callback(odb_callback)
33 class UpdateEvent : virtual public IUpdateEvent, public AuditEntry
34 {
35  private:
36  UpdateEvent() = default;
37 
38  friend class Factory;
39 
40  static std::shared_ptr<UpdateEvent> create(const DBPtr &database,
41  update::IUpdatePtr target_update,
43 
44  public:
45  std::string generate_description() const override;
46 
47  public:
48  virtual ~UpdateEvent() = default;
49 
50  static std::shared_ptr<UpdateEvent> create_empty();
51 
52  void target(update::IUpdatePtr u) override;
53 
54  update::UpdateId target_id() const override;
55 
56  public:
58 
59  friend class odb::access;
60 };
61 }
62 }
63 
64 #ifdef ODB_COMPILER
65 #include "core/update/Update.hpp"
66 #endif
Leosac::update::UpdateLWPtr
odb::lazy_weak_ptr< Update > UpdateLWPtr
Definition: UpdateFwd.hpp:46
Leosac::Audit::UpdateEvent::generate_description
std::string generate_description() const override
Generate a description for this event.
Definition: UpdateEvent.cpp:73
Leosac::Audit::AuditEntryPtr
std::shared_ptr< AuditEntry > AuditEntryPtr
Definition: AuditFwd.hpp:81
AuditEntry.hpp
Leosac::Audit::AuditEntry::database
void database(DBPtr db)
Set the database pointer.
Definition: AuditEntry.cpp:144
Leosac::update::IUpdatePtr
std::shared_ptr< IUpdate > IUpdatePtr
Definition: UpdateFwd.hpp:42
Leosac::DBPtr
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Audit::UpdateEvent
Provides an implementation of IUpdateEvent.
Definition: UpdateEvent.hpp:33
Leosac::Audit::Factory
Provide static methods to instanciate various Audit objects.
Definition: AuditFactory.hpp:46
Leosac::Audit::AuditEntry::parent
virtual IAuditEntryPtr parent() const override
Retrieve the parent of this entry.
Definition: AuditEntry.cpp:139
Leosac::Audit::UpdateEvent::create
static std::shared_ptr< UpdateEvent > create(const DBPtr &database, update::IUpdatePtr target_update, AuditEntryPtr parent)
Definition: UpdateEvent.cpp:31
Leosac::Audit::UpdateEvent::UpdateEvent
UpdateEvent()=default
Leosac::Audit::UpdateEvent::~UpdateEvent
virtual ~UpdateEvent()=default
Leosac::Audit::UpdateEvent::target_
update::UpdateLWPtr target_
Definition: UpdateEvent.hpp:57
Leosac::Audit::UpdateEvent::access
friend class odb::access
Definition: UpdateEvent.hpp:59
Leosac::Audit::IUpdateEvent
Interface for update-related event.
Definition: IUpdateEvent.hpp:32
IUpdateEvent.hpp
Leosac::Audit::AuditEntry
Implementation of IAuditEntry, backed by ODB.
Definition: AuditEntry.hpp:45
Leosac::Audit::UpdateEvent::target
void target(update::IUpdatePtr u) override
Set the update that is targeted by the event.
Definition: UpdateEvent.cpp:55
Update.hpp
Leosac::update::UpdateId
unsigned long UpdateId
Definition: UpdateFwd.hpp:56
Leosac::Audit::UpdateEvent::create_empty
static std::shared_ptr< UpdateEvent > create_empty()
Definition: UpdateEvent.cpp:68
Leosac::Audit::UpdateEvent::target_id
update::UpdateId target_id() const override
Retrieve the user_id that was targeted by this event.
Definition: UpdateEvent.cpp:61