Leosac  0.8.0
Open Source Access Control
GPIO.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2017 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 "hardware/Device.hpp"
23 #include "hardware/HardwareFwd.hpp"
24 #include <cstdint>
25 #include <odb/callback.hxx>
26 #include <odb/core.hxx>
27 #include <string>
28 
29 namespace Leosac
30 {
31 namespace Hardware
32 {
33 
40 #pragma db object callback(validation_callback) table("HARDWARE_GPIO")
41 class GPIO : public Device
42 {
43  public:
44  enum class Direction
45  {
46  In = 0,
47  Out = 1
48  };
49 
50  explicit GPIO();
51  virtual ~GPIO() = default;
52 
53  uint16_t number() const;
54 
55  void number(uint16_t number);
56 
57  Direction direction() const;
58 
60 
61  bool default_value() const;
62 
63  void default_value(bool default_value);
64 
65  void validation_callback(odb::callback_event e, odb::database &) const override;
66 
67  private:
68  uint16_t number_;
69 
71 
76 
77  friend odb::access;
78 };
79 }
80 }
Leosac::Hardware::GPIO::GPIO
GPIO()
Definition: GPIO.cpp:28
Leosac::Hardware::GPIO::Direction::Out
@ Out
Leosac::Hardware::GPIO::number
uint16_t number() const
Definition: GPIO.cpp:36
Leosac::Hardware::GPIO::direction_
Direction direction_
Definition: GPIO.hpp:70
Leosac::Hardware::GPIO::default_value
bool default_value() const
Definition: GPIO.cpp:56
Leosac::Hardware::Device
Base class for hardware devices.
Definition: Device.hpp:44
Leosac::Hardware::GPIO::number_
uint16_t number_
Definition: GPIO.hpp:68
Device.hpp
Leosac::Hardware::GPIO::validation_callback
void validation_callback(odb::callback_event e, odb::database &) const override
Definition: GPIO.cpp:66
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Hardware::GPIO::direction
Direction direction() const
Definition: GPIO.cpp:46
Leosac::Hardware::GPIO::default_value_
bool default_value_
True to default to ON, false otherwise.
Definition: GPIO.hpp:75
Leosac::Hardware::GPIO::Direction
Direction
Definition: GPIO.hpp:44
HardwareFwd.hpp
Leosac::Hardware::GPIO::~GPIO
virtual ~GPIO()=default
Leosac::Hardware::GPIO::Direction::In
@ In
Leosac::Hardware::GPIO
Abstraction of a GPIO device attributes.
Definition: GPIO.hpp:41