zpp
Zephyr C++20 Framework
zpp::poll_event Class Reference

wrapper class around a k_poll_event More...

#include <poll_event.hpp>

Public Types

enum class  type_tag : uint8_t {
  type_unknown , type_sem , type_fifo , type_signal ,
  type_ignore
}
 type of event sources More...
 

Public Member Functions

 poll_event (k_poll_event *event) noexcept
 wrap a k_poll_event pointer More...
 
void assign (std::nullptr_t) noexcept
 assign a null event (that will be ignored when polling) More...
 
void assign (sem &s) noexcept
 assign a semaphore to this event More...
 
void assign (sem_ref &s) noexcept
 assign a semaphore to this event More...
 
template<typename T_FifoItem >
void assign (fifo< T_FifoItem > &f) noexcept
 assign a fifo to this event More...
 
template<typename T_FifoItem >
void assign (fifo_ref< T_FifoItem > &f) noexcept
 assign a fifo to this event More...
 
void assign (poll_signal &s) noexcept
 assign a signal to this event More...
 
void assign (poll_signal_ref &s) noexcept
 assign a signal to this event More...
 
bool is_ready () noexcept
 check if this event is ready More...
 
void reset () noexcept
 reset event to non ready state More...
 
bool is_cancelled () noexcept
 check if this event is cancelled More...
 
template<typename T_FifoItemType >
auto fifo () noexcept
 get access to the fifo of the event More...
 
auto sem () noexcept
 get access to the sem of the event More...
 
auto signal () noexcept
 get access to the signal of the event More...
 
 poll_event (const poll_event &)=delete
 
 poll_event (poll_event &&)=delete
 
poll_eventoperator= (const poll_event &)=delete
 
poll_eventoperator= (poll_event &&)=delete
 

Detailed Description

wrapper class around a k_poll_event

Definition at line 29 of file poll_event.hpp.

Member Enumeration Documentation

◆ type_tag

enum zpp::poll_event::type_tag : uint8_t
strong

type of event sources

Enumerator
type_unknown 
type_sem 
type_fifo 
type_signal 
type_ignore 

Definition at line 34 of file poll_event.hpp.

34  : uint8_t {
35  type_unknown,
36  type_sem,
37  type_fifo,
38  type_signal,
39  type_ignore,
40  };

Constructor & Destructor Documentation

◆ poll_event() [1/3]

zpp::poll_event::poll_event ( k_poll_event *  event)
inlinenoexcept

wrap a k_poll_event pointer

Parameters
eventthe event to wrap

Definition at line 47 of file poll_event.hpp.

48  : m_event(event)
49  {
50  __ASSERT_NO_MSG(m_event != nullptr);
51  }

◆ poll_event() [2/3]

zpp::poll_event::poll_event ( const poll_event )
delete

◆ poll_event() [3/3]

zpp::poll_event::poll_event ( poll_event &&  )
delete

Member Function Documentation

◆ assign() [1/7]

template<typename T_FifoItem >
void zpp::poll_event::assign ( fifo< T_FifoItem > &  f)
inlinenoexcept

assign a fifo to this event

Parameters
fthe fifo to poll

Definition at line 103 of file poll_event.hpp.

104  {
105  __ASSERT_NO_MSG(m_event != nullptr);
106  k_poll_event_init(m_event,
107  K_POLL_TYPE_FIFO_DATA_AVAILABLE,
108  K_POLL_MODE_NOTIFY_ONLY,
109  f.native_handle());
110  m_event->tag = (int)type_tag::type_fifo;
111  }

References type_fifo.

◆ assign() [2/7]

template<typename T_FifoItem >
void zpp::poll_event::assign ( fifo_ref< T_FifoItem > &  f)
inlinenoexcept

assign a fifo to this event

Parameters
fthe fifo to poll

Definition at line 119 of file poll_event.hpp.

120  {
121  __ASSERT_NO_MSG(m_event != nullptr);
122  k_poll_event_init(m_event,
123  K_POLL_TYPE_FIFO_DATA_AVAILABLE,
124  K_POLL_MODE_NOTIFY_ONLY,
125  f.native_handle());
126  m_event->tag = (int)type_tag::type_fifo;
127  }

References type_fifo.

◆ assign() [3/7]

void zpp::poll_event::assign ( poll_signal s)
inlinenoexcept

assign a signal to this event

Parameters
sthe signal to poll

Definition at line 134 of file poll_event.hpp.

135  {
136  __ASSERT_NO_MSG(m_event != nullptr);
137  k_poll_event_init(m_event,
138  K_POLL_TYPE_SIGNAL,
139  K_POLL_MODE_NOTIFY_ONLY,
140  s.native_handle());
141  m_event->tag = (int)type_tag::type_signal;
142  }

References type_signal.

◆ assign() [4/7]

void zpp::poll_event::assign ( poll_signal_ref s)
inlinenoexcept

assign a signal to this event

Parameters
sthe signal to poll

Definition at line 149 of file poll_event.hpp.

150  {
151  __ASSERT_NO_MSG(m_event != nullptr);
152  k_poll_event_init(m_event,
153  K_POLL_TYPE_SIGNAL,
154  K_POLL_MODE_NOTIFY_ONLY,
155  s.native_handle());
156  m_event->tag = (int)type_tag::type_signal;
157  }

References type_signal.

◆ assign() [5/7]

void zpp::poll_event::assign ( sem s)
inlinenoexcept

assign a semaphore to this event

Parameters
sthe semaphore to poll

