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) Lumiera.org
5  2008, 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 
39 using std::unique_ptr;
40 
41 namespace steam {
42 namespace mobject {
43 namespace session {
44 
45  inline LocatingPin*
46  cloneChain (const unique_ptr<LocatingPin>& chain)
47  {
48  if (!chain)
49  return 0;
50  else
51  return chain->clone();
52  }
53 
54 
58  LocatingPin::LocatingPin (const LocatingPin& other)
59  : next_(cloneChain (other.next_))
60  { }
61 
62 
63  LocatingPin&
64  LocatingPin::operator= (const LocatingPin& other)
65  {
66  if (this != &other)
67  this->next_.reset (cloneChain (other.next_));
68  return *this;
69  }
70 
71 
72  LocatingPin*
73  LocatingPin::clone () const
74  {
75  return new LocatingPin(*this);
76  }
77 
78 
79 
82  {
83  REQUIRE (newLp);
84  REQUIRE (!newLp->next_, "can insert only single LocatingPins");
85 
86  if (next_ && newLp->getPrioLevel() > next_->getPrioLevel())
87  return next_->addChain (newLp);
88  else
89  {
90  unique_ptr<LocatingPin> tmp_next (newLp);
91  tmp_next->next_.swap(next_);
92  next_.swap(tmp_next);
93  return *newLp;
94  }
95  }
96 
97 
108  const LocatingPin::SolutionData
110  {
111  LocatingSolution solution;
112  resolve (solution);
113  return SolutionData (solution.getTime(), solution.getPipe());
114  }
115 
116  bool
117  LocatingPin::isOverdetermined () const
118  {
119  LocatingSolution solution;
120  resolve (solution);
121  return solution.is_impossible();
122  }
123 
124 
125 
126  void
127  LocatingPin::resolve (LocatingSolution& solution) const
128  {
129  if (!solution.still_to_solve())
130  return;
131  this->intersect (solution);
132  if (next_ && solution.still_to_solve())
133  next_->resolve(solution);
134  }
135 
136 
137  void
138  LocatingPin::intersect (LocatingSolution& solution) const
139  {
140  REQUIRE (solution.still_to_solve());
141  // base class Implementation is NOP...
142  }
143 
144 
153  {
154  return minTime;
155  }
156 
158  LocatingPin::LocatingSolution::getPipe()
159  {
160  TODO ("implement Placement LocatingSolution");
161  return asset::Pipe::query ("pipe(master)"); // yet another idiotic dummy
162  }
163 
164 
165  bool
166  LocatingPin::LocatingSolution::is_definite()
167  {
168  return (minTime == maxTime && minTrack == maxTrack);
169  }
170 
171  bool
172  LocatingPin::LocatingSolution::is_impossible()
173  {
174  if (minTime > maxTime) impo = true;
175  TODO ("track???");
176  return impo;
177  }
178 
179  bool
180  LocatingPin::LocatingSolution::still_to_solve ()
181  {
182  return not (is_definite() or is_impossible());
183  }
184 
185 
186 
187 
188 
189 
190 
191 
192  /* === Factory functions for adding LocatingPins === */
193 
194  FixedLocation&
195  LocatingPin::operator() (Time start, Fork track)
196  {
197  return static_cast<FixedLocation&>
198  (addChain (new FixedLocation (start, track)));
199  }
200 
201 
203  LocatingPin::operator() (PlaRef& refObj, Offset const& offset)
204  {
205  return static_cast<RelativeLocation&>
206  (addChain (new RelativeLocation (refObj, offset)));
207  }
208 
209 
210 
211 
212 }}} // 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
Core abstraction of the Session model: a media object.
Positioning specification, possibly chained to further specifications.
Definition: locatingpin.hpp:97
Steam-Layer implementation namespace root.
Implementing the Placement mechanics.
Namespace of Session and user visible high-level objects.
Definition: sequence.hpp:74
Lumiera&#39;s internal time value datatype.
Definition: timevalue.hpp:308
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:66
Specialised LocatingPin for use in Placement, especially for globally fixed positions The FixedLocati...
LocatingPin & addChain(LocatingPin *)
Definition: locatingpin.cpp:81
Offset measures a distance in time.
Definition: timevalue.hpp:367
virtual int getPrioLevel() const
order to consider when resolving.
Time getTime()
get some time value which could stand in for this solution.