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