SpaIot Library
Loading...
Searching...
No Matches
buttoncontroller.h
1/*
2 SpaIot Library (c) by epsilonrt - epsilonrt@epsilonrt.fr
3 This file is part of SpaIot library <https://github.com/epsilonrt/spaiot-lib>
4
5 SPDX-License-Identifier: BSD-3-Clause
6
7 SpaIot library is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY;
9*/
10#pragma once
11
12#include <map>
13#include "global.h"
14
15namespace SpaIot {
16
27 public:
32
38
43
49
55
59 virtual void clear();
60
64 bool isNull() const;
65
69 virtual bool isEmpty() const;
70
74 virtual bool operator== (const ButtonController &other) const;
75
79 virtual bool operator!= (const ButtonController &other) const;
80
84 virtual void begin();
85
89 virtual void end();
90
97 virtual int select (int button) = 0;
98
103 virtual void deselect () = 0;
104
108 virtual int selected() const;
109
113 virtual bool isOpen() const;
114
118 virtual bool isSelected() const;
119
123 virtual const String &name() const;
124
130 static bool addToRegister (const String &name, ButtonController &controller);
131
141 static ButtonController &getFromRegister (const String &name);
142
148 static bool registerContains (const String &name);
149
150 protected:
151 class Private;
152 ButtonController (Private &dd);
153 std::unique_ptr<Private> d_ptr;
154 private:
155 PIMPL_DECLARE_PRIVATE (ButtonController)
156 };
157}
This class is the base class of all button controllers.
Definition buttoncontroller.h:26
virtual bool isOpen() const
Returns true if begin() has been successfully called.
ButtonController(ButtonController &&other)
Move Constructor after the move, other is null, other.clear() must be called if it is to be used agai...
virtual int selected() const
Returns the button number that is selected, or -1 if no button is selected.
ButtonController(const ButtonController &other)
Copy Constructor.
virtual void end()
Releases all ressources used by the object.
virtual bool operator!=(const ButtonController &other) const
Returns true if the two objects are not equal.
bool isNull() const
Returns true if the object is null (i.e. it has not been initialized, d_ptr is null)
virtual ButtonController & operator=(const ButtonController &other)
Assignment operator.
virtual bool isEmpty() const
Checks if all attributes are set to their default values (same as the default constructor)
virtual void deselect()=0
Deselects the button After the call to this function, isSelected() must return false,...
static bool registerContains(const String &name)
Returns true if the register contains a ButtonController object with the given name.
virtual int select(int button)=0
Selects a button.
static ButtonController & getFromRegister(const String &name)
Returns a ButtonController object from the register.
static bool addToRegister(const String &name, ButtonController &controller)
Adds a ButtonController object to the register.
virtual ~ButtonController()
Destructor By default, this calls the virtual function end()
virtual void begin()
Configures all ressources needed to use the object.
virtual void clear()
Sets all attributes to their default values (same as the default constructor)
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 str...
virtual bool operator==(const ButtonController &other) const
Returns true if the two objects are equal.
SpaIot name space.
Definition bussettings.h:15