Lumiera  0.pre.03
»edit your freedom«
meta-cmd.cpp
Go to the documentation of this file.
1 /*
2  MetaCmd - actual steam command scripts for internal meta and control activities
3 
4  Copyright (C)
5  2018, 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 
29 #include "steam/cmd.hpp"
31 //#include "steam/mobject/session.hpp"
32 #include "include/ui-protocol.hpp"
34 #include "stage/interact/wizard.hpp"
35 #include "lib/diff/gen-node.hpp"
36 #include "lib/idi/entry-id.hpp"
37 #include "lib/format-string.hpp"
38 //#include "lib/symbol.hpp"
39 #include "lib/util.hpp"
40 
41 #include <string>
42 
43 using lib::hash::LuidH;
44 using stage::ID;
45 using stage::NOTE_INFO;
46 using stage::NOTE_WARN;
47 using stage::NOTE_ERROR;
48 using stage::NotifyLevel;
49 using stage::MARK_expand;
51 using lib::diff::GenNode;
52 //using util::cStr;
53 using util::_Fmt;
54 using util::isYes;
55 using std::string;
56 
57 
58 namespace steam {
59 namespace cmd {
60  namespace error = lumiera::error;
61 
62  //using mobject::Session;
63 
64  namespace { // implementation helper...
65  }//(End) implementation helper
66 
67 
68 
69 
80 COMMAND_DEFINITION (test_meta_activateContentDiff)
81  {
82  def.operation ([]()
83  {
84  TODO ("send a population diff starting from scratch");
85  TODO ("activate life-update service within the session");
86  // Temporary hack to get any meaningful UI <-> Steam communication
87  GuiNotification::facade().displayInfo(NOTE_INFO, "Request: population-Diff from Session.");
88  })
89  .captureUndo ([]() -> bool
90  {
91  return false;
92  })
93  .undoOperation ([](bool wasActive)
94  {
95  if (not wasActive)
96  {
97  UNIMPLEMENTED ("send a status update diff into the root node, to mark it as defunct");
98  TODO ("clear the life-update service within the session");
99  }
100  });
101  };
102 
103 
113 COMMAND_DEFINITION (meta_deactivateContentDiff)
114  {
115  def.operation ([]()
116  {
117  TODO ("send a status update diff into the root node, to mark it as defunct");
118  TODO ("clear the life-update service within the session");
119  })
120  .captureUndo ([]() -> bool
121  {
122  return true;
123  })
124  .undoOperation ([](bool wasActive)
125  {
126  if (wasActive)
127  {
128  UNIMPLEMENTED ("send a diff update to completely clear the root node, then send a population diff with current session content");
129  TODO ("activate life-update service within the session");
130  }
131  });
132  };
133 
134 
135 
136 
137  /* ===== Demo and Development ===== */
138 
142 COMMAND_DEFINITION (test_meta_displayInfo)
143  {
144  def.operation ([](int level, string message)
145  {
146  GuiNotification::facade().displayInfo (static_cast<NotifyLevel>(level), message);
147  })
148  .captureUndo ([](int level, string message) -> string
149  {
150  return _Fmt{"displayInfo(%d, '%s')"} % level % message;
151  })
152  .undoOperation ([](int, string, string uiAction)
153  {
154  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction);
155  });
156  };
157 
158 
162 COMMAND_DEFINITION (test_meta_markError)
163  {
164  def.operation ([](string message)
165  {
166  ID errorLogID = stage::interact::Wizard::getErrorLogID();
167  GuiNotification::facade().markError (errorLogID, message);
168  })
169  .captureUndo ([](string message) -> string
170  {
171  return _Fmt{"GUI::errorLog <- markError('%s')"} % message;
172  })
173  .undoOperation ([](string, string uiAction)
174  {
175  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction);
176  });
177  };
178 
179 
183 COMMAND_DEFINITION (test_meta_markNote)
184  {
185  def.operation ([](string message)
186  {
187  ID errorLogID = stage::interact::Wizard::getErrorLogID();
188  GuiNotification::facade().markNote (errorLogID, message);
189  })
190  .captureUndo ([](string message) -> string
191  {
192  return _Fmt{"GUI::errorLog <- markNote('%s')"} % message;
193  })
194  .undoOperation ([](string, string uiAction)
195  {
196  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction);
197  });
198  };
199 
200 
204 COMMAND_DEFINITION (test_meta_markAction)
205  {
206  def.operation ([](string actionID, string message)
207  {
208  ID errorLogID = stage::interact::Wizard::getErrorLogID();
209  GuiNotification::facade().mark (errorLogID
210  ,actionID==MARK_expand? GenNode{actionID, isYes(message)}
211  : GenNode{actionID, message});
212  })
213  .captureUndo ([](string actionID, string message) -> string
214  {
215  return _Fmt{"GUI::errorLog <- mark(%s, '%s')"} % actionID % message;
216  })
217  .undoOperation ([](string, string, string uiAction)
218  {
219  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction);
220  });
221  };
222 
223 
224 
229 }} // namespace steam::cmd
Global help controller.
bool isYes(string const &textForm) noexcept
check the given text if it can be interpreted as affirmative answer (bool true).
Definition: util.cpp:107
Hard wired key constants and basic definitions for communication with the GUI.
Major public Interface of the Lumiera GUI.
Front-end for printf-style string template interpolation.
#define COMMAND_DEFINITION(_NAME_)
Macro to write command definitions in a compact form.
Common ID definitions for Steam-Layer commands.
something to be aware of, to be indicated unobtrusively
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Generic building block for tree shaped (meta)data structures.
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor...
Global access point to push state update and notification of events from the lower layers into the Lu...
Bare symbolic and hash ID used for accounting of asset like entries.
severe condition to be indicated prominently
static lib::Depend< GuiNotification > facade
static storage for the facade access front-end
Actually defining a command and binding it to execution parameters.
possibly interesting info that can be safely ignored
generic data element node within a tree
Definition: gen-node.hpp:222