Leosac  0.8.0
Open Source Access Control
LibgpiodConfig.cpp
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 #include "LibgpiodConfig.hpp"
21 #include "tools/Colorize.hpp"
23 #include "tools/log.hpp"
24 #include <boost/algorithm/string.hpp>
25 
26 using namespace Leosac::Module::Libgpiod;
27 
28 LibgpiodConfig::LibgpiodConfig(const boost::property_tree::ptree &cfg)
29 {
30  Tools::PropertyTreeExtractor extractor(cfg, "Libgpiod");
31 
32  consumer_ = extractor.get<std::string>("consumer");
33 
34  using namespace Colorize;
35  INFO("Libgpiod Configuration:"
36  << std::endl
37  << '\t' << "Consumer: " << green(consumer_)
38  << std::endl);
39 }
40 
41 const std::string &LibgpiodConfig::consumer() const
42 {
43  return consumer_;
44 }
Leosac::Tools::PropertyTreeExtractor::get
T get(const std::string &node_name)
Extract a mandatory property from the tree.
Definition: PropertyTreeExtractor.cpp:36
INFO
@ INFO
Definition: log.hpp:34
Colorize.hpp
PropertyTreeExtractor.hpp
Leosac::Module::Libgpiod::LibgpiodConfig::LibgpiodConfig
LibgpiodConfig(const boost::property_tree::ptree &cfg)
Construct the general config object from the configuration tree.
Definition: LibgpiodConfig.cpp:28
Leosac::Module::Libgpiod
Namespace for the module that implements GPIO support using the Linux Kernel libgpiod interface.
Definition: LibgpiodConfig.hpp:32
Leosac::Colorize::green
std::string green(const T &in)
Definition: Colorize.hpp:82
Leosac::Tools::PropertyTreeExtractor
This class is a simpler helper to extract value from a property tree.
Definition: PropertyTreeExtractor.hpp:38
log.hpp
Leosac::Module::Libgpiod::LibgpiodConfig::consumer
const std::string & consumer() const
Returns the consumer name that will be temporary assigned to the GPIO.
Definition: LibgpiodConfig.cpp:41
Leosac::Module::Libgpiod::LibgpiodConfig::consumer_
std::string consumer_
The consumer name that will be temporary assigned to the GPIO.
Definition: LibgpiodConfig.hpp:56
LibgpiodConfig.hpp