Leosac  0.8.0
Open Source Access Control
wiegand.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 "WiegandReaderImpl.hpp"
23 #include "zmqpp/zmqpp.hpp"
24 #include <boost/property_tree/ptree.hpp>
25 #include <modules/BaseModule.hpp>
27 
28 namespace Leosac
29 {
30 namespace Module
31 {
32 
38 namespace Wiegand
39 {
40 class WiegandConfig;
41 class WiegandReaderConfig;
42 class WSHelperThread;
43 
48 {
49  public:
50  WiegandReaderModule(zmqpp::context &ctx, zmqpp::socket *pipe,
51  const boost::property_tree::ptree &cfg, CoreUtilsPtr utils);
52 
53  ~WiegandReaderModule() override;
54 
59  virtual void run() override;
60 
61  private:
65  void process_config();
66 
70  void load_db_config();
71 
76  void load_xml_config(const boost::property_tree::ptree &module_config);
77 
83  create_strategy(const WiegandReaderConfig &reader_config,
84  WiegandReaderImpl *reader);
85 
89  std::vector<WiegandReaderImpl> readers_;
90 
94  std::unique_ptr<WiegandConfig> wiegand_config_;
95 
96  std::unique_ptr<WSHelperThread> ws_helper_thread_;
97 };
98 }
99 }
100 }
Leosac::Module::Wiegand::WiegandReaderModule::wiegand_config_
std::unique_ptr< WiegandConfig > wiegand_config_
Configuration object for the module.
Definition: wiegand.hpp:94
Leosac::Module::BaseModule
Base class for module implementation.
Definition: BaseModule.hpp:110
Leosac::Module::Wiegand::WiegandReaderImpl
An implementation class that represents a Wiegand Reader.
Definition: WiegandReaderImpl.hpp:41
Leosac::Module::Wiegand::WiegandReaderModule::readers_
std::vector< WiegandReaderImpl > readers_
Vector of wiegand reader managed by this module.
Definition: wiegand.hpp:89
Leosac::Module::Wiegand::Strategy::WiegandStrategyUPtr
std::unique_ptr< WiegandStrategy > WiegandStrategyUPtr
Definition: WiegandStrategy.hpp:38
BaseModule.hpp
WiegandStrategy.hpp
Leosac::Module::Wiegand::WiegandReaderModule::ws_helper_thread_
std::unique_ptr< WSHelperThread > ws_helper_thread_
Definition: wiegand.hpp:96
WiegandReaderImpl.hpp
Leosac::Module::Wiegand::WiegandReaderModule::run
virtual void run() override
Module's main loop.
Definition: wiegand.cpp:122
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Module::Wiegand::WiegandReaderModule::~WiegandReaderModule
~WiegandReaderModule() override
Definition: wiegand.cpp:73
Leosac::Module::Wiegand::WiegandReaderModule::create_strategy
Strategy::WiegandStrategyUPtr create_strategy(const WiegandReaderConfig &reader_config, WiegandReaderImpl *reader)
Internal factory that build a strategy object based upon a reader configuration.
Definition: wiegand.cpp:143
Leosac::Module::Wiegand::WiegandReaderModule::load_xml_config
void load_xml_config(const boost::property_tree::ptree &module_config)
Load the module configuration from the XML configuration object.
Definition: wiegand.cpp:241
Leosac::Module::Wiegand::WiegandReaderModule
This simply is the main class for the Wiegand module.
Definition: wiegand.hpp:47
Leosac::Module::Wiegand::WiegandReaderModule::WiegandReaderModule
WiegandReaderModule(zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
Definition: wiegand.cpp:57
Leosac::Module::Wiegand::WiegandReaderModule::process_config
void process_config()
Create wiegand reader instances based on configuration.
Definition: wiegand.cpp:81
Leosac::Module::Wiegand::WiegandReaderConfig
An instance of this class represents the configuration of one Wiegand reader.
Definition: WiegandConfig.hpp:46
Leosac::CoreUtilsPtr
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35
Leosac::Module::Wiegand::WiegandReaderModule::load_db_config
void load_db_config()
Load the module configuration from the database.
Definition: wiegand.cpp:197