Leosac  0.7.0
OpenSourceAccessControl
AuthTarget.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 
23 #include "tools/ISchedule.hpp"
24 #include <memory>
25 #include <string>
26 
27 namespace Leosac
28 {
29 namespace Auth
30 {
31 class AuthTarget;
32 using AuthTargetPtr = std::shared_ptr<AuthTarget>;
33 
38 {
39  public:
40  virtual ~AuthTarget() = default;
41  explicit AuthTarget(const std::string target_name);
42 
43  const std::string &name() const;
44  void name(const std::string &new_name);
45 
48 
52  bool is_always_open(const std::chrono::system_clock::time_point &tp) const;
53 
57  bool is_always_closed(const std::chrono::system_clock::time_point &tp) const;
58 
70 
71  void gpio(std::unique_ptr<Hardware::FGPIO> new_gpio);
72 
73  protected:
74  std::string name_;
75 
76  std::vector<Tools::IScheduleCPtr> always_open_;
77  std::vector<Tools::IScheduleCPtr> always_close_;
78 
82  std::unique_ptr<Hardware::FGPIO> gpio_;
83 };
84 }
85 }
std::shared_ptr< AuthTarget > AuthTargetPtr
Definition: AuthFwd.hpp:93
bool is_always_closed(const std::chrono::system_clock::time_point &tp) const
Check whether the door is in "always closed" mode at the given time point.
Definition: AuthTarget.cpp:72
std::vector< Tools::IScheduleCPtr > always_open_
Definition: AuthTarget.hpp:76
Represent an object that we are authorizing against (a door).
Definition: AuthTarget.hpp:37
std::shared_ptr< const ISchedule > IScheduleCPtr
Definition: ToolsFwd.hpp:38
A Facade to a GPIO object.
Definition: FGPIO.hpp:45
std::vector< Tools::IScheduleCPtr > always_close_
Definition: AuthTarget.hpp:77
Hardware::FGPIO * gpio()
Returns the pointer to the optional FGPIO associated with the door.
Definition: AuthTarget.cpp:51
This is the header file for a generated source file, GitSHA1.cpp.
void add_always_open_sched(const Tools::IScheduleCPtr &sched)
Definition: AuthTarget.cpp:41
std::unique_ptr< Hardware::FGPIO > gpio_
Optional GPIO associated with the door.
Definition: AuthTarget.hpp:82
const std::string & name() const
Definition: AuthTarget.cpp:25
void add_always_close_sched(const Tools::IScheduleCPtr &sched)
Definition: AuthTarget.cpp:46
virtual ~AuthTarget()=default
AuthTarget(const std::string target_name)
Definition: AuthTarget.cpp:36
bool is_always_open(const std::chrono::system_clock::time_point &tp) const
Check whether the door is in "always open" mode at the given time point.
Definition: AuthTarget.cpp:61