Leosac  0.8.0
Open Source Access Control
DoorEvent.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 "IDoorEvent.hpp"
24 
25 namespace Leosac
26 {
27 namespace Audit
28 {
32 #pragma db object polymorphic callback(odb_callback)
33 class DoorEvent : virtual public IDoorEvent, public AuditEntry
34 {
35  private:
36  DoorEvent();
37 
38  friend class Factory;
39 
40  static std::shared_ptr<DoorEvent>
42 
43  public:
44  virtual ~DoorEvent() = default;
45 
46  static std::shared_ptr<DoorEvent> create_empty();
47 
48  virtual void target(Auth::IDoorPtr door) override;
49 
50  virtual Auth::DoorId target_id() const override;
51 
52  virtual void before(const std::string &repr) override;
53 
54  virtual void after(const std::string &repr) override;
55 
56  virtual const std::string &before() const override;
57 
58  virtual const std::string &after() const override;
59 
60  virtual Auth::AccessPointId access_point_id_before() const override;
61 
62  virtual void access_point_id_before(Auth::AccessPointId id) override;
63 
64  virtual Auth::AccessPointId access_point_id_after() const override;
65 
66  virtual void access_point_id_after(Auth::AccessPointId id) override;
67 
68  virtual std::string generate_description() const override;
69 
70  public:
74  std::string generate_target_description() const;
75 
76 #pragma db on_delete(set_null)
78 
80 
84  std::string before_;
85 
89  std::string after_;
90 
99 
106 
107  friend class odb::access;
108 };
109 }
110 }
111 
112 #ifdef ODB_COMPILER
113 #include "core/auth/Door.hpp"
114 #endif
Leosac::Audit::DoorEvent::target_door_id_
Auth::DoorId target_door_id_
Definition: DoorEvent.hpp:79
Leosac::Audit::DoorEvent::~DoorEvent
virtual ~DoorEvent()=default
Leosac::Audit::DoorEvent
Provides an implementation of IDoorEvent.
Definition: DoorEvent.hpp:33
Leosac::Audit::AuditEntryPtr
std::shared_ptr< AuditEntry > AuditEntryPtr
Definition: AuditFwd.hpp:81
AuditEntry.hpp
Leosac::Audit::IDoorEvent
Interface that describes an Audit object for door related event.
Definition: IDoorEvent.hpp:32
Leosac::Audit::DoorEvent::create_empty
static std::shared_ptr< DoorEvent > create_empty()
Definition: DoorEvent.cpp:130
Leosac::Audit::DoorEvent::before_
std::string before_
Optional JSON dump of the object before the event took place.
Definition: DoorEvent.hpp:84
Leosac::Audit::AuditEntry::database
void database(DBPtr db)
Set the database pointer.
Definition: AuditEntry.cpp:144
Leosac::Audit::DoorEvent::access_point_id_before
virtual Auth::AccessPointId access_point_id_before() const override
Return the id of the associated access_point before the event took place.
Definition: DoorEvent.cpp:135
Leosac::DBPtr
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
Leosac::Audit::DoorEvent::after
virtual const std::string & after() const override
Definition: DoorEvent.cpp:99
Leosac::Audit::DoorEvent::target_id
virtual Auth::DoorId target_id() const override
Definition: DoorEvent.cpp:87
IDoorEvent.hpp
Leosac::Audit::DoorEvent::access_point_id_after_
Auth::AccessPointId access_point_id_after_
The id of associated AP after the event.
Definition: DoorEvent.hpp:105
Leosac::Audit::DoorEvent::generate_target_description
std::string generate_target_description() const
Generate a short description for the targeted door.
Definition: DoorEvent.cpp:118
Leosac::Audit::DoorEvent::after_
std::string after_
Optional JSON dump of the object after the event took place.
Definition: DoorEvent.hpp:89
Leosac::Audit::DoorEvent::target
virtual void target(Auth::IDoorPtr door) override
Set the door that is targeted by the event.
Definition: DoorEvent.cpp:63
Door.hpp
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Audit::DoorEvent::access_point_id_before_
Auth::AccessPointId access_point_id_before_
The id of the associated AP before the event.
Definition: DoorEvent.hpp:98
Leosac::Auth::DoorId
unsigned long DoorId
Definition: AuthFwd.hpp:107
Leosac::Audit::DoorEvent::target_
Auth::DoorLWPtr target_
Definition: DoorEvent.hpp:77
Leosac::Audit::DoorEvent::DoorEvent
DoorEvent()
Definition: DoorEvent.cpp:31
Leosac::Audit::Factory
Provide static methods to instanciate various Audit objects.
Definition: AuditFactory.hpp:46
Leosac::Audit::DoorEvent::create
static std::shared_ptr< DoorEvent > create(const DBPtr &database, Auth::IDoorPtr target_door, AuditEntryPtr parent)
Definition: DoorEvent.cpp:38
Leosac::Auth::IDoorPtr
std::shared_ptr< IDoor > IDoorPtr
Definition: AuthFwd.hpp:104
Leosac::Audit::AuditEntry::parent
virtual IAuditEntryPtr parent() const override
Retrieve the parent of this entry.
Definition: AuditEntry.cpp:139
Leosac::Audit::DoorEvent::access
friend class odb::access
Definition: DoorEvent.hpp:107
Leosac::Audit::DoorEvent::access_point_id_after
virtual Auth::AccessPointId access_point_id_after() const override
Return the id of the associated access_point after the event took place.
Definition: DoorEvent.cpp:145
Leosac::Audit::AuditEntry
Implementation of IAuditEntry, backed by ODB.
Definition: AuditEntry.hpp:45
Leosac::Audit::DoorEvent::before
virtual const std::string & before() const override
Definition: DoorEvent.cpp:94
Leosac::Audit::DoorEvent::generate_description
virtual std::string generate_description() const override
Generate a description for this event.
Definition: DoorEvent.cpp:104
Leosac::Auth::AccessPointId
unsigned long AccessPointId
Definition: AuthFwd.hpp:128
Leosac::Auth::DoorLWPtr
odb::lazy_weak_ptr< Door > DoorLWPtr
Definition: AuthFwd.hpp:110