| 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 | /* SPDX-FileCopyrightText: 2022 Bartosz Golaszewski <[email protected]> */ |
| 3 | |
| 4 | /** |
| 5 | * @file chip-info.hpp |
| 6 | */ |
| 7 | |
| 8 | #ifndef __LIBGPIOD_CXX_CHIP_INFO_HPP__ |
| 9 | #define __LIBGPIOD_CXX_CHIP_INFO_HPP__ |
| 10 | |
| 11 | #if !defined(__LIBGPIOD_GPIOD_CXX_INSIDE__) |
| 12 | #error "Only gpiod.hpp can be included directly." |
| 13 | #endif |
| 14 | |
| 15 | #include <memory> |
| 16 | #include <ostream> |
| 17 | |
| 18 | namespace gpiod { |
| 19 | |
| 20 | class chip; |
| 21 | |
| 22 | /** |
| 23 | * @brief Represents an immutable snapshot of GPIO chip information. |
| 24 | */ |
| 25 | class chip_info final |
| 26 | { |
| 27 | public: |
| 28 | |
| 29 | /** |
| 30 | * @brief Copy constructor. |
| 31 | * @param other Object to copy. |
| 32 | */ |
| 33 | chip_info(const chip_info& other); |
| 34 | |
| 35 | /** |
| 36 | * @brief Move constructor. |
| 37 | * @param other Object to move. |
| 38 | */ |
| 39 | chip_info(chip_info&& other) noexcept; |
| 40 | |
| 41 | ~chip_info(); |
| 42 | |
| 43 | /** |
| 44 | * @brief Assignment operator. |
| 45 | * @param other Object to copy. |
| 46 | * @return Reference to self. |
| 47 | */ |
| 48 | chip_info& operator=(const chip_info& other); |
| 49 | |
| 50 | /** |
| 51 | * @brief Move assignment operator. |
| 52 | * @param other Object to move. |
| 53 | * @return Reference to self. |
| 54 | */ |
| 55 | chip_info& operator=(chip_info&& other) noexcept; |
| 56 | |
| 57 | /** |
| 58 | * @brief Get the name of this GPIO chip. |
| 59 | * @return String containing the chip name. |
| 60 | */ |
| 61 | ::std::string name() const noexcept; |
| 62 | |
| 63 | /** |
| 64 | * @brief Get the label of this GPIO chip. |
| 65 | * @return String containing the chip name. |
| 66 | */ |
| 67 | ::std::string label() const noexcept; |
| 68 | |
| 69 | /** |
| 70 | * @brief Return the number of lines exposed by this chip. |
| 71 | * @return Number of lines. |
| 72 | */ |
| 73 | ::std::size_t num_lines() const noexcept; |
| 74 | |
| 75 | private: |
| 76 | |
| 77 | chip_info(); |
| 78 | |
| 79 | struct impl; |
| 80 | |
| 81 | ::std::shared_ptr<impl> _m_priv; |
| 82 | |
| 83 | friend chip; |
| 84 | }; |
| 85 | |
| 86 | /** |
| 87 | * @brief Stream insertion operator for GPIO chip objects. |
| 88 | * @param out Output stream to write to. |
| 89 | * @param chip GPIO chip to insert into the output stream. |
| 90 | * @return Reference to out. |
| 91 | */ |
| 92 | ::std::ostream& operator<<(::std::ostream& out, const chip_info& chip); |
| 93 | |
| 94 | } /* namespace gpiod */ |
| 95 | |
| 96 | #endif /* __LIBGPIOD_CXX_CHIP_INFO_HPP__ */ |