SpaIot Library
SpaIot::ButtonControllerabstract

This class is the base class of all button controllers. More...

Inheritance diagram for SpaIot::ButtonController:

Public Member Functions

 ButtonController (const ButtonController &other)
 Copy Constructor.
 
 ButtonController (ButtonController &&other)
 Move Constructor after the move, other is null, other.clear() must be called if it is to be used again.
 
virtual ButtonControlleroperator= (const ButtonController &other)
 Assignment operator.
 
virtual ButtonControlleroperator= (ButtonController &&other)
 Move assignment after the move, other is null, other.clear() must be called if it is to be used again.
 
virtual ~ButtonController ()
 Destructor By default, this calls the virtual function end()
 
virtual void clear ()
 Sets all attributes to their default values (same as the default constructor)
 
bool isNull () const
 Returns true if the object is null (i.e. it has not been initialized, d_ptr is null)
 
virtual bool isEmpty () const
 Checks if all attributes are set to their default values (same as the default constructor)
 
virtual bool operator== (const ButtonController &other) const
 Returns true if the two objects are equal.
 
virtual bool operator!= (const ButtonController &other) const
 Returns true if the two objects are not equal.
 
virtual void begin ()
 Configures all ressources needed to use the object.
 
virtual void end ()
 Releases all ressources used by the object.
 
virtual int select (int button)=0
 Selects a button. More...
 
virtual void deselect ()=0
 Deselects the button After the call to this function, isSelected() must return false, and selected() must return -1.
 
virtual int selected () const
 Returns the button number that is selected, or -1 if no button is selected.
 
virtual bool isOpen () const
 Returns true if begin() has been successfully called.
 
virtual bool isSelected () const
 Returns true if a button is selected.
 
virtual const String & name () const
 Returns the name of the ButtonController object if it has been set, otherwise it returns an empty string.
 

Static Public Member Functions

static bool addToRegister (const String &name, ButtonController &controller)
 Adds a ButtonController object to the register. More...
 
static ButtonControllergetFromRegister (const String &name)
 Returns a ButtonController object from the register. More...
 
static bool registerContains (const String &name)
 Returns true if the register contains a ButtonController object with the given name. More...
 

Detailed Description

This class is the base class of all button controllers.

It is an abstract class, and cannot be instantiated. It provides a common interface for all button controllers. This class is copyable and movable.

select() and deselect() are pure virtual functions that must be implemented by derived classes

Member Function Documentation

◆ addToRegister()

static bool SpaIot::ButtonController::addToRegister ( const String &  name,
ButtonController controller 
)
static

Adds a ButtonController object to the register.

Parameters
nameThe name of the ButtonController object that will be used to retrieve it from the register
controllerThe ButtonController object

◆ getFromRegister()

static ButtonController& SpaIot::ButtonController::getFromRegister ( const String &  name)
static

Returns a ButtonController object from the register.

The user must call registerContains() before calling this function to check if the register contains a ButtonController object with the given name, otherwise an exception will be thrown std::out_of_range (and if exceptions are not enabled, the program will terminate)

Parameters
nameThe name of the ButtonController object that will be used to retrieve it from the register
Returns
The ButtonController object

◆ registerContains()

static bool SpaIot::ButtonController::registerContains ( const String &  name)
static

Returns true if the register contains a ButtonController object with the given name.

Parameters
nameThe name of the ButtonController object that will be used to retrieve it from the register
Returns
true if the register contains a ButtonController object with the given name

◆ select()

virtual int SpaIot::ButtonController::select ( int  button)
pure virtual

Selects a button.

Parameters
buttonthe button to be selected
Returns
the value return by selected()

Implemented in SpaIot::Pcf8574Mux, and SpaIot::Multiplexer.