Leosac  0.7.0
OpenSourceAccessControl
Autodetect.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 "Strategies.hpp"
23 
24 namespace Leosac
25 {
26 namespace Module
27 {
28 
29 namespace Wiegand
30 {
31 namespace Strategy
32 {
43 {
44  public:
54  Autodetect(WiegandReaderImpl *reader, std::chrono::milliseconds delay,
55  char pin_key_end);
56 
57  virtual void timeout() override;
58 
59  virtual bool completed() const override;
60 
61  virtual void signal(zmqpp::socket &sock) override;
62 
63  virtual void set_reader(WiegandReaderImpl *new_ptr) override;
64 
65  private:
71  void reset() override;
72 
84 
88  void check_timeout();
89 
92 
93  std::chrono::milliseconds delay_;
94  using TimePoint = std::chrono::system_clock::time_point;
97 
100  bool ready_;
101 
103 };
104 }
105 }
106 }
107 }
Variable strategy that tries to autodetect what it reads.
Definition: Autodetect.hpp:42
An implementation class that represents a Wiegand Reader.
This is the header file for a generated source file, GitSHA1.cpp.
std::unique_ptr< CardReading > CardReadingUPtr
Definition: CardReading.hpp:34
std::unique_ptr< PinReading > PinReadingUPtr
The multiple modes available to wiegand reader are implemented through the strategy pattern...
void check_timeout()
Called when timeout() was called but nothing was read.
Definition: Autodetect.cpp:86
PinReadingUPtr build_strategy(int bits)
Dynamically instanciate a new strategy based on the number of bits available.
Definition: Autodetect.cpp:177
virtual void set_reader(WiegandReaderImpl *new_ptr) override
Update the pointer that points back to the associated reader.
Definition: Autodetect.cpp:157
virtual void timeout() override
This is called when the module detect a timeout.
Definition: Autodetect.cpp:42
virtual bool completed() const override
Did the strategy gather needed data? If this function returns true, that means that the strategy impl...
Definition: Autodetect.cpp:128
std::chrono::system_clock::time_point TimePoint
Definition: Autodetect.hpp:94
virtual void signal(zmqpp::socket &sock) override
Tells the strategy implementation to send a message to the application containing the received creden...
Definition: Autodetect.cpp:133
Autodetect(WiegandReaderImpl *reader, std::chrono::milliseconds delay, char pin_key_end)
Create a strategy that read whatever it can and tries its best to determine what is was that it read...
Definition: Autodetect.cpp:27