Leosac  0.8.0
Open Source Access Control
MqttModule.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2022 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 "MqttExternalServer.hpp"
23 #include "zmqpp/zmqpp.hpp"
24 #include <boost/property_tree/ptree.hpp>
25 #include <modules/BaseModule.hpp>
26 
27 namespace Leosac
28 {
29 namespace Module
30 {
31 
37 namespace Mqtt
38 {
39 class MqttConfig;
40 class MqttServerConfig;
41 
45 class MqttModule : public BaseModule
46 {
47  public:
48  MqttModule(zmqpp::context &ctx, zmqpp::socket *pipe,
49  const boost::property_tree::ptree &cfg, CoreUtilsPtr utils);
50 
51  ~MqttModule() override;
52 
53  virtual void run() override;
54 
55  private:
59  void process_config();
60 
64  void load_db_config();
65 
70  void load_xml_config(const boost::property_tree::ptree &module_config);
71 
75  std::vector<MqttExternalServer> servers_;
76 
80  std::unique_ptr<MqttConfig> mqtt_config_;
81 };
82 }
83 }
84 }
Leosac::Module::Mqtt::MqttModule::load_xml_config
void load_xml_config(const boost::property_tree::ptree &module_config)
Load the module configuration from the XML configuration object.
Definition: MqttModule.cpp:155
Leosac::Module::BaseModule
Base class for module implementation.
Definition: BaseModule.hpp:110
Leosac::Module::Mqtt::MqttModule::run
virtual void run() override
This is the main loop of the module.
Definition: MqttModule.cpp:84
BaseModule.hpp
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
MqttExternalServer.hpp
Leosac::Module::Mqtt::MqttModule::servers_
std::vector< MqttExternalServer > servers_
Vector of mqtt connections managed by this module.
Definition: MqttModule.hpp:75
Leosac::Module::Mqtt::MqttModule::load_db_config
void load_db_config()
Load the module configuration from the database.
Definition: MqttModule.cpp:97
Leosac::Module::Mqtt::MqttModule
This simply is the main class for the Wiegand module.
Definition: MqttModule.hpp:45
Leosac::Module::Mqtt::MqttModule::process_config
void process_config()
Create Mqtt server instances based on configuration.
Definition: MqttModule.cpp:53
Leosac::CoreUtilsPtr
std::shared_ptr< CoreUtils > CoreUtilsPtr
Definition: LeosacFwd.hpp:35
Leosac::Module::Mqtt::MqttModule::MqttModule
MqttModule(zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
Definition: MqttModule.cpp:36
Leosac::Module::Mqtt::MqttModule::mqtt_config_
std::unique_ptr< MqttConfig > mqtt_config_
Configuration object for the module.
Definition: MqttModule.hpp:80
Leosac::Module::Mqtt::MqttModule::~MqttModule
~MqttModule() override
Definition: MqttModule.cpp:49