roo_control
API Documentation for roo_control
Loading...
Searching...
No Matches
roo_control::Switch< State > Class Template Referenceabstract

An abstraction of a multi-state settable switch. More...

#include <switch.h>

Inheritance diagram for roo_control::Switch< State >:
[legend]
Collaboration diagram for roo_control::Switch< State >:
[legend]

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.
 

Detailed Description

template<typename State>
class roo_control::Switch< State >

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.

Definition at line 24 of file switch.h.

Constructor & Destructor Documentation

◆ ~Switch()

template<typename State >
virtual roo_control::Switch< State >::~Switch ( )
virtualdefault

Member Function Documentation

◆ setState()

template<typename State >
virtual bool roo_control::Switch< State >::setState ( State  state)
pure virtual

The documentation for this class was generated from the following file: