UniSet
2.8.0
include
Trigger.h
1
/*
2
* Copyright (c) 2015 Pavel Vainerman.
3
*
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as
6
* published by the Free Software Foundation, version 2.1.
7
*
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Lesser Public License for more details.
12
*
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15
*/
16
// --------------------------------------------------------------------------
21
//--------------------------------------------------------------------------
22
#ifndef UNITRIGGER_H_
23
#define UNITRIGGER_H_
24
//--------------------------------------------------------------------------
25
namespace
uniset
26
{
27
// header only
28
30
class
Trigger
31
{
32
public
:
33
Trigger
(
bool
initial =
false
) noexcept
34
{
35
oldstate = initial;
36
}
37
39
bool
hi
(
bool
state) noexcept
40
{
41
if
(oldstate != state)
42
{
43
oldstate = state;
44
45
if
(state)
46
return
true
;
47
}
48
49
return
false
;
50
}
52
bool
low
(
bool
state) noexcept
53
{
54
if
(oldstate != state)
55
{
56
oldstate = state;
57
58
if
(!state)
59
return
true
;
60
}
61
62
return
false
;
63
}
65
bool
change
(
bool
state) noexcept
66
{
67
if
(oldstate != state)
68
{
69
oldstate = state;
70
return
true
;
71
}
72
73
return
false
;
74
}
75
76
inline
bool
get() const noexcept
77
{
78
return
oldstate;
79
}
80
81
private
:
82
bool
oldstate;
83
};
84
// -------------------------------------------------------------------------
85
}
// end of uniset namespace
86
// --------------------------------------------------------------------------
87
#endif
88
// --------------------------------------------------------------------------
uniset::Trigger::change
bool change(bool state) noexcept
Definition:
Trigger.h:65
uniset
Definition:
CommonEventLoop.h:14
uniset::Trigger::hi
bool hi(bool state) noexcept
Definition:
Trigger.h:39
uniset::Trigger
Definition:
Trigger.h:30
uniset::Trigger::low
bool low(bool state) noexcept
Definition:
Trigger.h:52
Документация по UniSet. Последние изменения: Вс 25 Окт 2020 00:02:12. Создано системой
1.8.17