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) Lumiera.org
5  2018, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 * *****************************************************/
22 
23 
38 #include "steam/cmd.hpp"
40 //#include "steam/mobject/session.hpp"
41 #include "include/ui-protocol.hpp"
43 #include "stage/interact/wizard.hpp"
44 #include "lib/diff/gen-node.hpp"
45 #include "lib/idi/entry-id.hpp"
46 #include "lib/format-string.hpp"
47 //#include "lib/symbol.hpp"
48 #include "lib/util.hpp"
49 
50 #include <string>
51 
52 using lib::hash::LuidH;
53 using stage::ID;
54 using stage::NOTE_INFO;
55 using stage::NOTE_WARN;
56 using stage::NOTE_ERROR;
57 using stage::NotifyLevel;
58 using stage::MARK_expand;
60 using lib::diff::GenNode;
61 //using util::cStr;
62 using util::_Fmt;
63 using util::isYes;
64 using std::string;
65 
66 
67 namespace steam {
68 namespace cmd {
69  namespace error = lumiera::error;
70 
71  //using mobject::Session;
72 
73  namespace { // implementation helper...
74  }//(End) implementation helper
75 
76 
77 
78 
89 COMMAND_DEFINITION (test_meta_activateContentDiff)
90  {
91  def.operation ([]()
92  {
93  TODO ("send a population diff starting from scratch");
94  TODO ("activate life-update service within the session");
95  // Temporary hack to get any meaningful UI <-> Steam communication
96  GuiNotification::facade().displayInfo(NOTE_INFO, "Request: population-Diff from Session.");
97  })
98  .captureUndo ([]() -> bool
99  {
100  return false;
101  })
102  .undoOperation ([](bool wasActive)
103  {
104  if (not wasActive)
105  {
106  UNIMPLEMENTED ("send a status update diff into the root node, to mark it as defunct");
107  TODO ("clear the life-update service within the session");
108  }
109  });
110  };
111 
112 
122 COMMAND_DEFINITION (meta_deactivateContentDiff)
123  {
124  def.operation ([]()
125  {
126  TODO ("send a status update diff into the root node, to mark it as defunct");
127  TODO ("clear the life-update service within the session");
128  })
129  .captureUndo ([]() -> bool
130  {
131  return true;
132  })
133  .undoOperation ([](bool wasActive)
134  {
135  if (wasActive)
136  {
137  UNIMPLEMENTED ("send a diff update to completely clear the root node, then send a population diff with current session content");
138  TODO ("activate life-update service within the session");
139  }
140  });
141  };
142 
143 
144 
145 
146  /* ===== Demo and Development ===== */
147 
151 COMMAND_DEFINITION (test_meta_displayInfo)
152  {
153  def.operation ([](int level, string message)
154  {
155  GuiNotification::facade().displayInfo (static_cast<NotifyLevel>(level), message);
156  })
157  .captureUndo ([](int level, string message) -> string
158  {
159  return _Fmt{"displayInfo(%d, '%s')"} % level % message;
160  })
161  .undoOperation ([](int, string, string uiAction)
162  {
163  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction);
164  });
165  };
166 
167 
171 COMMAND_DEFINITION (test_meta_markError)
172  {
173  def.operation ([](string message)
174  {
175  ID errorLogID = stage::interact::Wizard::getErrorLogID();
176  GuiNotification::facade().markError (errorLogID, message);
177  })
178  .captureUndo ([](string message) -> string
179  {
180  return _Fmt{"GUI::errorLog <- markError('%s')"} % message;
181  })
182  .undoOperation ([](string, string uiAction)
183  {
184  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction);
185  });
186  };
187 
188 
192 COMMAND_DEFINITION (test_meta_markNote)
193  {
194  def.operation ([](string message)
195  {
196  ID errorLogID = stage::interact::Wizard::getErrorLogID();
197  GuiNotification::facade().markNote (errorLogID, message);
198  })
199  .captureUndo ([](string message) -> string
200  {
201  return _Fmt{"GUI::errorLog <- markNote('%s')"} % message;
202  })
203  .undoOperation ([](string, string uiAction)
204  {
205  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction);
206  });
207  };
208 
209 
213 COMMAND_DEFINITION (test_meta_markAction)
214  {
215  def.operation ([](string actionID, string message)
216  {
217  ID errorLogID = stage::interact::Wizard::getErrorLogID();
218  GuiNotification::facade().mark (errorLogID
219  ,actionID==MARK_expand? GenNode{actionID, isYes(message)}
220  : GenNode{actionID, message});
221  })
222  .captureUndo ([](string actionID, string message) -> string
223  {
224  return _Fmt{"GUI::errorLog <- mark(%s, '%s')"} % actionID % message;
225  })
226  .undoOperation ([](string, string, string uiAction)
227  {
228  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO UI-Action: "+uiAction);
229  });
230  };
231 
232 
233 
238 }} // 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:116
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:231