Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
base.hpp
1 /*
2  Title --- iface/base.hpp
3 
4  Copyright (C) 2013 Giacomo Trudu - wicker25[at]gmail[dot]com
5 
6  This file is part of Rpi-hw.
7 
8  Rpi-hw is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation version 3 of the License.
11 
12  Rpi-hw is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with Rpi-hw. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #ifndef _RPI_HW_IFACE_BASE_HPP_
23 #define _RPI_HW_IFACE_BASE_HPP_
24 
25 #include <memory>
26 #include <initializer_list>
27 #include <vector>
28 
29 #include <rpi-hw/types.hpp>
30 #include <rpi-hw/exception.hpp>
31 #include <rpi-hw/utils.hpp>
32 
33 #include <rpi-hw/gpio.hpp>
34 
35 namespace rpihw { // Begin main namespace
36 
37 /*!
38  @namespace rpihw::iface
39  @brief Namespace of the interfaces.
40 */
41 
42 namespace iface { // Begin interfaces namespace
43 
44 /*!
45  @class base
46  @brief Generic interface.
47 */
48 class base {
49 
50 public:
51 
52  /*!
53  @brief Constructor method.
54  @param[in] pins Sequence of `uint8_t` containing the GPIO pins.
55  */
56  base( std::initializer_list< uint8_t > pins );
57 
58  /*!
59  @brief Constructor method.
60  @param[in] pins Vector containing the GPIO pins.
61  */
62  base( const std::vector< uint8_t > &pins );
63 
64  //! Destructor method.
65  virtual ~base();
66 
67  /*!
68  @brief Sets an interface pin.
69  @param[in] index The index position of the interface pin.
70  @param[in] pin The new GPIO pin.
71  */
72  virtual void setPin( uint8_t index, uint8_t pin );
73 
74  /*!
75  @brief Returns an interface pin.
76  @param[in] index The index position of the interface pin.
77  @return The GPIO pin.
78  */
79  virtual uint8_t getPin( uint8_t index ) const;
80 
81  //! Returns the number of the pins.
82  virtual uint8_t size() const;
83 
84 protected:
85 
86  //! Vector containing interface pins.
87  std::vector< uint8_t > m_pins;
88 
89  //! Virtual GPIO controller.
91 };
92 
93 } // End of interfaces namespace
94 
95 } // End of main namespace
96 
97 
98 // Include inline methods
99 #include <rpi-hw/iface/base-inl.hpp>
100 
101 #endif /* _RPI_HW_IFACE_BASE_HPP_ */
virtual uint8_t size() const
Returns the number of the pins.
Definition: base-inl.hpp:37
Generic interface.
Definition: base.hpp:48
base(std::initializer_list< uint8_t > pins)
Constructor method.
gpio * m_gpio
Virtual GPIO controller.
Definition: base.hpp:90
std::vector< uint8_t > m_pins
Vector containing interface pins.
Definition: base.hpp:87
Virtual GPIO controller.
Definition: gpio.hpp:63
virtual void setPin(uint8_t index, uint8_t pin)
Sets an interface pin.
virtual uint8_t getPin(uint8_t index) const
Returns an interface pin.
Definition: base-inl.hpp:30
virtual ~base()
Destructor method.