Lumiera  0.pre.03
»edit your freedom«
locatingpin.cpp
Go to the documentation of this file.
1 /*
2  LocatingPin - Chaining and constraining the Placement of a Media Object
3 
4  Copyright (C)
5  2008, 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 
30 using std::unique_ptr;
31 
32 namespace steam {
33 namespace mobject {
34 namespace session {
35 
36  inline LocatingPin*
37  cloneChain (const unique_ptr<LocatingPin>& chain)
38  {
39  if (!chain)
40  return 0;
41  else
42  return chain->clone();
43  }
44 
45 
49  LocatingPin::LocatingPin (const LocatingPin& other)
50  : next_(cloneChain (other.next_))
51  { }
52 
53 
54  LocatingPin&
55  LocatingPin::operator= (const LocatingPin& other)
56  {
57  if (this != &other)
58  this->next_.reset (cloneChain (other.next_));
59  return *this;
60  }
61 
62 
63  LocatingPin*
64  LocatingPin::clone () const
65  {
66  return new LocatingPin(*this);
67  }
68 
69 
70 
73  {
74  REQUIRE (newLp);
75  REQUIRE (!newLp->next_, "can insert only single LocatingPins");
76 
77  if (next_ && newLp->getPrioLevel() > next_->getPrioLevel())
78  return next_->addChain (newLp);
79  else
80  {
81  unique_ptr<LocatingPin> tmp_next (newLp);
82  tmp_next->next_.swap(next_);
83  next_.swap(tmp_next);
84  return *newLp;
85  }
86  }
87 
88 
99  const LocatingPin::SolutionData
101  {
102  LocatingSolution solution;
103  resolve (solution);
104  return SolutionData (solution.getTime(), solution.getPipe());
105  }
106 
107  bool
108  LocatingPin::isOverdetermined () const
109  {
110  LocatingSolution solution;
111  resolve (solution);
112  return solution.is_impossible();
113  }
114 
115 
116 
117  void
118  LocatingPin::resolve (LocatingSolution& solution) const
119  {
120  if (!solution.still_to_solve())
121  return;
122  this->intersect (solution);
123  if (next_ && solution.still_to_solve())
124  next_->resolve(solution);
125  }
126 
127 
128  void
129  LocatingPin::intersect (LocatingSolution& solution) const
130  {
131  REQUIRE (solution.still_to_solve());
132  // base class Implementation is NOP...
133  }
134 
135 
144  {
145  return minTime;
146  }
147 
149  LocatingPin::LocatingSolution::getPipe()
150  {
151  TODO ("implement Placement LocatingSolution");
152  return asset::Pipe::query ("pipe(master)"); // yet another idiotic dummy
153  }
154 
155 
156  bool
157  LocatingPin::LocatingSolution::is_definite()
158  {
159  return (minTime == maxTime && minTrack == maxTrack);
160  }
161 
162  bool
163  LocatingPin::LocatingSolution::is_impossible()
164  {
165  if (minTime > maxTime) impo = true;
166  TODO ("track???");
167  return impo;
168  }
169 
170  bool
171  LocatingPin::LocatingSolution::still_to_solve ()
172  {
173  return not (is_definite() or is_impossible());
174  }
175 
176 
177 
178 
179 
180 
181 
182 
183  /* === Factory functions for adding LocatingPins === */
184 
185  FixedLocation&
186  LocatingPin::operator() (Time start, Fork track)
187  {
188  return static_cast<FixedLocation&>
189  (addChain (new FixedLocation (start, track)));
190  }
191 
192 
194  LocatingPin::operator() (PlaRef& refObj, Offset const& offset)
195  {
196  return static_cast<RelativeLocation&>
197  (addChain (new RelativeLocation (refObj, offset)));
198  }
199 
200 
201 
202 
203 }}} // namespace steam::mobject::session
Core abstraction: placement of a media object into session context.
const SolutionData resolve() const
implementing the core Placement functionality.
std::unique_ptr< LocatingPin > next_
next additional Pin, if any
Definition: locatingpin.hpp:97
Core abstraction of the Session model: a media object.
Positioning specification, possibly chained to further specifications.
Definition: locatingpin.hpp:88
Steam-Layer implementation namespace root.
Implementing the Placement mechanics.
Namespace of Session and user visible high-level objects.
Definition: sequence.hpp:65
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:299
The most common case of positioning a MObject in the Session: directly specifying a constant position...
static PPipe query(string const &properties)
convenience shortcut for retrieving default configured pipes
Definition: pipe.cpp:57
Specialised LocatingPin for use in Placement, especially for globally fixed positions The FixedLocati...
LocatingPin & addChain(LocatingPin *)
Definition: locatingpin.cpp:72
Offset measures a distance in time.
Definition: timevalue.hpp:358
virtual int getPrioLevel() const
order to consider when resolving.
Time getTime()
get some time value which could stand in for this solution.