roo_control
API Documentation for roo_control
Loading...
Searching...
No Matches
switch.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
roo_control/binary_logical_state.h
"
4
#include "
roo_control/selector/selector.h
"
5
#include "roo_logging.h"
6
7
namespace
roo_control
{
8
9
/// An abstraction of a multi-state settable switch.
10
///
11
/// This can represent GPIO relays, port extenders, or software switches.
12
///
13
/// This abstraction serves two main purposes:
14
/// 1) it makes it easy to swap the implementation of a switch, without
15
/// changing the code that uses it. For example, you can start by
16
/// connecting a simple relay to a GPIO port, but eventually upgrade to a
17
/// port extender. You will not need to update the calling code (just the
18
/// setup logic).
19
/// 2) it allows building higher-level abstractions that are
20
/// implementation-independent. For example, the InertSwitch (and its
21
/// materialization, InertBinarySwitch) can be used to add debouncing
22
/// on top of any switch implementation.
23
template
<
typename
State>
24
class
Switch
:
public
Selector
<State> {
25
public
:
26
virtual
~Switch
() =
default
;
27
28
/// Updates the state of the switch. Returns true on success.
29
virtual
bool
setState
(State
state
) = 0;
30
};
31
32
/// Materialization for a two-state switch, usually driven by digital logic.
33
using
BinarySwitch
=
Switch<BinaryLogicalState>
;
34
35
}
// namespace roo_control
binary_logical_state.h
roo_control::Selector
An abstraction of a multi-state device.
Definition
selector.h:23
roo_control::Switch
An abstraction of a multi-state settable switch.
Definition
switch.h:24
roo_control::Switch::setState
virtual bool setState(State state)=0
Updates the state of the switch. Returns true on success.
roo_control::Switch::~Switch
virtual ~Switch()=default
roo_control
Definition
binary_logical_state.cpp:3
selector.h
temp_repos
roo_control
src
roo_control
switch
switch.h
Generated by
1.9.8