EmlaLockSafe
ViewStore.h
Go to the documentation of this file.
1
5#pragma once
6#include <ViewBase.h>
7#include <map>
8
9namespace views {
18class ViewStore {
19public:
23 enum ViewId {
40 };
41
42protected:
46 std::map<ViewId, lcd::ViewBase*> views;
47
48protected:
53
54protected:
59 static ViewStore instance;
60 return instance;
61 }
62
63public:
71 static lcd::ViewBase* getView(const ViewId& id) {
72 auto it = getSingleton().views.find(id);
73 if (it == getSingleton().views.end()) {
74 return nullptr;
75 }
76 return it->second;
77 }
78
79public:
87 static void addView(const ViewId& id, lcd::ViewBase& view) {
88 getSingleton().views[id] = &view;
89 }
90
91public:
98 static bool activateView(const ViewId& id) {
99 auto it = getSingleton().views.find(id);
100 if (it == getSingleton().views.end()) {
101 lcd::ViewBase::activateView(nullptr);
102 return false;
103 }
104
105 lcd::ViewBase::activateView(it->second);
106 return true;
107 }
108};
109} // namespace views
Class managing which holds static references to all views which can be accessed over the ViewId witho...
Definition: ViewStore.h:18
static lcd::ViewBase * getView(const ViewId &id)
Returns the pointer to the view registered by the given id.
Definition: ViewStore.h:71
std::map< ViewId, lcd::ViewBase * > views
Map linking the IDs.
Definition: ViewStore.h:46
static bool activateView(const ViewId &id)
activates the view described by the id
Definition: ViewStore.h:98
static ViewStore & getSingleton()
Get the Singleton object if the ViewStore.
Definition: ViewStore.h:58
static void addView(const ViewId &id, lcd::ViewBase &view)
registers a new view
Definition: ViewStore.h:87
ViewStore()
protected, use the static functions instead
Definition: ViewStore.h:52
ViewId
IDs of the different views.
Definition: ViewStore.h:23
@ ConfigurationServerView
Definition: ViewStore.h:24
@ PreferencesMenu
Definition: ViewStore.h:32
@ EmergencyEnterKeyView
Definition: ViewStore.h:25
@ UnlockSafeView
Definition: ViewStore.h:38
@ EmergencyMenu
Definition: ViewStore.h:27
@ EmergencyEnterMenuView
Definition: ViewStore.h:26
@ HardwareTestView
Definition: ViewStore.h:29
@ TimeRestrictedView
Definition: ViewStore.h:36
@ WifiConnectingView
Definition: ViewStore.h:39
@ SetTimerView
Definition: ViewStore.h:35
@ LockedView
Definition: ViewStore.h:31
@ SelectDisplayTimeLeft
Definition: ViewStore.h:33
@ SelectDisplayTimePassed
Definition: ViewStore.h:34
@ EmlalockUnlockKeyMenu
Definition: ViewStore.h:28
@ HygieneOpeningMenu
Definition: ViewStore.h:30
@ UnlockedMainMenu
Definition: ViewStore.h:37
Definition: ConfigurationServerView.h:10