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)
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 
29 //#include "lib/symbol.hpp"
30 //#include "include/logging.h"
34 #include "include/ui-protocol.hpp"
38 #include "lib/diff/gen-node.hpp"
39 #include "lib/time/timevalue.hpp"
40 //#include "lib/idi/entry-id.hpp"
41 #include "lib/format-string.hpp"
42 #include "lib/format-cout.hpp"
43 //#include "lib/symbol.hpp"
44 #include "lib/util.hpp"
45 
46 #include <string>
47 //#include <map>
48 
50 using lib::diff::GenNode;
51 using lib::diff::MakeRec;
52 using lib::diff::Ref;
53 using lib::idi::RandID;
54 using lib::time::Time;
55 using lib::time::FSecs;
58 //using util::cStr;
59 using util::_Fmt;
60 using std::string;
61 
62 #include <string>
63 
64 //using std::map;
65 using std::string;
66 
67 using util::contains;
68 using util::isnil;
69 
70 namespace steam {
71 namespace mobject {
72 namespace session {
73 
74  namespace { //Implementation details....
75 
79  GenNode
80  emptyTimeline (string baseID, RandID const& forkRootID)
81  {
82  return MakeRec()
83  .set(MakeRec()
84  .type (string{stage::TYPE_Fork})
85  .genNode(forkRootID)
86  )
87  .genNode(baseID);
88  }
89 
90  GenNode
91  emptyTrack (string trackID)
92  {
93  return MakeRec()
94  .type (string{stage::TYPE_Fork})
95  .genNode(trackID);
96  }
97 
98  GenNode
99  ruler()
100  {
101  return MakeRec()
102  .type (string{stage::TYPE_Ruler})
103  .genNode("Ruler");
104  }
105 
106  GenNode
107  clip (string clipID, TimeSpan timings)
108  {
109  return MakeRec()
110  .type (string{stage::TYPE_Clip})
111  .set(string{stage::ATTR_timing}, timings)
112  .genNode(clipID);
113  }
114  GenNode
115  clip (string clipID, Time start, Duration dur = Duration{FSecs{1}})
116  {
117  return clip (clipID, TimeSpan{start,dur});
118  }
119 
122  GenNode
123  makeName (GenNode const& elm)
124  {
125  return GenNode{string{stage::ATTR_name}, elm.idi.getSym() };
126  }
127 
129  GenNode
130  defineTiming (Time start, Duration dur = Duration{FSecs{1}})
131  {
132  return GenNode{string{stage::ATTR_timing}, TimeSpan{start,dur} };
133  }
134  } //(End)Implementation details....
135 
136 
137 
138 
141 
142 
143  DummySessionConnection::DummySessionConnection()
144  { }
145 
146  DummySessionConnection::~DummySessionConnection() { }
147 
148 
149 
155  {
156  const RandID forkRootID{stage::ATTR_fork};
157  const GenNode timeline = emptyTimeline (baseID, forkRootID);
158  const GenNode rootTrackName = GenNode{string{stage::ATTR_name}, "Track-"+baseID};
159  const GenNode forkRoot = MakeRec().genNode(forkRootID);
160  const GenNode clip1 = clip ("Clip-1", Time::ZERO);
161  const GenNode clip2 = clip ("Clip-2", Time::NEVER);
162 
163  return MutationMessage{after(Ref::END)
164  , ins (timeline)
165  , mut (timeline)
166  , mut (forkRoot)
167  , set (rootTrackName)
168  , ins (clip1)
169  , ins (clip2)
170  , mut (clip1)
171  , ins (makeName(clip1))
172  , emu (clip1)
173  , mut (clip2)
174  , ins (makeName(clip2))
175  , ins (defineTiming(Time{FSecs{5}}, Duration{FSecs{4}}))
176  , emu (clip2)
177  , emu (forkRoot)
178  , emu (timeline)
179  };
180  }
181 
182 
188  {
189  const RandID forkRootID{stage::ATTR_fork};
190  const GenNode timeline = emptyTimeline (baseID, forkRootID);
191  const GenNode rootTrackName = GenNode{string{stage::ATTR_name}, "Fork-Root"};
192  const GenNode forkRoot = MakeRec().genNode(forkRootID);
193  const GenNode track1 = emptyTrack ("Track-1");
194  const GenNode track2 = emptyTrack ("Track-2");
195  const GenNode track21 = emptyTrack ("Track-21");
196  const GenNode track22 = emptyTrack ("Track-22");
197  const GenNode track221 = emptyTrack ("Track-221");
198  const GenNode track222 = emptyTrack ("Track-222");
199  const GenNode timeRuler = ruler();
200  const GenNode scopeRuler0 = ruler();
201  const GenNode scopeRuler2 = ruler();
202  const GenNode scopeRuler22 = ruler();
203  const GenNode scopeRuler221 = ruler();
204 
205  return MutationMessage{after(Ref::END)
206  , ins (timeline)
207  , mut (timeline)
208  , mut (forkRoot)
209  , ins (rootTrackName)
210  , ins (track1)
211  , ins (track2)
212  , ins (timeRuler)
213  , ins (scopeRuler0)
214  , mut (track1)
215  , ins (makeName(track1))
216  , emu (track1)
217  , mut (track2)
218  , ins (makeName(track2))
219  , ins (track21)
220  , ins (track22)
221  , ins (scopeRuler2)
222  , mut (track21)
223  , ins (makeName(track21))
224  , emu (track21)
225  , mut (track22)
226  , ins (makeName(track22))
227  , ins (track221)
228  , ins (track222)
229  , ins (scopeRuler22)
230  , mut (track221)
231  , ins (makeName(track221))
232  , ins (scopeRuler221)
233  , emu (track221)
234  , mut (track222)
235  , ins (makeName(track222))
236  , emu (track222)
237  , emu (track22)
238  , emu (track2)
239  , emu (forkRoot)
240  , emu (timeline)
241  };
242  }
243 
244 
246  void
248  {
249  TODO ("build internal diagnostic data structure, apply a copy of the message");
250  }
251 
252 
253 }}// namespace steam::mobject::session
254 
255 namespace cmd {
256 
257  using lib::hash::LuidH;
258  using stage::ID;
259  using stage::NOTE_INFO;
260  using stage::NOTE_WARN;
261  using stage::NOTE_ERROR;
262 // using stage::NotifyLevel;
263 // using stage::MARK_expand;
265 // using util::isYes;
266 
267  namespace session = steam::mobject::session;
268 
269  using DummySess = session::DummySessionConnection;
270 
271 
272  /* ============ dedicated Fake-Commands ============ */
273 
283 COMMAND_DEFINITION (test_fake_injectSequence_1)
284  {
285  def.operation ([](string dummyID)
286  {
287  string message{_Fmt{"fabricate Sequence_1 (dummyID='%s')"} % dummyID};
288  GuiNotification::facade().displayInfo (NOTE_INFO, message);
289  auto popuDiff = DummySess::instance().fabricateSeq1 (dummyID);
290  DummySess::instance().applyCopy (popuDiff);
291  auto rootID = session::Root::getID();
292  GuiNotification::facade().mutate (rootID, move(popuDiff));
293  })
294  .captureUndo ([](string dummyID) -> string
295  {
296  return _Fmt{"fabricateSequence_1('%s')"} % dummyID;
297  })
298  .undoOperation ([](string, string memento)
299  {
300  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
301  });
302  };
303 
304 
309 COMMAND_DEFINITION (test_fake_injectSequence_2)
310  {
311  def.operation ([](string dummyID)
312  {
313  string message{_Fmt{"fabricate Sequence_2 (dummyID='%s')"} % dummyID};
314  GuiNotification::facade().displayInfo (NOTE_INFO, message);
315  auto popuDiff = DummySess::instance().fabricateSeq2 (dummyID);
316  DummySess::instance().applyCopy (popuDiff);
317  auto rootID = session::Root::getID();
318  GuiNotification::facade().mutate (rootID, move(popuDiff));
319  })
320  .captureUndo ([](string dummyID) -> string
321  {
322  return _Fmt{"fabricateSequence_2('%s')"} % dummyID;
323  })
324  .undoOperation ([](string, string memento)
325  {
326  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
327  });
328  };
329 
330 
334 COMMAND_DEFINITION (test_fake_blubb)
335  {
336  def.operation ([](string dummyID)
337  {
338  string message{_Fmt{"fabricate gulp (dummyID='%s')"} % dummyID};
339  GuiNotification::facade().displayInfo (NOTE_INFO, message);
340  })
341  .captureUndo ([](string dummyID) -> string
342  {
343  return _Fmt{"fabricateGulp('%s')"} % dummyID;
344  })
345  .undoOperation ([](string, string memento)
346  {
347  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
348  });
349  };
350 
351 
352 }} // 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:294
static lib::idi::EntryID< Root > getID()
get an unique ID to identify "the model root".
Definition: root.cpp:48
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:65
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:280
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:299
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:220
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:314
Duration is the internal Lumiera time metric.
Definition: timevalue.hpp:468
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:573
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:222
bool contains(SEQ const &cont, typename SEQ::const_reference val)
shortcut for brute-force containment test in any sequential container
Definition: util.hpp:255
static lib::Depend< DummySessionConnection > instance
access point to set up the scaffolding.