Lumiera  0.pre.03
»edit your freedom«
placement-object-identity-test.cpp
Go to the documentation of this file.
1 /*
2  PlacementObjectIdentity(Test) - object identity for placements into the session
3 
4  Copyright (C) Lumiera.org
5  2010, 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 
28 #include "lib/test/run.hpp"
29 #include "steam/asset/media.hpp"
38 #include "lib/time/timevalue.hpp"
39 //#include "steam/mobject/test-dummy-mobject.hpp"
40 //#include "lib/test/test-helper.hpp"
41 
42 
43 
44 namespace steam {
45 namespace mobject {
46 namespace test {
47 
48  using session::Clip;
49 
51 
52 
53 
54  /***********************************************************************/
64  class PlacementObjectIdentity_test : public Test
65  {
66 
67  typedef Placement<MObject> PMObj;
68  typedef Placement<Clip> PClip;
69 
70  typedef PlacementMO::ID PMObjID;
71  typedef PlacementMO::Id<Clip> PClipID;
72 
73 
74  virtual void
75  run (Arg)
76  {
77 
78  // create data simulating a "Session"
79  PMObj pClip1 = asset::Media::create("test-1", asset::VIDEO)->createClip();
80  PMObj pClip2 = asset::Media::create("test-2", asset::VIDEO)->createClip();
81 
82  // set up a tie to fixed start positions
83  pClip1.chain (lib::time::Time(0,10));
84  pClip2.chain (lib::time::Time(0,20));
85 
86  CHECK (pClip1->isValid());
87  CHECK (pClip2->isValid());
88  CHECK (2 == pClip1.use_count()); // one by the placement and one by the clip-Asset
89  CHECK (2 == pClip2.use_count());
90 
93 
94  UNIMPLEMENTED ("verify proper handling of object identity");
95 
96 #if false
97  // Prepare an (test)Index
98  PPIdx index = SessionServiceMockIndex::install();
99  PMO& root = index->getRoot();
100 
101  // Add the Clips to "session"
102  PMObjID clip1ID = index->insert (pClip1, root);
103  PMObjID clip2ID = index->insert (pClip2, root);
104 
107 
108 
109  // extract various kinds of IDs and refs
110  PMObj & rP1 (pClip1);
111  PMObj const& rP2 (pClip2);
112  PMObj::ID id1 = pClip1.getID();
113  PMObj::Id<Clip> id2 = pClip2.getID();
114  LumieraUid luid = id1.get();
115 
116  PlacementRef<Clip> ref1 (id1);
117  PlacementRef<MObject> ref2 (pClip2);
118 
119  MORef<Clip> rMO;
120  CHECK (!rMO); // still empty (not bound)
121 
122  // activate by binding to provided ref
123  rMO.activate(refObj);
124  CHECK (rMO); // now bound
125 
127 
128  // re-link to the Placement (note we get the Clip API!)
129  Placement<Clip> & refP = rMO.getPlacement();
130  CHECK (refP);
131  CHECK (3 == refP.use_count());
132  CHECK (&refP == placementAdr); // actually denotes the address of the original Placement in the "session"
133 
134  ExplicitPlacement exPla = refP.resolve();
135  CHECK (exPla.time == start); // recovered Placement resolves to the same time as provided by the proxied API
136  CHECK (4 == refP.use_count()); // but now we've indeed created an additional owner (exPla)
137  CHECK (4 == rMO.use_count());
138 
139 
142 
143 
145  index.reset();
146 
147 #endif
148  }
149 
150 
151  };
152 
153 
155  LAUNCHER (PlacementObjectIdentity_test, "function session");
156 
157 
158 }}} // namespace steam::mobject::test
Reference tag denoting a placement attached to the session.
An active (smart-ptr like) external reference to a specifically placed MObject "instance" within the ...
Definition: mobject-ref.hpp:94
Media data represented a specific kind of Asset.
Core abstraction: completely resolved placement of an MObject Within the session model, all media objects are attached with the help of mobject::Placement elements.
Definition: run.hpp:49
Core abstraction: placement of a media object into session context.
Special kind of Placement, where the location of the MObject has been nailed down to a fixed position...
MObject in the Session to represent a clip on the timeline.
Core abstraction of the Session model: a media object.
A user visible/editable Clip is a reference to a contiguous sequence of media data loaded as Asset in...
static MediaFactory create
storage for the static MediaFactory instance
Definition: media.hpp:84
Steam-Layer implementation namespace root.
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:308
External MObject/Placement reference.
Core of the session implementation datastructure.
Simple test class runner.
there is an implicit PlacementIndex available on a global level, by default implemented within the cu...
Implementation level session API: PlacementIndex mock for tests.
A generic reference mechanism for Placements, as added to the current session.
MORef & activate(Placement< MO > const &placement)
activate an MObject reference, based on an existing placement, which needs to be contained (added to)...
virtual bool isValid() const =0
MObject self-test (usable for asserting)
static PPIdx install()
Re-define the implicit PlacementIndex temporarily, e.g.
a family of time value like entities and their relationships.