libgpiod  2.1
edge-event-buffer.hpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-3.0-or-later */
2 /* SPDX-FileCopyrightText: 2021-2022 Bartosz Golaszewski <brgl@bgdev.pl> */
3 
8 #ifndef __LIBGPIOD_CXX_EDGE_EVENT_BUFFER_HPP__
9 #define __LIBGPIOD_CXX_EDGE_EVENT_BUFFER_HPP__
10 
11 #if !defined(__LIBGPIOD_GPIOD_CXX_INSIDE__)
12 #error "Only gpiod.hpp can be included directly."
13 #endif
14 
15 #include <cstddef>
16 #include <iostream>
17 #include <memory>
18 #include <vector>
19 
20 namespace gpiod {
21 
22 class edge_event;
23 class line_request;
24 
37 class edge_event_buffer final
38 {
39 public:
40 
45  using const_iterator = ::std::vector<edge_event>::const_iterator;
46 
52  explicit edge_event_buffer(::std::size_t capacity = 64);
53 
54  edge_event_buffer(const edge_event_buffer& other) = delete;
55 
60  edge_event_buffer(edge_event_buffer&& other) noexcept;
61 
63 
64  edge_event_buffer& operator=(const edge_event_buffer& other) = delete;
65 
71  edge_event_buffer& operator=(edge_event_buffer&& other) noexcept;
72 
78  const edge_event& get_event(unsigned int index) const;
79 
84  ::std::size_t num_events() const;
85 
90  ::std::size_t capacity() const noexcept;
91 
97  const_iterator begin() const noexcept;
98 
104  const_iterator end() const noexcept;
105 
106 private:
107 
108  struct impl;
109 
110  ::std::unique_ptr<impl> _m_priv;
111 
112  friend line_request;
113 };
114 
121 ::std::ostream& operator<<(::std::ostream& out, const edge_event_buffer& buf);
122 
127 } /* namespace gpiod */
128 
129 #endif /* __LIBGPIOD_CXX_EDGE_EVENT_BUFFER_HPP__ */
edge_event_buffer(::std::size_t capacity=64)
Constructor.
const_iterator begin() const noexcept
Get a constant iterator to the first edge event currently stored in the buffer.
::std::vector< edge_event >::const_iterator const_iterator
Constant iterator for iterating over edge events stored in the buffer.
Immutable object containing data about a single edge event.
Definition: edge-event.hpp:33
Stores the context of a set of requested GPIO lines.
::std::size_t num_events() const
Get the number of edge events currently stored in the buffer.
::std::size_t capacity() const noexcept
Maximum capacity of the buffer.
Object into which edge events are read for better performance.
const edge_event & get_event(unsigned int index) const
Get the constant reference to the edge event at given index.
const_iterator end() const noexcept
Get a constant iterator to the element after the last edge event in the buffer.