Leosac  0.8.0
Open Source Access Control
DoormanModule.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/AuthTarget.hpp"
24 #include "modules/BaseModule.hpp"
26 #include <boost/property_tree/ptree.hpp>
27 #include <memory>
28 #include <vector>
29 #include <zmqpp/zmqpp.hpp>
30 
31 namespace Leosac
32 {
33 namespace Module
34 {
41 namespace Doorman
42 {
43 
44 class DoormanInstance;
45 
52 class DoormanModule : public BaseModule
53 {
54  public:
55  DoormanModule(zmqpp::context &ctx, zmqpp::socket *pipe,
56  const boost::property_tree::ptree &cfg, CoreUtilsPtr utils);
57 
58  DoormanModule(const DoormanModule &) = delete;
59 
60  DoormanModule &operator=(const DoormanModule &) = delete;
61 
62  ~DoormanModule() = default;
63 
64  virtual void run() override;
65 
66  const std::vector<Auth::AuthTargetPtr> &doors() const;
67 
68  private:
69  void update();
70 
76  void process_config();
77 
78  void process_doors_config(const boost::property_tree::ptree &t);
79 
83  std::vector<std::shared_ptr<DoormanInstance>> doormen_;
84 
88  std::vector<Auth::AuthTargetPtr> doors_;
89 };
90 }
91 }
92 }
FGPIO.hpp
Leosac::Module::BaseModule
Base class for module implementation.
Definition: BaseModule.hpp:110
AuthTarget.hpp
BaseModule.hpp
Leosac::Module::Doorman::DoormanModule::doormen_
std::vector< std::shared_ptr< DoormanInstance > > doormen_
Authenticator instances.
Definition: DoormanModule.hpp:83
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
XmlScheduleLoader.hpp
Leosac::Module::Doorman::DoormanModule::doors_
std::vector< Auth::AuthTargetPtr > doors_
Doors, to manage the always-on or always off stuff.
Definition: DoormanModule.hpp:88
Leosac::Module::Doorman::DoormanModule::operator=
DoormanModule & operator=(const DoormanModule &)=delete
Leosac::Module::Doorman::DoormanModule::DoormanModule
DoormanModule(zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
Definition: DoormanModule.cpp:30
Leosac::Module::Doorman::DoormanModule::run
virtual void run() override
This is the main loop of the module.
Definition: DoormanModule.cpp:111
Leosac::Module::Doorman::DoormanModule::update
void update()
Definition: DoormanModule.cpp:179
Leosac::Module::Doorman::DoormanModule::process_doors_config
void process_doors_config(const boost::property_tree::ptree &t)
Definition: DoormanModule.cpp:120
Leosac::Module::Doorman::DoormanModule::process_config
void process_config()
Processing the configuration tree, spawning AuthFileInstance object as described in the configuration...
Definition: DoormanModule.cpp:58
Leosac::Module::Doorman::DoormanModule::~DoormanModule
~DoormanModule()=default
Leosac::CoreUtilsPtr
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35
Leosac::Module::Doorman::DoormanModule::doors
const std::vector< Auth::AuthTargetPtr > & doors() const
Definition: DoormanModule.cpp:189
Leosac::Module::Doorman::DoormanModule
Main class for the module, it create handlers and run them to, well, handle events and send command.
Definition: DoormanModule.hpp:52