Leosac  0.8.0
Open Source Access Control
Door.cpp
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 #include "core/auth/Door.hpp"
22 #include "tools/AssertCast.hpp"
23 
24 using namespace Leosac::Auth;
25 
27  : version_(0)
28 {
29 }
30 
32 {
33  return id_;
34 }
35 
36 std::string Door::alias() const
37 {
38  return alias_;
39 }
40 
41 std::string Door::description() const
42 {
43  return desc_;
44 }
45 
46 void Door::alias(const std::string &alias)
47 {
48  alias_ = alias;
49 }
50 
51 void Door::description(const std::string &desc)
52 {
53  desc_ = desc;
54 }
55 
57 {
58  return access_point_;
59 }
60 
62 {
63  access_point_ = assert_cast<AccessPointPtr>(ptr);
64  if (access_point_)
65  access_point_->door_ = assert_cast<DoorPtr>(shared_from_this());
66 }
67 
68 std::vector<Leosac::Tools::ScheduleMappingLWPtr> Door::lazy_mapping() const
69 {
70  return schedules_mapping_;
71 }
72 
74  const Leosac::Tools::ScheduleMappingPtr &sched_mapping)
75 {
76  schedules_mapping_.push_back(sched_mapping);
77 }
78 
80 {
81  if (access_point_)
82  return access_point_->id();
83  return 0;
84 }
Leosac::Auth::Door::access_point_
std::shared_ptr< AccessPoint > access_point_
The access point that controls the door.
Definition: Door.hpp:78
AccessPoint.hpp
Leosac::Auth
Holds classes relevant to the Authentication and Authorization subsystem.
Definition: AccessPoint.hpp:27
Leosac::Auth::Door::desc_
std::string desc_
Definition: Door.hpp:71
Leosac::Auth::Door::description
virtual std::string description() const override
Definition: Door.cpp:41
Leosac::Auth::Door::schedule_mapping_added
void schedule_mapping_added(const Tools::ScheduleMappingPtr &sched_mapping)
A ScheduleMapping object has added this door as part of its mapping.
Definition: Door.cpp:73
Leosac::Auth::Door::access_point_id
virtual AccessPointId access_point_id() const override
Definition: Door.cpp:79
Leosac::Auth::Door::schedules_mapping_
std::vector< Tools::ScheduleMappingLWPtr > schedules_mapping_
ScheduleMapping that maps this door.
Definition: Door.hpp:84
Leosac::Tools::ScheduleMappingPtr
std::shared_ptr< ScheduleMapping > ScheduleMappingPtr
Definition: ToolsFwd.hpp:41
Leosac::Auth::IAccessPointPtr
std::shared_ptr< IAccessPoint > IAccessPointPtr
Definition: AuthFwd.hpp:127
Door.hpp
Leosac::Auth::Door::lazy_mapping
virtual std::vector< Tools::ScheduleMappingLWPtr > lazy_mapping() const override
Retrieve the lazy pointers to the ScheduleMapping objects that map this door.
Definition: Door.cpp:68
Leosac::Auth::DoorId
unsigned long DoorId
Definition: AuthFwd.hpp:107
Leosac::Auth::Door::id_
DoorId id_
Definition: Door.hpp:68
Leosac::Auth::Door::id
virtual DoorId id() const override
Definition: Door.cpp:31
Leosac::Auth::Door::alias
virtual std::string alias() const override
Definition: Door.cpp:36
Leosac::Auth::Door::alias_
std::string alias_
Definition: Door.hpp:70
Leosac::Auth::Door::Door
Door()
Definition: Door.cpp:26
Leosac::Auth::Door::access_point
virtual IAccessPointPtr access_point() const override
Definition: Door.cpp:56
AssertCast.hpp
Leosac::Auth::AccessPointId
unsigned long AccessPointId
Definition: AuthFwd.hpp:128