SpaIot Library
buttoncontroller.h
1/*
2 * SpaIot Library (c) by epsilonrt - epsilonrt@gmail.com
3 * This file is part of SpaIot library <https://github.com/epsilonrt/spaiot-lib>
4 *
5 * SpaIot library is licensed under a
6 * Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
7 *
8 * You should have received a copy of the license along with this
9 * work. If not, see <http://creativecommons.org/licenses/by-nc-sa/4.0/>.
10 *
11 * SpaIot library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY;
13 */
14#pragma once
15
16#include <map>
17#include "global.h"
18
19namespace SpaIot {
20
25 class ButtonController {
26 public:
30 ButtonController();
35 ButtonController (const String & name);
40 virtual ~ButtonController();
44 virtual void begin() = 0;
48 virtual void end();
54 virtual int select (int button) = 0;
58 virtual void deselect () = 0;
63 virtual int selected() const;
68 virtual bool isOpened() const;
73 virtual bool isNull() const;
78 virtual bool isSelected() const;
83 virtual const String & name() const;
88 virtual bool operator== (const ButtonController &other) const;
93 virtual bool operator!= (const ButtonController &other) const;
100 static bool addToRegister (const String & name, ButtonController & controller);
106 static ButtonController & getFromRegister (const String & name);
112 static bool registerContains (const String & name);
113
114 protected:
115 bool m_isopened;
116 int m_selected;
117 mutable String m_name;
118
119 private:
120 static std::map<String, ButtonController &> Register;
121 };
122}
SpaIot name space.
Definition: bussettings.h:21