Lumiera  0.pre.03
»edit your freedom«
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"
50 #include "stage/ctrl/bus-term.hpp"
53 #include "include/ui-protocol.hpp"
54 
55 #include <string>
56 
57 
58 namespace stage {
59 namespace ctrl {
60 
62  using lib::diff::GenNode;
63  using lib::diff::Ref;
64  using std::string;
65 
66 
67 
68 
84  : public StateManager
85  {
87  using Record = Storage::Record const&;
88 
89  BusTerm& uiBus_;
90  Storage storage_;
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_)
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())
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*/
Simple map based implementation of the PresentationStateManager interface.
Constructor for a specially crafted &#39;ref GenNode&#39;.
Definition: gen-node.hpp:840
Hard wired key constants and basic definitions for communication with the GUI.
void record(BareEntryID const &elementID, GenNode const &stateMark)
remember the state mark for the denoted element
connection point at the UI-Bus.
Definition: bus-term.hpp:96
virtual void replayAllProperties(ID uiElm) override
replay all captured state from the given element.
AnyPair entry(Query< TY > const &query, typename WrapReturn< TY >::Wrapper &obj)
helper to simplify creating mock table entries, wrapped correctly
Implementation of storage for captured presentation state.
Interface: a component to maintain persistent interface state.
void clearProperty(BareEntryID const &elementID, string propertyKey)
clear previously recorded state for a given element and specific property
void clearState(BareEntryID const &elementID)
clear any previously recorded state for a given element
Attachment point to the UI-Bus.
virtual void replayAllState(string propertyKey) override
replay all captured state from any element, but captured especially for the given property ...
Map storage for captured presentation state information.
virtual bool mark(ID subject, GenNode const &mark)
route a state update or notification to the given subject.
Definition: ui-bus.cpp:168
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
void replayPropertiesOf(Record entry)
Generic building block for tree shaped (meta)data structures.
static const Ref NO
symbolic ID ref "_NO_"
Definition: gen-node.hpp:861
GenNode const & retrieve(BareEntryID const &elementID, string propertyKey) const
retrieve captured state
Interface: handling of persistent interface state.
Lumiera error handling (C++ interface).
void recordState(ID uiElm, StateMark stateMark)
Interface for the operating facility (CoreService) to feed state mark messages to be remembered...
Bare symbolic and hash ID used for accounting of asset like entries.
generic data element node within a tree
Definition: gen-node.hpp:222