Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
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"
38#include "lib/diff/gen-node.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
52using lib::diff::Ref;
54using lib::time::Time;
58//using util::cStr;
59using util::_Fmt;
60using std::string;
61
62#include <string>
63
64//using std::map;
65using std::string;
66
67using util::contains;
68using util::isnil;
69
70namespace steam {
71namespace mobject {
72namespace session {
73
74 namespace { //Implementation details....
75
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
91 emptyTrack (string trackID)
92 {
93 return MakeRec()
94 .type (string{stage::TYPE_Fork})
95 .genNode(trackID);
96 }
97
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
145
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
255namespace 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
268
270
271
272 /* ============ dedicated Fake-Commands ============ */
273
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
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
334COMMAND_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
Access point to singletons and other kinds of dependencies designated by type.
Definition depend.hpp:281
Mutator && set(string const &key, X &&content)
Definition record.hpp:462
Mutator && type(string const &typeID)
Definition record.hpp:454
Hash implementation based on a lumiera unique object id (LUID) When invoking the default ctor,...
string const & getSym() const
Definition entry-id.hpp:169
Duration is the internal Lumiera time metric.
A time interval anchored at a specific point in time.
Lumiera's internal time value datatype.
static const Time NEVER
border condition marker value. NEVER >= any time value
static const Time ZERO
Global access point to push state update and notification of events from the lower layers into the Lu...
static lib::Depend< GuiNotification > facade
static storage for the facade access front-end
Scaffolding to drive the evolution of the Lumiera application.
static lib::Depend< DummySessionConnection > instance
access point to set up the scaffolding.
MutationMessage fabricateSeq1(string baseID)
Build a population diff message to describe a specific session structure to add.
MutationMessage fabricateSeq2(string baseID)
Build another population diff message for a way more contrived timeline structure.
A front-end for using printf-style formatting.
Actually defining a command and binding it to execution parameters.
#define COMMAND_DEFINITION(_NAME_)
Macro to write command definitions in a compact form.
Dummy and scaffolding to help development of the UI - Session connection.
Automatically use custom string conversion in C++ stream output.
Front-end for printf-style string template interpolation.
Generic building block for tree shaped (meta)data structures.
Major public Interface of the Lumiera GUI.
Generic Message with an embedded diff, to describe changes to model elements.
boost::rational< int64_t > FSecs
rational representation of fractional seconds
lib::idi::BareEntryID const & ID
const Symbol TYPE_Ruler
@ NOTE_INFO
possibly interesting info that can be safely ignored
@ NOTE_ERROR
severe condition to be indicated prominently
@ NOTE_WARN
something to be aware of, to be indicated unobtrusively
const Symbol ATTR_name
const Symbol TYPE_Clip
const Symbol ATTR_fork
const Symbol ATTR_timing
const Symbol TYPE_Fork
CommandSetup test_fake_injectSequence_2
CommandSetup test_fake_injectSequence_1
GenNode makeName(GenNode const &elm)
fabricate an attribute node based on the human-readable part of the given elemen's ID
GenNode defineTiming(Time start, Duration dur=Duration{FSecs{1}})
define the (optional) timings for a clip
Namespace of Session and user visible high-level objects.
Definition sequence.hpp:65
Steam-Layer implementation namespace root.
bool contains(MAP &map, typename MAP::key_type const &key)
shortcut for containment test on a map
Definition util.hpp:230
bool isnil(lib::time::Duration const &dur)
MObject within the session to represent "the session itself".
generic data element node within a tree
Definition gen-node.hpp:224
Opaque message to effect a structural change on a target, which is likewise only known in an abstract...
Constructor for a specially crafted 'ref GenNode'.
Definition gen-node.hpp:843
Entry-ID with a symbolic tag but just a plain random hash part.
Definition entry-id.hpp:295
a family of time value like entities and their relationships.
Concrete implementation to apply structural changes to hierarchical data structures.
Hard wired key constants and basic definitions for communication with the GUI.
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...