2007-10-13 05:13:28 +02:00
/*
2007-10-18 17:29:01 +02:00
LOCATINGPIN . hpp - Chaining and constraining the Placement of a Media Object
2007-10-13 05:13:28 +02:00
2008-03-10 04:25:03 +01:00
Copyright ( C ) Lumiera . org
2008 , Hermann Vosseler < Ichthyostega @ web . de >
2007-10-13 05:13:28 +02:00
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation ; either version 2 of the
License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
2007-10-22 05:15:08 +02:00
/** @file locatingpin.hpp
* * Implementing the Placement mechanics . The various specifications how
* * some MObject is to be placed ( logically ) within the EDL are given by small
* * LocatingPin objects forming a chain . For resolving the actual position , at the
* * moment ( 10 / 07 ) we use a preliminary implementation to support the most common
* * Placement types ( fixed and relative ) . It is comprised of the nested LocatingSolution
* * and the functions FixedLocation # resolve ( LocatingSolution & ) and
* * RelativeLocation # resolve ( LocatingSolution & ) etc . If this is to be extended ,
2007-11-10 02:27:16 +01:00
* * we ' ll need a real spatial discrete constraint solver ( and this probably will be
* * some library implementation , because the problem is anything but trivial ) .
2009-05-29 07:10:54 +02:00
* *
* * @ todo this can be considered a preliminary sketch without being backed
* * by actual functionality . Just enough to be able to drive the design of
* * other parts ahead . See esp . Trac # 100 , which contains an idea for a
* * refactoring .
2007-10-22 05:15:08 +02:00
* *
*/
2007-10-18 17:29:01 +02:00
# ifndef MOBJECT_SESSION_LOCATINGPIN_H
# define MOBJECT_SESSION_LOCATINGPIN_H
2007-10-13 05:13:28 +02:00
2008-11-26 05:19:59 +01:00
# include "proc/common.hpp"
2007-10-19 06:39:52 +02:00
2007-11-12 02:05:39 +01:00
# include <utility>
2008-01-07 18:16:03 +01:00
# include <tr1/memory>
2007-10-19 06:39:52 +02:00
# include <boost/scoped_ptr.hpp>
using boost : : scoped_ptr ;
2007-10-13 05:13:28 +02:00
2008-02-14 04:12:30 +01:00
namespace asset { class Pipe ; }
2008-01-07 18:16:03 +01:00
2009-05-29 07:10:54 +02:00
namespace mobject {
2007-11-12 02:05:39 +01:00
class MObject ;
2007-10-13 05:13:28 +02:00
2009-05-29 07:10:54 +02:00
///////////////////////////////////////////TODO: all those dependencies are just a plain mess right now.
//
//template<class MO, class B=MObject>
//class Placement ;
//typedef Placement<MObject> PMO;
2009-06-02 03:31:52 +02:00
template < class MO = MObject >
2009-05-29 07:10:54 +02:00
class PlacementRef ; ///TODO: as of 5/09 the idea is to phase out direct dependency on the placement class and recast those dependencies in terms of PlacementRef
namespace session {
2007-10-19 06:39:52 +02:00
class FixedLocation ;
class RelativeLocation ;
2007-11-12 02:05:39 +01:00
2007-10-19 06:39:52 +02:00
2007-10-22 05:15:08 +02:00
/**
2009-05-29 07:10:54 +02:00
* Positioning specification , possibly chained
2007-10-22 05:15:08 +02:00
* to further specifications . The base class LocatingPin
* is a " no-op " specification which doesn ' t constrain the
* possible locations and thus can be embedded into pristine
* Placement by default . The Functor operators provide a
* way to add concrete positioning specifications , thereby
2007-11-10 02:27:16 +01:00
* defining the position of the MObject to be placed .
*
* @ note to the implementer of subclasses : LocatingPins are
* copyable and need to handle cloning ( incl the chain )
2007-10-22 05:15:08 +02:00
*/
class LocatingPin
2007-10-13 05:13:28 +02:00
{
protected :
2008-03-10 06:09:44 +01:00
typedef lumiera : : Time Time ;
2008-01-07 18:16:03 +01:00
typedef Time * Track ; //TODO dummy declaration; we don't use Tracks as first-class entity any longer
2008-02-14 04:12:30 +01:00
typedef std : : tr1 : : shared_ptr < asset : : Pipe > Pipe ;
2009-05-29 07:10:54 +02:00
typedef std : : pair < Time , Pipe > SolutionData ; //TODO (ichthyo considers better passing of solution by subclass)
2007-11-12 02:05:39 +01:00
struct LocatingSolution ;
2007-10-19 06:39:52 +02:00
2007-10-18 17:29:01 +02:00
/** next additional Pin, if any */
2007-10-22 05:15:08 +02:00
scoped_ptr < LocatingPin > next_ ;
/** order to consider when resolving. 0=highest */
virtual int getPrioLevel ( ) const { return 0 ; }
2007-11-10 02:27:16 +01:00
LocatingPin & addChain ( LocatingPin * ) ;
2007-10-22 05:15:08 +02:00
void resolve ( LocatingSolution & ) const ;
virtual void intersect ( LocatingSolution & ) const ;
2007-10-13 05:13:28 +02:00
public :
2007-11-12 02:05:39 +01:00
const SolutionData resolve ( ) const ;
2007-11-10 23:09:15 +01:00
bool isOverdetermined ( ) const ;
2007-10-13 05:13:28 +02:00
2007-10-22 05:15:08 +02:00
/* Factory functions for adding LocatingPins */
2007-10-19 06:39:52 +02:00
2007-11-12 02:05:39 +01:00
FixedLocation & operator ( ) ( Time start , Track track = 0 ) ;
2009-06-02 03:31:52 +02:00
RelativeLocation & operator ( ) ( PlacementRef < > & refObj , Time offset = Time ( 0 ) ) ; //////////TODO: warning, just a dummy placeholder for now!!
2007-10-22 05:15:08 +02:00
LocatingPin ( const LocatingPin & ) ;
LocatingPin & operator = ( const LocatingPin & ) ;
2007-11-10 02:27:16 +01:00
virtual LocatingPin * clone ( ) const ;
2007-10-22 05:15:08 +02:00
virtual ~ LocatingPin ( ) { } ;
2008-05-19 08:46:19 +02:00
// protected:
2007-10-22 05:15:08 +02:00
LocatingPin ( ) { } ;
2008-05-19 08:46:19 +02:00
//TODO (for working out the buildable interface; ctor should be protected)
protected :
2009-05-29 07:10:54 +02:00
// friend class Placement<MObject>;
2007-11-12 02:05:39 +01:00
2007-10-22 05:15:08 +02:00
/**
* @ internal helper for the ( preliminary )
* position resolve ( ) implementation .
* @ todo we can ' t sensibly reason about tracks ,
* because at the moment ( 10 / 07 ) we lack a track implementation . . .
2007-11-10 21:50:55 +01:00
* @ todo shouldn ' t we use a range - restriction LocatingPin ( subclass )
2009-05-29 07:10:54 +02:00
* to represent the to - be - found solution ? ( ichthyo : see Trac # 100 )
2007-10-22 05:15:08 +02:00
*/
struct LocatingSolution
{
Time minTime ;
Time maxTime ;
2008-01-07 18:16:03 +01:00
Track minTrack ; // TODO don't use Tracks
2007-10-22 05:15:08 +02:00
Track maxTrack ;
bool impo ;
LocatingSolution ( )
2007-11-12 02:05:39 +01:00
: minTime ( Time : : MAX ) , // TODO: better implementation of "unspecified..."
maxTime ( Time : : MIN ) ,
2007-10-22 05:15:08 +02:00
minTrack ( 0 ) , // TODO
maxTrack ( 0 ) ,
impo ( false )
{ }
2007-11-12 02:05:39 +01:00
Time getTime ( ) ;
2008-02-14 04:12:30 +01:00
Pipe getPipe ( ) ;
2007-11-12 02:05:39 +01:00
bool is_definite ( ) ;
bool is_impossible ( ) ;
bool still_to_solve ( ) ;
2007-10-22 05:15:08 +02:00
} ;
2007-10-13 05:13:28 +02:00
} ;
2007-10-22 05:15:08 +02:00
2007-10-13 05:13:28 +02:00
} // namespace mobject::session
} // namespace mobject
# endif