Debian Codegraph @

bindings/cxx/gpiodcxx/info-event.hpp

raw symbols SCIP
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /* SPDX-FileCopyrightText: 2021-2022 Bartosz Golaszewski <[email protected]> */
3
4 /**
5 * @file gpiod.h
6 */
7
8 #ifndef __LIBGPIOD_CXX_INFO_EVENT_HPP__
9 #define __LIBGPIOD_CXX_INFO_EVENT_HPP__
10
11 #if !defined(__LIBGPIOD_GPIOD_CXX_INSIDE__)
12 #error "Only gpiod.hpp can be included directly."
13 #endif
14
15 #include <cstdint>
16 #include <iostream>
17 #include <memory>
18
19 #include "timestamp.hpp"
20
21 namespace gpiod {
22
23 class chip;
24 class line_info;
25
26 /**
27 * @brief Immutable object containing data about a single line info event.
28 */
29 class info_event final
30 {
31 public:
32
33 /**
34 * @brief Types of info events.
35 */
36 enum class event_type
37 {
38 LINE_REQUESTED = 1,
39 /**< Line has been requested. */
40 LINE_RELEASED,
41 /**< Previously requested line has been released. */
42 LINE_CONFIG_CHANGED,
43 /**< Line configuration has changed. */
44 };
45
46 /**
47 * @brief Copy constructor.
48 * @param other Object to copy.
49 */
50 info_event(const info_event& other);
51
52 /**
53 * @brief Move constructor.
54 * @param other Object to move.
55 */
56 info_event(info_event&& other) noexcept;
57
58 ~info_event();
59
60 /**
61 * @brief Copy assignment operator.
62 * @param other Object to copy.
63 * @return Reference to self.
64 */
65 info_event& operator=(const info_event& other);
66
67 /**
68 * @brief Move assignment operator.
69 * @param other Object to move.
70 * @return Reference to self.
71 */
72 info_event& operator=(info_event&& other) noexcept;
73
74 /**
75 * @brief Type of this event.
76 * @return Event type.
77 */
78 event_type type() const;
79
80 /**
81 * @brief Timestamp of the event as returned by the kernel.
82 * @return Timestamp as a 64-bit unsigned integer.
83 */
84 ::std::uint64_t timestamp_ns() const noexcept;
85
86 /**
87 * @brief Get the new line information.
88 * @return Constant reference to the line info object containing the
89 * line data as read at the time of the info event.
90 */
91 const line_info& get_line_info() const noexcept;
92
93 private:
94
95 info_event();
96
97 struct impl;
98
99 ::std::shared_ptr<impl> _m_priv;
100
101 friend chip;
102 };
103
104 /**
105 * @brief Stream insertion operator for info events.
106 * @param out Output stream to write to.
107 * @param event GPIO line info event to insert into the output stream.
108 * @return Reference to out.
109 */
110 ::std::ostream& operator<<(::std::ostream& out, const info_event& event);
111
112 } /* namespace gpiod */
113
114 #endif /* __LIBGPIOD_CXX_INFO_EVENT_HPP__ */