Lumiera  0.pre.03
»edityourfreedom«
dummy-session-connection.cpp
Go to the documentation of this file.
1 /*
2  DummySessionConnection - scaffolding placeholder to drive the GUI-Session connection
3 
4  Copyright (C) Lumiera.org
5  2016, 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 "lib/util.hpp"
39 //#include "lib/symbol.hpp"
40 //#include "include/logging.h"
44 #include "include/ui-protocol.hpp"
48 #include "lib/diff/gen-node.hpp"
49 //#include "lib/idi/entry-id.hpp"
50 #include "lib/format-string.hpp"
51 #include "lib/format-cout.hpp"
52 //#include "lib/symbol.hpp"
53 #include "lib/util.hpp"
54 
55 #include <string>
56 //#include <map>
57 
58 using lib::diff::GenNode;
59 using lib::diff::MakeRec;
61 //using util::cStr;
62 using util::_Fmt;
63 using std::string;
64 
65 #include <string>
66 
67 //using std::map;
68 using std::string;
69 
70 using util::contains;
71 using util::isnil;
72 
73 namespace proc {
74 namespace mobject {
75 namespace session {
76 
77  namespace { //Implementation details....
78 
79  GenNode
80  emptyTimeline (string baseID)
81  {
82  return MakeRec()
83  .set(string{gui::ATTR_fork}
84  ,MakeRec()
85  .type(string{gui::TYPE_Fork})
86  )
87  .genNode(baseID);
88  }
89  } //(End)Implementation details....
90 
91 
93 
95  {
96  }
97 
98 
101 
102 
108  {
109  return MutationMessage{ ins (emptyTimeline (baseID))
110  };
111  }
112 
113 
114  void
116  {
117  TODO ("build internal diagnostic data structure, apply a copy of the message");
118  }
119 
120 
121 }}// namespace proc::mobject::session
122 
123 namespace cmd {
124 
125  using lib::hash::LuidH;
126  using gui::ID;
127  using gui::NOTE_INFO;
128  using gui::NOTE_WARN;
129  using gui::NOTE_ERROR;
130 // using gui::NotifyLevel;
131 // using gui::MARK_expand;
132  using gui::GuiNotification;
133 // using util::isYes;
134 
135  namespace session = proc::mobject::session;
136 
138 
139 
140  /* ============ dedicated Fake-Commands ============ */
141 
152  {
153  def.operation ([](string dummyID)
154  {
155  string message{_Fmt{"fabricate Sequence_1 (dummyID='%s')"} % dummyID};
156  GuiNotification::facade().displayInfo (NOTE_INFO, message);
157  auto popuDiff = DummySess::instance().fabricateSeq1 (dummyID);
158  DummySess::instance().applyCopy (popuDiff);
159  auto rootID = session::Root::getID();
160  GuiNotification::facade().mutate (rootID, move(popuDiff));
161  })
162  .captureUndo ([](string dummyID) -> string
163  {
164  return _Fmt{"fabricateSequence_1('%s')"} % dummyID;
165  })
166  .undoOperation ([](string, string memento)
167  {
168  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
169  });
170  };
171 
172 
178  {
179  def.operation ([](string dummyID)
180  {
181  string message{_Fmt{"fabricate Sequence_2 (dummyID='%s')"} % dummyID};
182  GuiNotification::facade().displayInfo (NOTE_INFO, message);
183  })
184  .captureUndo ([](string dummyID) -> string
185  {
186  return _Fmt{"fabricateSequence_2('%s')"} % dummyID;
187  })
188  .undoOperation ([](string, string memento)
189  {
190  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
191  });
192  };
193 
194 
198 COMMAND_DEFINITION (test_fake_blubb)
199  {
200  def.operation ([](string dummyID)
201  {
202  string message{_Fmt{"fabricate gulp (dummyID='%s')"} % dummyID};
203  GuiNotification::facade().displayInfo (NOTE_INFO, message);
204  })
205  .captureUndo ([](string dummyID) -> string
206  {
207  return _Fmt{"fabricateGulp('%s')"} % dummyID;
208  })
209  .undoOperation ([](string, string memento)
210  {
211  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
212  });
213  };
214 
215 
216 }} // namespace proc::mobject::session
Concrete implementation to apply structural changes to hierarchical data structures.
Rec::Mutator MakeRec
Definition: gen-node.hpp:135
Generic Message with an embedded diff, to describe changes to model elements.
Automatically use custom string conversion in C++ stream output.
something to be aware of, to be indicated unobtrusively
Hard wired key constants and basic definitions for communication with the GUI.
Major public Interface of the Lumiera GUI.
static lib::idi::EntryID< Root > getID()
get an unique ID to identify "the model root".
Definition: root.cpp:57
lib::idi::BareEntryID const & ID
Definition: wizard.hpp:61
Front-end for printf-style string template interpolation.
#define COMMAND_DEFINITION(_NAME_)
Macro to write command definitions in a compact form.
Dummy and scaffolding to help development of the UI - Session connection.
Opaque message to effect a structural change on a target, which is likewise only known in an abstract...
A front-end for using printf-style formatting.
MObject within the session to represent "the session itself".
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
Global access point to push state update and notification of events from the lower layers into the Lu...
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
Definition: util.hpp:205
CommandSetup test_fake_injectSequence_1
possibly interesting info that can be safely ignored
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.
Scaffolding to drive the evolution of the Lumiera application.
bool isnil(lib::time::Duration const &dur)
Definition: timevalue.hpp:642
severe condition to be indicated prominently
Mutator & type(string const &typeID)
Definition: record.hpp:449
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor...
Namespace of Session and user visible high-level objects.
CommandSetup test_fake_injectSequence_2
const Symbol TYPE_Fork
Definition: ui-protocol.cpp:36
const Symbol ATTR_fork
Definition: ui-protocol.cpp:43
static lib::Depend< DummySessionConnection > instance
access point to set up the scaffolding.
Proc-Layer implementation namespace root.
Definition: id-scheme.hpp:63
Actually defining a command and binding it to execution parameters.
generic data element node within a tree
Definition: gen-node.hpp:213
MutationMessage fabricateSeq1(string baseID)
Build a population diff message to describe a specific session structure to add.
Mutator & set(string const &key, X &&content)
Definition: record.hpp:457