Leosac  0.8.0
Open Source Access Control
WiegandStrategy.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 "core/auth/Auth.hpp"
23 #include "zmqpp/zmqpp.hpp"
24 #include <boost/any.hpp>
25 #include <chrono>
26 #include <string>
27 
28 namespace Leosac
29 {
30 namespace Module
31 {
32 namespace Wiegand
33 {
34 class WiegandReaderImpl;
35 namespace Strategy
36 {
37 class WiegandStrategy;
38 using WiegandStrategyUPtr = std::unique_ptr<WiegandStrategy>;
39 
51 {
52  public:
54  : reader_(reader)
55  {
56  }
57 
58  virtual ~WiegandStrategy() = default;
59 
63  virtual void timeout() = 0;
64 
74  virtual bool completed() const = 0;
75 
85  virtual void signal(zmqpp::socket &sock) = 0;
86 
94  virtual void reset() = 0;
95 
99  virtual void set_reader(WiegandReaderImpl *new_ptr)
100  {
101  reader_ = new_ptr;
102  }
103 
104  // we may add the handle_msg here, because some mode may want to
105  // have "lower-level" access to gpio event.
106 
107  friend class WiegandReaderImpl;
108 
109  protected:
111 };
112 }
113 }
114 }
115 }
Leosac::Module::Wiegand::WiegandReaderImpl
An implementation class that represents a Wiegand Reader.
Definition: WiegandReaderImpl.hpp:41
Auth.hpp
Leosac::Module::Wiegand::Strategy::WiegandStrategyUPtr
std::unique_ptr< WiegandStrategy > WiegandStrategyUPtr
Definition: WiegandStrategy.hpp:38
Leosac::Module::Wiegand::Strategy::WiegandStrategy::timeout
virtual void timeout()=0
This is called when the module detect a timeout.
Leosac::Module::Wiegand::Strategy::WiegandStrategy::set_reader
virtual void set_reader(WiegandReaderImpl *new_ptr)
Update the pointer that points back to the associated reader.
Definition: WiegandStrategy.hpp:99
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Module::Wiegand::Strategy::WiegandStrategy::~WiegandStrategy
virtual ~WiegandStrategy()=default
Leosac::Module::Wiegand::Strategy::WiegandStrategy
The multiple modes available to wiegand reader are implemented through the strategy pattern.
Definition: WiegandStrategy.hpp:50
Leosac::Module::Wiegand::Strategy::WiegandStrategy::WiegandStrategy
WiegandStrategy(WiegandReaderImpl *reader)
Definition: WiegandStrategy.hpp:53
Leosac::Module::Wiegand::Strategy::WiegandStrategy::reader_
WiegandReaderImpl * reader_
Definition: WiegandStrategy.hpp:110
Leosac::Module::Wiegand::Strategy::WiegandStrategy::signal
virtual void signal(zmqpp::socket &sock)=0
Tells the strategy implementation to send a message to the application containing the received creden...
Leosac::Module::Wiegand::Strategy::WiegandStrategy::reset
virtual void reset()=0
Reset the strategy, meaning that the next time timeout() is called the behavior should be the same th...
Leosac::Module::Wiegand::Strategy::WiegandStrategy::completed
virtual bool completed() const =0
Did the strategy gather needed data? If this function returns true, that means that the strategy impl...