zpp
Zephyr C++20 Framework
zpp::poll_signal_base< T_PollSignal > Class Template Reference

CRTP base class for poll_signals. More...

#include <poll_signal.hpp>

Public Types

using native_type = struct k_poll_signal
 
using native_pointer = native_type *
 
using native_const_pointer = native_type const *
 

Public Member Functions

std::optional< int > check () noexcept
 check if the signal was signaled More...
 
bool raise (int result) noexcept
 signal the signal More...
 
void reset () noexcept
 reset the state to non-signalled More...
 
auto native_handle () noexcept -> native_pointer
 get the native k_poll_signal handle More...
 
auto native_handle () const noexcept -> native_const_pointer
 get the native k_poll_signal handle More...
 
 poll_signal_base (const poll_signal_base &)=delete
 
 poll_signal_base (poll_signal_base &&)=delete
 
poll_signal_baseoperator= (const poll_signal_base &)=delete
 
poll_signal_baseoperator= (poll_signal_base &&)=delete
 

Protected Member Functions

 poll_signal_base () noexcept
 default contructor only to be used by derived classes More...
 

Detailed Description

template<typename T_PollSignal>
class zpp::poll_signal_base< T_PollSignal >

CRTP base class for poll_signals.

Parameters
PollSignalthe CRTP derived class

Definition at line 26 of file poll_signal.hpp.

Member Typedef Documentation

◆ native_const_pointer

template<typename T_PollSignal >
using zpp::poll_signal_base< T_PollSignal >::native_const_pointer = native_type const *

Definition at line 30 of file poll_signal.hpp.

◆ native_pointer

template<typename T_PollSignal >
using zpp::poll_signal_base< T_PollSignal >::native_pointer = native_type *

Definition at line 29 of file poll_signal.hpp.

◆ native_type

template<typename T_PollSignal >
using zpp::poll_signal_base< T_PollSignal >::native_type = struct k_poll_signal

Definition at line 28 of file poll_signal.hpp.

Constructor & Destructor Documentation

◆ poll_signal_base() [1/3]

template<typename T_PollSignal >
zpp::poll_signal_base< T_PollSignal >::poll_signal_base ( )
inlineprotectednoexcept

default contructor only to be used by derived classes

Definition at line 35 of file poll_signal.hpp.

36  {
37  }

◆ poll_signal_base() [2/3]

template<typename T_PollSignal >
zpp::poll_signal_base< T_PollSignal >::poll_signal_base ( const poll_signal_base< T_PollSignal > &  )
delete

◆ poll_signal_base() [3/3]

template<typename T_PollSignal >
zpp::poll_signal_base< T_PollSignal >::poll_signal_base ( poll_signal_base< T_PollSignal > &&  )
delete

Member Function Documentation

◆ check()

template<typename T_PollSignal >
std::optional<int> zpp::poll_signal_base< T_PollSignal >::check ( )
inlinenoexcept

check if the signal was signaled

Returns
when the signal was signaled the signal value

Definition at line 44 of file poll_signal.hpp.

45  {
46  unsigned int signaled{0};
47  int result{0};
48 
49  k_poll_signal_check(native_handle(), &signaled, &result);
50 
51  if (signaled != 0) {
52  return { result };
53  } else {
54  return {};
55  }
56  }
auto native_handle() noexcept -> native_pointer
get the native k_poll_signal handle
Definition: poll_signal.hpp:88

References zpp::poll_signal_base< T_PollSignal >::native_handle().

◆ native_handle() [1/2]

template<typename T_PollSignal >
auto zpp::poll_signal_base< T_PollSignal >::native_handle ( ) const -> native_const_pointer
inlinenoexcept

get the native k_poll_signal handle

Returns
pointer to a k_poll_signal

Definition at line 98 of file poll_signal.hpp.

99  {
100  return static_cast<const T_PollSignal*>(this)->native_handle();
101  }

References zpp::poll_signal_base< T_PollSignal >::native_handle().

◆ native_handle() [2/2]

template<typename T_PollSignal >
auto zpp::poll_signal_base< T_PollSignal >::native_handle ( ) -> native_pointer
inlinenoexcept

get the native k_poll_signal handle

Returns
pointer to a k_poll_signal

Definition at line 88 of file poll_signal.hpp.

89  {
90  return static_cast<T_PollSignal*>(this)->native_handle();
91  }

Referenced by zpp::poll_signal_base< T_PollSignal >::check(), zpp::poll_signal_base< T_PollSignal >::native_handle(), zpp::poll_signal_base< T_PollSignal >::raise(), and zpp::poll_signal_base< T_PollSignal >::reset().

◆ operator=() [1/2]

template<typename T_PollSignal >
poll_signal_base& zpp::poll_signal_base< T_PollSignal >::operator= ( const poll_signal_base< T_PollSignal > &  )
delete

◆ operator=() [2/2]

template<typename T_PollSignal >
poll_signal_base& zpp::poll_signal_base< T_PollSignal >::operator= ( poll_signal_base< T_PollSignal > &&  )
delete

◆ raise()

template<typename T_PollSignal >
bool zpp::poll_signal_base< T_PollSignal >::raise ( int  result)
inlinenoexcept

signal the signal

Parameters
resultthe value that check will return
Returns
false if the signalling failed

Definition at line 65 of file poll_signal.hpp.

66  {
67  auto rc = k_poll_signal_raise(native_handle(), result);
68  if (rc == 0) {
69  return true;
70  } else {
71  return false;
72  }
73  }

References zpp::poll_signal_base< T_PollSignal >::native_handle().

◆ reset()

template<typename T_PollSignal >
void zpp::poll_signal_base< T_PollSignal >::reset ( )
inlinenoexcept

reset the state to non-signalled

Definition at line 78 of file poll_signal.hpp.

79  {
80  k_poll_signal_reset(native_handle());
81  }

References zpp::poll_signal_base< T_PollSignal >::native_handle().


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