|
roo_control
API Documentation for roo_control
|
An abstraction of a multi-state settable switch. More...
#include <switch.h>
Public Member Functions | |
| virtual | ~Switch ()=default |
| virtual bool | setState (State state)=0 |
| Updates the state of the switch. Returns true on success. | |
Public Member Functions inherited from roo_control::Selector< State > | |
| virtual | ~Selector ()=default |
| virtual bool | getState (State &result) const =0 |
| Retrieves the current state, or returns false when it cannot be read. | |
An abstraction of a multi-state settable switch.
This can represent GPIO relays, port extenders, or software switches.
This abstraction serves two main purposes: 1) it makes it easy to swap the implementation of a switch, without changing the code that uses it. For example, you can start by connecting a simple relay to a GPIO port, but eventually upgrade to a port extender. You will not need to update the calling code (just the setup logic). 2) it allows building higher-level abstractions that are implementation-independent. For example, the InertSwitch (and its materialization, InertBinarySwitch) can be used to add debouncing on top of any switch implementation.
|
virtualdefault |
|
pure virtual |
Updates the state of the switch. Returns true on success.
Implemented in roo_control::Pcf8574::Port, roo_control::Pcf8574::OutputPort, roo_control::BoundSwitch< BinaryLogicalState >, roo_control::GpioRelay, roo_control::BoundSwitch< State >, and roo_control::InertSwitch< StateT >.