Leosac  0.8.0
Open Source Access Control
AccessPointEvent.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 "IAccessPointEvent.hpp"
24 
25 namespace Leosac
26 {
27 namespace Audit
28 {
32 #pragma db object polymorphic callback(odb_callback)
33 class AccessPointEvent : virtual public IAccessPointEvent, public AuditEntry
34 {
35  private:
37 
38  friend class Factory;
39 
40  static std::shared_ptr<AccessPointEvent> create(const DBPtr &database,
41  Auth::IAccessPointPtr target_ap,
43 
44  public:
45  virtual ~AccessPointEvent() = default;
46 
47  static std::shared_ptr<AccessPointEvent> create_empty();
48 
49  virtual void target(Auth::IAccessPointPtr door) override;
50 
51  Auth::AccessPointId target_id() const override;
52 
53  virtual void before(const std::string &repr) override;
54 
55  virtual void after(const std::string &repr) override;
56 
57  const std::string &before() const override;
58 
59  const std::string &after() const override;
60 
61  std::string generate_description() const override;
62 
63  public:
67  std::string generate_target_description() const;
68 
69 #pragma db on_delete(set_null)
71 
73 
77  std::string before_;
78 
82  std::string after_;
83 
84  friend class odb::access;
85 };
86 }
87 }
88 
89 #ifdef ODB_COMPILER
91 #endif
Leosac::Audit::AccessPointEvent::target_ap_id_
Auth::AccessPointId target_ap_id_
Definition: AccessPointEvent.hpp:72
AccessPoint.hpp
IAccessPointEvent.hpp
Leosac::Audit::AuditEntryPtr
std::shared_ptr< AuditEntry > AuditEntryPtr
Definition: AuditFwd.hpp:81
Leosac::Audit::AccessPointEvent::target_id
Auth::AccessPointId target_id() const override
Definition: AccessPointEvent.cpp:85
AuditEntry.hpp
Leosac::Audit::AuditEntry::database
void database(DBPtr db)
Set the database pointer.
Definition: AuditEntry.cpp:144
Leosac::Audit::AccessPointEvent::access
friend class odb::access
Definition: AccessPointEvent.hpp:84
Leosac::Audit::AccessPointEvent::AccessPointEvent
AccessPointEvent()
Definition: AccessPointEvent.cpp:31
Leosac::DBPtr
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
Leosac::Audit::AccessPointEvent
Provides an implementation of IAccessPointEvent.
Definition: AccessPointEvent.hpp:33
Leosac::Audit::AccessPointEvent::after_
std::string after_
Optional JSON dump of the object after the event took place.
Definition: AccessPointEvent.hpp:82
Leosac::Auth::IAccessPointPtr
std::shared_ptr< IAccessPoint > IAccessPointPtr
Definition: AuthFwd.hpp:127
Leosac::Audit::IAccessPointEvent
Interface that describes an Audit object for AccessPoint related event.
Definition: IAccessPointEvent.hpp:33
Leosac::Audit::AccessPointEvent::create_empty
static std::shared_ptr< AccessPointEvent > create_empty()
Definition: AccessPointEvent.cpp:130
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Auth::AccessPointLWPtr
odb::lazy_weak_ptr< AccessPoint > AccessPointLWPtr
Definition: AuthFwd.hpp:131
Leosac::Audit::AccessPointEvent::before_
std::string before_
Optional JSON dump of the object before the event took place.
Definition: AccessPointEvent.hpp:77
Leosac::Audit::Factory
Provide static methods to instanciate various Audit objects.
Definition: AuditFactory.hpp:46
Leosac::Audit::AccessPointEvent::after
const std::string & after() const override
Definition: AccessPointEvent.cpp:97
Leosac::Audit::AccessPointEvent::generate_target_description
std::string generate_target_description() const
Generate a short description for the targeted AP.
Definition: AccessPointEvent.cpp:118
Leosac::Audit::AccessPointEvent::~AccessPointEvent
virtual ~AccessPointEvent()=default
Leosac::Audit::AuditEntry::parent
virtual IAuditEntryPtr parent() const override
Retrieve the parent of this entry.
Definition: AuditEntry.cpp:139
Leosac::Audit::AccessPointEvent::before
const std::string & before() const override
Definition: AccessPointEvent.cpp:92
Leosac::Audit::AccessPointEvent::create
static std::shared_ptr< AccessPointEvent > create(const DBPtr &database, Auth::IAccessPointPtr target_ap, AuditEntryPtr parent)
Definition: AccessPointEvent.cpp:37
Leosac::Audit::AccessPointEvent::target
virtual void target(Auth::IAccessPointPtr door) override
Set the AccessPoint that is targeted by the event.
Definition: AccessPointEvent.cpp:61
Leosac::Audit::AccessPointEvent::generate_description
std::string generate_description() const override
Generate a description for this event.
Definition: AccessPointEvent.cpp:102
Leosac::Audit::AuditEntry
Implementation of IAuditEntry, backed by ODB.
Definition: AuditEntry.hpp:45
Leosac::Audit::AccessPointEvent::target_
Auth::AccessPointLWPtr target_
Definition: AccessPointEvent.hpp:70
Leosac::Auth::AccessPointId
unsigned long AccessPointId
Definition: AuthFwd.hpp:128