00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "proc/mobject/placement.hpp"
00025 #include "proc/mobject/session/locatingpin.hpp"
00026 #include "proc/mobject/session/fixedlocation.hpp"
00027 #include "proc/mobject/session/relativelocation.hpp"
00028
00029 namespace mobject
00030 {
00031 namespace session
00032 {
00033 inline LocatingPin*
00034 cloneChain (const scoped_ptr<LocatingPin>& chain)
00035 {
00036 if (!chain)
00037 return 0;
00038 else
00039 return chain->clone();
00040 }
00041
00042
00046 LocatingPin::LocatingPin (const LocatingPin& other)
00047 : next_(cloneChain (other.next_))
00048 { }
00049
00050
00051 LocatingPin&
00052 LocatingPin::operator= (const LocatingPin& other)
00053 {
00054 if (this != &other)
00055 this->next_.reset (cloneChain (other.next_));
00056 return *this;
00057 }
00058
00059
00060 LocatingPin*
00061 LocatingPin::clone () const
00062 {
00063 return new LocatingPin(*this);
00064 }
00065
00066
00067
00068 LocatingPin&
00069 LocatingPin::addChain (LocatingPin* newLp)
00070 {
00071 REQUIRE (newLp);
00072 REQUIRE (!newLp->next_, "can insert only single LocatingPins");
00073
00074 if (next_ && newLp->getPrioLevel() > next_->getPrioLevel())
00075 return next_->addChain (newLp);
00076 else
00077 {
00078 scoped_ptr<LocatingPin> tmp_next (newLp);
00079 tmp_next->next_.swap(next_);
00080 next_.swap(tmp_next);
00081 return *newLp;
00082 }
00083 }
00084
00085
00096 const LocatingPin::SolutionData
00097 LocatingPin::resolve () const
00098 {
00099 LocatingSolution solution;
00100 resolve (solution);
00101 return SolutionData (solution.getTime(), solution.getPipe());
00102 }
00103
00104 bool
00105 LocatingPin::isOverdetermined () const
00106 {
00107 LocatingSolution solution;
00108 resolve (solution);
00109 return solution.is_impossible();
00110 }
00111
00112
00113
00114 void
00115 LocatingPin::resolve (LocatingSolution& solution) const
00116 {
00117 if (!solution.still_to_solve())
00118 return;
00119 this->intersect (solution);
00120 if (next_ && solution.still_to_solve())
00121 next_->resolve(solution);
00122 }
00123
00124
00125 void
00126 LocatingPin::intersect (LocatingSolution& solution) const
00127 {
00128 REQUIRE (solution.still_to_solve());
00129
00130 }
00131
00132
00139 LocatingPin::Time
00140 LocatingPin::LocatingSolution::getTime()
00141 {
00142 return minTime;
00143 }
00144
00145 LocatingPin::Pipe
00146 LocatingPin::LocatingSolution::getPipe()
00147 {
00148 UNIMPLEMENTED ("get effective Pipe of Solution");
00149 return Pipe ();
00150 }
00151
00152
00153 bool
00154 LocatingPin::LocatingSolution::is_definite()
00155 {
00156 return (minTime == maxTime && minTrack == maxTrack);
00157 }
00158
00159 bool
00160 LocatingPin::LocatingSolution::is_impossible()
00161 {
00162 if (minTime > maxTime) impo = true;
00163 TODO ("track???");
00164 return impo;
00165 }
00166
00167 bool
00168 LocatingPin::LocatingSolution::still_to_solve ()
00169 {
00170 return !(is_definite() || is_impossible());
00171 }
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 FixedLocation&
00183 LocatingPin::operator() (Time start, Track track)
00184 {
00185 return static_cast<FixedLocation&>
00186 (addChain (new FixedLocation (start, track)));
00187 }
00188
00189
00190 RelativeLocation&
00191 LocatingPin::operator() (PMO refObj, Time offset)
00192 {
00193 return static_cast<RelativeLocation&>
00194 (addChain (new RelativeLocation (refObj, offset)));
00195 }
00196
00197
00198
00199
00200 }
00201
00202 }