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/symbol.hpp"
39 //#include "include/logging.h"
43 #include "include/ui-protocol.hpp"
47 #include "lib/diff/gen-node.hpp"
48 #include "lib/time/timevalue.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 
59 using lib::diff::GenNode;
60 using lib::diff::MakeRec;
61 using lib::diff::Ref;
62 using lib::idi::RandID;
63 using lib::time::Time;
64 using lib::time::FSecs;
67 //using util::cStr;
68 using util::_Fmt;
69 using std::string;
70 
71 #include <string>
72 
73 //using std::map;
74 using std::string;
75 
76 using util::contains;
77 using util::isnil;
78 
79 namespace steam {
80 namespace mobject {
81 namespace session {
82 
83  namespace { //Implementation details....
84 
88  GenNode
89  emptyTimeline (string baseID, RandID const& forkRootID)
90  {
91  return MakeRec()
92  .set(MakeRec()
93  .type (string{stage::TYPE_Fork})
94  .genNode(forkRootID)
95  )
96  .genNode(baseID);
97  }
98 
99  GenNode
100  emptyTrack (string trackID)
101  {
102  return MakeRec()
103  .type (string{stage::TYPE_Fork})
104  .genNode(trackID);
105  }
106 
107  GenNode
108  ruler()
109  {
110  return MakeRec()
111  .type (string{stage::TYPE_Ruler})
112  .genNode("Ruler");
113  }
114 
115  GenNode
116  clip (string clipID, TimeSpan timings)
117  {
118  return MakeRec()
119  .type (string{stage::TYPE_Clip})
120  .set(string{stage::ATTR_timing}, timings)
121  .genNode(clipID);
122  }
123  GenNode
124  clip (string clipID, Time start, Duration dur = Duration{FSecs{1}})
125  {
126  return clip (clipID, TimeSpan{start,dur});
127  }
128 
131  GenNode
132  makeName (GenNode const& elm)
133  {
134  return GenNode{string{stage::ATTR_name}, elm.idi.getSym() };
135  }
136 
138  GenNode
139  defineTiming (Time start, Duration dur = Duration{FSecs{1}})
140  {
141  return GenNode{string{stage::ATTR_timing}, TimeSpan{start,dur} };
142  }
143  } //(End)Implementation details....
144 
145 
146 
147 
150 
151 
152  DummySessionConnection::DummySessionConnection()
153  { }
154 
155  DummySessionConnection::~DummySessionConnection() { }
156 
157 
158 
164  {
165  const RandID forkRootID{stage::ATTR_fork};
166  const GenNode timeline = emptyTimeline (baseID, forkRootID);
167  const GenNode rootTrackName = GenNode{string{stage::ATTR_name}, "Track-"+baseID};
168  const GenNode forkRoot = MakeRec().genNode(forkRootID);
169  const GenNode clip1 = clip ("Clip-1", Time::ZERO);
170  const GenNode clip2 = clip ("Clip-2", Time::NEVER);
171 
172  return MutationMessage{after(Ref::END)
173  , ins (timeline)
174  , mut (timeline)
175  , mut (forkRoot)
176  , set (rootTrackName)
177  , ins (clip1)
178  , ins (clip2)
179  , mut (clip1)
180  , ins (makeName(clip1))
181  , emu (clip1)
182  , mut (clip2)
183  , ins (makeName(clip2))
184  , ins (defineTiming(Time{FSecs{5}}, Duration{FSecs{4}}))
185  , emu (clip2)
186  , emu (forkRoot)
187  , emu (timeline)
188  };
189  }
190 
191 
197  {
198  const RandID forkRootID{stage::ATTR_fork};
199  const GenNode timeline = emptyTimeline (baseID, forkRootID);
200  const GenNode rootTrackName = GenNode{string{stage::ATTR_name}, "Fork-Root"};
201  const GenNode forkRoot = MakeRec().genNode(forkRootID);
202  const GenNode track1 = emptyTrack ("Track-1");
203  const GenNode track2 = emptyTrack ("Track-2");
204  const GenNode track21 = emptyTrack ("Track-21");
205  const GenNode track22 = emptyTrack ("Track-22");
206  const GenNode track221 = emptyTrack ("Track-221");
207  const GenNode track222 = emptyTrack ("Track-222");
208  const GenNode timeRuler = ruler();
209  const GenNode scopeRuler0 = ruler();
210  const GenNode scopeRuler2 = ruler();
211  const GenNode scopeRuler22 = ruler();
212  const GenNode scopeRuler221 = ruler();
213 
214  return MutationMessage{after(Ref::END)
215  , ins (timeline)
216  , mut (timeline)
217  , mut (forkRoot)
218  , ins (rootTrackName)
219  , ins (track1)
220  , ins (track2)
221  , ins (timeRuler)
222  , ins (scopeRuler0)
223  , mut (track1)
224  , ins (makeName(track1))
225  , emu (track1)
226  , mut (track2)
227  , ins (makeName(track2))
228  , ins (track21)
229  , ins (track22)
230  , ins (scopeRuler2)
231  , mut (track21)
232  , ins (makeName(track21))
233  , emu (track21)
234  , mut (track22)
235  , ins (makeName(track22))
236  , ins (track221)
237  , ins (track222)
238  , ins (scopeRuler22)
239  , mut (track221)
240  , ins (makeName(track221))
241  , ins (scopeRuler221)
242  , emu (track221)
243  , mut (track222)
244  , ins (makeName(track222))
245  , emu (track222)
246  , emu (track22)
247  , emu (track2)
248  , emu (forkRoot)
249  , emu (timeline)
250  };
251  }
252 
253 
255  void
257  {
258  TODO ("build internal diagnostic data structure, apply a copy of the message");
259  }
260 
261 
262 }}// namespace steam::mobject::session
263 
264 namespace cmd {
265 
266  using lib::hash::LuidH;
267  using stage::ID;
268  using stage::NOTE_INFO;
269  using stage::NOTE_WARN;
270  using stage::NOTE_ERROR;
271 // using stage::NotifyLevel;
272 // using stage::MARK_expand;
274 // using util::isYes;
275 
276  namespace session = steam::mobject::session;
277 
278  using DummySess = session::DummySessionConnection;
279 
280 
281  /* ============ dedicated Fake-Commands ============ */
282 
292 COMMAND_DEFINITION (test_fake_injectSequence_1)
293  {
294  def.operation ([](string dummyID)
295  {
296  string message{_Fmt{"fabricate Sequence_1 (dummyID='%s')"} % dummyID};
297  GuiNotification::facade().displayInfo (NOTE_INFO, message);
298  auto popuDiff = DummySess::instance().fabricateSeq1 (dummyID);
299  DummySess::instance().applyCopy (popuDiff);
300  auto rootID = session::Root::getID();
301  GuiNotification::facade().mutate (rootID, move(popuDiff));
302  })
303  .captureUndo ([](string dummyID) -> string
304  {
305  return _Fmt{"fabricateSequence_1('%s')"} % dummyID;
306  })
307  .undoOperation ([](string, string memento)
308  {
309  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
310  });
311  };
312 
313 
318 COMMAND_DEFINITION (test_fake_injectSequence_2)
319  {
320  def.operation ([](string dummyID)
321  {
322  string message{_Fmt{"fabricate Sequence_2 (dummyID='%s')"} % dummyID};
323  GuiNotification::facade().displayInfo (NOTE_INFO, message);
324  auto popuDiff = DummySess::instance().fabricateSeq2 (dummyID);
325  DummySess::instance().applyCopy (popuDiff);
326  auto rootID = session::Root::getID();
327  GuiNotification::facade().mutate (rootID, move(popuDiff));
328  })
329  .captureUndo ([](string dummyID) -> string
330  {
331  return _Fmt{"fabricateSequence_2('%s')"} % dummyID;
332  })
333  .undoOperation ([](string, string memento)
334  {
335  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
336  });
337  };
338 
339 
343 COMMAND_DEFINITION (test_fake_blubb)
344  {
345  def.operation ([](string dummyID)
346  {
347  string message{_Fmt{"fabricate gulp (dummyID='%s')"} % dummyID};
348  GuiNotification::facade().displayInfo (NOTE_INFO, message);
349  })
350  .captureUndo ([](string dummyID) -> string
351  {
352  return _Fmt{"fabricateGulp('%s')"} % dummyID;
353  })
354  .undoOperation ([](string, string memento)
355  {
356  GuiNotification::facade().displayInfo (NOTE_WARN, "can not UNDO Dummy-Action: "+memento);
357  });
358  };
359 
360 
361 }} // 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:849
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:308
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:229
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:323
Duration is the internal Lumiera time metric.
Definition: timevalue.hpp:477
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:582
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:255
static lib::Depend< DummySessionConnection > instance
access point to set up the scaffolding.