Definition at line 72 of file poll_event.hpp.

73  {
74  __ASSERT_NO_MSG(m_event != nullptr);
75  k_poll_event_init(m_event,
76  K_POLL_TYPE_SEM_AVAILABLE,
77  K_POLL_MODE_NOTIFY_ONLY,
78  s.native_handle());
79  m_event->tag = (int)type_tag::type_sem;
80  }

References type_sem.

◆ assign() [6/7]

void zpp::poll_event::assign ( sem_ref s)
inlinenoexcept

assign a semaphore to this event

Parameters
sthe semaphore to poll

Definition at line 87 of file poll_event.hpp.

88  {
89  __ASSERT_NO_MSG(m_event != nullptr);
90  k_poll_event_init(m_event,
91  K_POLL_TYPE_SEM_AVAILABLE,
92  K_POLL_MODE_NOTIFY_ONLY,
93  s.native_handle());
94  m_event->tag = (int)type_tag::type_sem;
95  }

References type_sem.

◆ assign() [7/7]

void zpp::poll_event::assign ( std::nullptr_t  )
inlinenoexcept

assign a null event (that will be ignored when polling)

Definition at line 56 of file poll_event.hpp.

57  {
58  __ASSERT_NO_MSG(m_event != nullptr);
59 
60  m_event->obj = nullptr;
61  m_event->state = K_POLL_STATE_NOT_READY;
62  m_event->mode = K_POLL_MODE_NOTIFY_ONLY;
63  m_event->type = K_POLL_TYPE_IGNORE;
64  m_event->tag = (int)type_tag::type_ignore;
65  }

References type_ignore.

◆ fifo()

template<typename T_FifoItemType >
auto zpp::poll_event::fifo ( )
inlinenoexcept

get access to the fifo of the event

Warning
the event must be an fifo event and the fifo ItemType must match with the registerred ItemType
Returns
a fifo_ref that points to the registered fifo

Definition at line 222 of file poll_event.hpp.

223  {
224  __ASSERT_NO_MSG(m_event != nullptr);
225  __ASSERT_NO_MSG(m_event->tag == (int)type_tag::type_fifo);
226  __ASSERT_NO_MSG(m_event->fifo != nullptr);
227 
228  return fifo_ref<T_FifoItemType>(m_event->fifo);
229  }

References type_fifo.

◆ is_cancelled()

bool zpp::poll_event::is_cancelled ( )
inlinenoexcept

check if this event is cancelled

Returns
true if the event is cancelled

Definition at line 201 of file poll_event.hpp.

202  {
203  __ASSERT_NO_MSG(m_event != nullptr);
204  __ASSERT_NO_MSG(m_event->tag != (int)type_tag::type_unknown);
205 
206  if (m_event->state & K_POLL_STATE_CANCELLED) {
207  return true;
208  } else {
209  return false;
210  }
211  }

References type_unknown.

◆ is_ready()

bool zpp::poll_event::is_ready ( )
inlinenoexcept

check if this event is ready

Returns
true if the event is ready

Definition at line 165 of file poll_event.hpp.

166  {
167  __ASSERT_NO_MSG(m_event != nullptr);
168  __ASSERT_NO_MSG(m_event->tag != (int)type_tag::type_unknown);
169 
170  switch((type_tag)m_event->tag) {
172  return false;
173  case type_tag::type_sem:
174  return (m_event->state & K_POLL_STATE_SEM_AVAILABLE);
175  case type_tag::type_fifo:
176  return (m_event->state & K_POLL_STATE_FIFO_DATA_AVAILABLE);
178  return (m_event->state & K_POLL_STATE_SIGNALED);
180  return false;
181  }
182 
183  return false;
184  }
type_tag
type of event sources
Definition: poll_event.hpp:34

References type_fifo, type_ignore, type_sem, type_signal, and type_unknown.

◆ operator=() [1/2]

poll_event& zpp::poll_event::operator= ( const poll_event )
delete

◆ operator=() [2/2]

poll_event& zpp::poll_event::operator= ( poll_event &&  )
delete

◆ reset()

void zpp::poll_event::reset ( )
inlinenoexcept

reset event to non ready state

Definition at line 189 of file poll_event.hpp.

190  {
191  __ASSERT_NO_MSG(m_event != nullptr);
192 
193  m_event->state = K_POLL_STATE_NOT_READY;
194  }

◆ sem()

auto zpp::poll_event::sem ( )
inlinenoexcept

get access to the sem of the event

Warning
the event must be a sem event
Returns
a sem_ref that points to the registered sem

Definition at line 238 of file poll_event.hpp.

239  {
240  __ASSERT_NO_MSG(m_event != nullptr);
241  __ASSERT_NO_MSG(m_event->tag == (int)type_tag::type_sem);
242  __ASSERT_NO_MSG(m_event->sem != nullptr);
243 
244  return sem_ref(m_event->sem);
245  }

References type_sem.

◆ signal()

auto zpp::poll_event::signal ( )
inlinenoexcept

get access to the signal of the event

Warning
the event must be a signal event
Returns
a borrowed_poll_signal that points to the registered signal

Definition at line 254 of file poll_event.hpp.

255  {
256  __ASSERT_NO_MSG(m_event != nullptr);
257  __ASSERT_NO_MSG(m_event->tag == (int)type_tag::type_signal);
258  __ASSERT_NO_MSG(m_event->signal != nullptr);
259 
260  return poll_signal_ref(m_event->signal);
261  }

References type_signal.


The documentation for this class was generated from the following file: