Lumiera  0.pre.03
»edit your freedom«
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/time/timevalue.hpp"
50 //#include "lib/idi/entry-id.hpp"
51 #include "lib/format-string.hpp"
52 #include "lib/format-cout.hpp"
53 //#include "lib/symbol.hpp"
54 #include "lib/util.hpp"
55 
56 #include <string>
57 //#include <map>
58 
60 using lib::diff::GenNode;
61 using lib::diff::MakeRec;
62 using lib::diff::Ref;
63 using lib::idi::RandID;
64 using lib::time::Time;
65 using lib::time::FSecs;
68 //using util::cStr;
69 using util::_Fmt;
70 using std::string;
71 
72 #include <string>
73 
74 //using std::map;
75 using std::string;
76 
77 using util::contains;
78 using util::isnil;
79 
80 namespace steam {
81 namespace mobject {
82 namespace session {
83 
84  namespace { //Implementation details....
85 
89  GenNode
90  emptyTimeline (string baseID, RandID const& forkRootID)
91  {
92  return MakeRec()
93  .set(MakeRec()
94  .type (string{stage::TYPE_Fork})
95  .genNode(forkRootID)
96  )
97  .genNode(baseID);
98  }
99 
100  GenNode
101  emptyTrack (string trackID)
102  {
103  return MakeRec()
104  .type (string{stage::TYPE_Fork})
105  .genNode(trackID);
106  }
107 
108  GenNode
109  ruler()
110  {
111  return MakeRec()
112  .type (string{stage::TYPE_Ruler})
113  .genNode("Ruler");
114  }
115 
116  GenNode
117  clip (string clipID, TimeSpan timings)
118  {
119  return MakeRec()
120  .type (string{stage::TYPE_Clip})
121  .set(string{stage::ATTR_timing}, timings)
122  .genNode(clipID);
123  }
124  GenNode
125  clip (string clipID, Time start, Duration dur = Duration{FSecs{1}})
126  {
127  return clip (clipID, TimeSpan{start,dur});
128  }
129 
132  GenNode
133  makeName (GenNode const& elm)
134  {
135  return GenNode{string{stage::ATTR_name}, elm.idi.getSym() };
136  }
137 
139  GenNode
140  defineTiming (Time start, Duration dur = Duration{FSecs{1}})
141  {
142  return GenNode{string{stage::ATTR_timing}, TimeSpan{start,dur} };
143  }
144  } //(End)Implementation details....
145 
146 
147 
148 
151 
152 
153  DummySessionConnection::DummySessionConnection()
154  { }
155 
156  DummySessionConnection::~DummySessionConnection() { }
157 
158 
159 
165  {
166  const RandID forkRootID{stage::ATTR_fork};
167  const GenNode timeline = emptyTimeline (baseID, forkRootID);
168  const GenNode rootTrackName = GenNode{string{stage::ATTR_name}, "Track-"+baseID};
169  const GenNode forkRoot = MakeRec().genNode(forkRootID);
170  const GenNode clip1 = clip ("Clip-1", Time::ZERO);
171  const GenNode clip2 = clip ("Clip-2", Time::NEVER);
172 
173  return MutationMessage{after(Ref::END)
174  , ins (timeline)
175  , mut (timeline)
176  , mut (forkRoot)
177  , set (rootTrackName)
178  , ins (clip1)
179  , ins (clip2)
180  , mut (clip1)
181  , ins (makeName(clip1))
182  , emu (clip1)
183  , mut (clip2)
184  , ins (makeName(clip2))
185  , ins (defineTiming(Time{FSecs{5}}, Duration{FSecs{4}}))
186  , emu (clip2)
187  , emu (forkRoot)
188  , emu (timeline)
189  };
190  }
191 
192 
198  {
199  const RandID forkRootID{stage::ATTR_fork};
200  const GenNode timeline = emptyTimeline (baseID, forkRootID);
201  const GenNode rootTrackName = GenNode{string{stage::ATTR_name}, "Fork-Root"};
202  const GenNode forkRoot = MakeRec().genNode(forkRootID);
203  const GenNode track1 = emptyTrack ("Track-1");
204  const GenNode track2 = emptyTrack ("Track-2");
205  const GenNode track21 = emptyTrack ("Track-21");
206  const GenNode track22 = emptyTrack ("Track-22");
207  const GenNode track221 = emptyTrack ("Track-221");
208  const GenNode track222 = emptyTrack ("Track-222");
209  const GenNode timeRuler = ruler();
210  const GenNode scopeRuler0 = ruler();
211  const GenNode scopeRuler2 = ruler();
212  const GenNode scopeRuler22 = ruler();
213  const GenNode scopeRuler221 = ruler();
214 
215  return MutationMessage{after(Ref::END)
216  , ins (timeline)
217  , mut (timeline)
218  , mut (forkRoot)
219  , ins (rootTrackName)
220  , ins (track1)
221  , ins (track2)
222  , ins (timeRuler)
223  , ins (scopeRuler0)
224  , mut (track1)
225  , ins (makeName(track1))
226  , emu (track1)
227  , mut (track2)
228  , ins (makeName(track2))
229  , ins (track21)
230  , ins (track22)
231  , ins (scopeRuler2)
232  , mut (track21)
233  , ins (makeName(track21))
234  , emu (track21)
235  , mut (track22)
236  , ins (makeName(track22))
237  , ins (track221)
238  , ins (track222)
239  , ins (scopeRuler22)
240  , mut (track221)
241  , ins (makeName(track221))
242  , ins (scopeRuler221)
243  , emu (track221)
244  , mut (track222)
245  , ins (makeName(track222))
246  , emu (track222)
247  , emu (track22)
248  , emu (track2)
249  , emu (forkRoot)
250  , emu (timeline)
251  };
252  }
253 
254 
256  void
258  {
259  TODO ("build internal diagnostic data structure, apply a copy of the message");
260  }
261 
262 
263 }}// namespace steam::mobject::session
264 
265 namespace cmd {
266 
267  using lib::hash::LuidH;
268  using stage::ID;
269  using stage::NOTE_INFO;
270  using stage::NOTE_WARN;
271  using stage::NOTE_ERROR;
272 // using stage::NotifyLevel;
273 // using stage::MARK_expand;
275 // using util::isYes;
276 
277  namespace session = steam::mobject::session;
278 
279  using DummySess = session::DummySessionConnection;
280 
281 
282  /* ============ dedicated Fake-Commands ============ */
283 
293 COMMAND_DEFINITION (test_fake_injectSequence_1)
294  {
295  def.operation ([](string dummyID)
296  {
297  string message{_Fmt{"fabricate Sequence_1 (dummyID='%s')"} % dummyID};
298  GuiNotification::facade().displayInfo (NOTE_INFO, message);
299  auto popuDiff = DummySess::instance().fabricateSeq1 (dummyID);
300  DummySess::instance().applyCopy (popuDiff);
301  auto rootID = session::Root::getID();
302  GuiNotification::facade().mutate (rootID, move(popuDiff));
303  })
304  .captureUndo ([](string dummyID) -> string
305  {
306  return _Fmt{"fabricateSequence_1('%s')"} % dummyID;
307  })
308  .undoOperation ([](string, string memento)
309  {
310  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
311  });
312  };
313 
314 
319 COMMAND_DEFINITION (test_fake_injectSequence_2)
320  {
321  def.operation ([](string dummyID)
322  {
323  string message{_Fmt{"fabricate Sequence_2 (dummyID='%s')"} % dummyID};
324  GuiNotification::facade().displayInfo (NOTE_INFO, message);
325  auto popuDiff = DummySess::instance().fabricateSeq2 (dummyID);
326  DummySess::instance().applyCopy (popuDiff);
327  auto rootID = session::Root::getID();
328  GuiNotification::facade().mutate (rootID, move(popuDiff));
329  })
330  .captureUndo ([](string dummyID) -> string
331  {
332  return _Fmt{"fabricateSequence_2('%s')"} % dummyID;
333  })
334  .undoOperation ([](string, string memento)
335  {
336  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
337  });
338  };
339 
340 
344 COMMAND_DEFINITION (test_fake_blubb)
345  {
346  def.operation ([](string dummyID)
347  {
348  string message{_Fmt{"fabricate gulp (dummyID='%s')"} % dummyID};
349  GuiNotification::facade().displayInfo (NOTE_INFO, message);
350  })
351  .captureUndo ([](string dummyID) -> string
352  {
353  return _Fmt{"fabricateGulp('%s')"} % dummyID;
354  })
355  .undoOperation ([](string, string memento)
356  {
357  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
358  });
359  };
360 
361 
362 }} // namespace steam::mobject::session
Concrete implementation to apply structural changes to hierarchical data structures.
GenNode makeName(GenNode const &elm)
fabricate an attribute node based on the human-readable part of the given elemen&#39;s ID ...
Generic Message with an embedded diff, to describe changes to model elements.
Automatically use custom string conversion in C++ stream output.
Constructor for a specially crafted &#39;ref GenNode&#39;.
Definition: gen-node.hpp:840
MutationMessage fabricateSeq1(string baseID)
Build a population diff message to describe a specific session structure to add.
Hard wired key constants and basic definitions for communication with the GUI.
Major public Interface of the Lumiera GUI.
Entry-ID with a symbolic tag but just a plain random hash part.
Definition: entry-id.hpp:303
static lib::idi::EntryID< Root > getID()
get an unique ID to identify "the model root".
Definition: root.cpp:57
GenNode defineTiming(Time start, Duration dur=Duration{FSecs{1}})
define the (optional) timings for a clip
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.
something to be aware of, to be indicated unobtrusively
Opaque message to effect a structural change on a target, which is likewise only known in an abstract...
Steam-Layer implementation namespace root.
A front-end for using printf-style formatting.
MObject within the session to represent "the session itself".
Namespace of Session and user visible high-level objects.
Definition: sequence.hpp:74
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:305
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.
boost::rational< int64_t > FSecs
rational representation of fractional seconds
Definition: timevalue.hpp:226
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...
static const Time NEVER
border condition marker value. NEVER >= any time value
Definition: timevalue.hpp:320
Duration is the internal Lumiera time metric.
Definition: timevalue.hpp:474
severe condition to be indicated prominently
MutationMessage fabricateSeq2(string baseID)
Build another population diff message for a way more contrived timeline structure.
A time interval anchored at a specific point in time.
Definition: timevalue.hpp:579
Scaffolding to drive the evolution of the Lumiera application.
Actually defining a command and binding it to execution parameters.
a family of time value like entities and their relationships.
possibly interesting info that can be safely ignored
generic data element node within a tree
Definition: gen-node.hpp:231
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container
Definition: util.hpp:230
static lib::Depend< DummySessionConnection > instance
access point to set up the scaffolding.