Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
state-recorder.hpp
Go to the documentation of this file.
1/*
2 STATE-RECORDER.hpp - map based recording of presentation state
3
4 Copyright (C)
5 2016, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
43#ifndef STAGE_CTRL_STATE_RECORDER_H
44#define STAGE_CTRL_STATE_RECORDER_H
45
46
47#include "lib/error.hpp"
48#include "lib/idi/entry-id.hpp"
49#include "lib/diff/gen-node.hpp"
54
55#include <string>
56
57
58namespace stage {
59namespace ctrl {
60
63 using lib::diff::Ref;
64 using std::string;
65
66
67
68
84 : public StateManager
85 {
87 using Record = Storage::Record const&;
88
91
92
93
94 /* === PresentationStateManager interface === */
95
96 virtual StateMark
97 currentState (ID uiElm, string propertyKey) const override
98 {
99 return storage_.retrieve (uiElm, propertyKey);
100 }
101
102
103 virtual void
104 replayState (ID uiElm, string propertyKey) override
105 {
106 StateMark state = storage_.retrieve (uiElm, propertyKey);
107 if (state != Ref::NO)
108 uiBus_.mark (uiElm, state);
109 }
110
111
112 virtual void
113 replayAllState() override
114 {
115 for (Record entry : storage_)
116 replayPropertiesOf (entry);
117 }
118
119
123 virtual void
124 replayAllState (string propertyKey) override
125 {
126 for (Record entry : storage_)
127 {
128 StateMark state = Storage::getState (entry, propertyKey);
129 if (state != Ref::NO)
130 uiBus_.mark (Storage::getID (entry), state);
131 }
132 }
133
134
136 virtual void
137 replayAllProperties (ID uiElm) override
138 {
139 auto entry = storage_.find (uiElm);
140 if (entry != storage_.end())
141 replayPropertiesOf (*entry);
142 }
143
144
145 virtual void
146 clearState() override
147 {
148 storage_.clear();
149 }
150
151
152 public:
153 StateRecorder (BusTerm& busConnection)
154 : uiBus_(busConnection)
155 , storage_()
156 { }
157
166 void
167 recordState (ID uiElm, StateMark stateMark)
168 {
169 if (MARK_reset == stateMark.idi.getSym())
170 storage_.clearState (uiElm);
171 else
172 if (MARK_clearErr == stateMark.idi.getSym())
173 storage_.clearProperty (uiElm, string{MARK_Error});
174 else
175 if (MARK_clearMsg == stateMark.idi.getSym())
176 storage_.clearProperty (uiElm, string{MARK_Message});
177 else
178 storage_.record (uiElm, stateMark);
179 }
180
181 private:
190 void
192 {
193 ID uiElm = Storage::getID (entry);
194 for (auto& stateMark : Storage::getState (entry))
195 uiBus_.mark (uiElm, stateMark);
196 }
197 };
198
199
200
201}} // namespace stage::ctrl
202#endif /*STAGE_CTRL_STATE_RECORDER_H*/
Attachment point to the UI-Bus.
connection point at the UI-Bus.
Definition bus-term.hpp:98
virtual bool mark(ID subject, GenNode const &mark)
route a state update or notification to the given subject.
Definition ui-bus.cpp:151
Interface: handling of persistent interface state.
lib::idi::BareEntryID const & ID
lib::diff::GenNode const & StateMark
Map storage for captured presentation state information.
void clearState(BareEntryID const &elementID)
clear any previously recorded state for a given element
static StateData const & getState(Record const &entry)
void clearProperty(BareEntryID const &elementID, string propertyKey)
clear previously recorded state for a given element and specific property
static BareEntryID const & getID(Record const &entry)
void record(BareEntryID const &elementID, GenNode const &stateMark)
remember the state mark for the denoted element
GenNode const & retrieve(BareEntryID const &elementID, string propertyKey) const
retrieve captured state
iterator find(BareEntryID const &elementID) const
Simple map based implementation of the PresentationStateManager interface.
virtual StateMark currentState(ID uiElm, string propertyKey) const override
virtual void replayState(ID uiElm, string propertyKey) override
StateRecorder(BusTerm &busConnection)
void replayPropertiesOf(Record entry)
virtual void replayAllState(string propertyKey) override
replay all captured state from any element, but captured especially for the given property
virtual void replayAllState() override
virtual void replayAllProperties(ID uiElm) override
replay all captured state from the given element.
void recordState(ID uiElm, StateMark stateMark)
Interface for the operating facility (CoreService) to feed state mark messages to be remembered.
virtual void clearState() override
Storage::Record const & Record
Bare symbolic and hash ID used for accounting of asset like entries.
Lumiera error handling (C++ interface).
Generic building block for tree shaped (meta)data structures.
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
const Symbol MARK_clearMsg
const Symbol MARK_reset
const Symbol MARK_Message
const Symbol MARK_Error
const Symbol MARK_clearErr
Interface: a component to maintain persistent interface state.
Implementation of storage for captured presentation state.
generic data element node within a tree
Definition gen-node.hpp:224
Constructor for a specially crafted 'ref GenNode'.
Definition gen-node.hpp:843
static const Ref NO
symbolic ID ref "_NO_"
Definition gen-node.hpp:862
Hard wired key constants and basic definitions for communication with the GUI.