blob: b3d897cdbccc8123d665e23ad252164f80684eb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/**
* \file
* \brief SignalInformation class header
*
* \author Copyright (C) 2015 Kamil Szczygiel http://www.distortec.com http://www.freddiechopin.info
*
* \par License
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
* distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDE_DISTORTOS_SIGNALINFORMATION_HPP_
#define INCLUDE_DISTORTOS_SIGNALINFORMATION_HPP_
#include <csignal>
#include <cstdint>
namespace distortos
{
/**
* \brief SignalInformation class contains information about queued signal
*
* Similar to siginfo_t - http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html
*
* \ingroup signals
*/
class SignalInformation
{
public:
/// replacement for predefined \a si_code values
enum class Code : uint8_t
{
/// signal generated by Thread::generateSignal() or ThisThread::Signals::generateSignal() (similar to
/// \a SI_USER)
generated,
/// signal queued by Thread::queueSignal() or ThisThread::Signals::queueSignal() (similar to \a SI_QUEUE)
queued,
};
/**
* \brief SignalInformation's constructor.
*
* \param [in] signalNumber is the signal number (similar to \a si_signo member of \a siginfo_t)
* \param [in] code is the signal code (similar to \a si_code member of \a siginfo_t)
* \param [in] value is the signal value (similar to \a si_value member of \a siginfo_t)
*/
constexpr SignalInformation(const uint8_t signalNumber, const Code code, const sigval value) :
value_(value),
code_{code},
signalNumber_{signalNumber}
{
}
/**
* \return signal code (similar to \a si_code member of \a siginfo_t)
*/
Code getCode() const
{
return code_;
}
/**
* \return signal number (similar to \a si_signo member of \a siginfo_t)
*/
uint8_t getSignalNumber() const
{
return signalNumber_;
}
/**
* \return signal value (similar to \a si_value member of \a siginfo_t)
*/
sigval getValue() const
{
return value_;
}
private:
/// signal value (similar to \a si_value member of \a siginfo_t)
sigval value_;
/// signal code (similar to \a si_code member of \a siginfo_t)
Code code_;
/// signal number (similar to \a si_signo member of \a siginfo_t)
uint8_t signalNumber_;
};
} // namespace distortos
#endif // INCLUDE_DISTORTOS_SIGNALINFORMATION_HPP_
|