WIP update test code to reflect the new placement properties.

still have to convince the compiler that i am not a terrrorist....
This commit is contained in:
Fischlurch 2007-11-10 23:09:15 +01:00
parent 38236e607d
commit 5c2fa504e7
9 changed files with 46 additions and 20 deletions

View file

@ -38,7 +38,7 @@ using std::tr1::shared_ptr;
#include "proc/assetmanager.hpp"
using proc_interface::IDA; // TODO finally not needed?
using proc_interface::PAsset; //TODO: only temporarily
//using proc_interface::PAsset; //TODO: only temporarily
using proc_interface::AssetManager;
namespace mobject
@ -70,9 +70,8 @@ namespace mobject
static session::MObjectFactory create;
/** MObject self-test (usable for asserting) */
virtual bool isValid() =0;
virtual bool isValid() const =0;
virtual PAsset getMedia () =0; ///< @todo solve the reference/Interface problem concerning Placements, then push down
virtual Time& getLength() =0; ///< @todo how to deal with the time/length field??
};

View file

@ -43,12 +43,8 @@ namespace mobject
/* some dummy implementations used to make the code compile... */
virtual Time& getLength() { return length; }
virtual PAsset getMedia ()
{
UNIMPLEMENTED ("how to relate MObjects and media assets...");
return AssetManager::instance().getAsset(IDA(0)); // KABOOM! (just to make it compile)
}
virtual Time& getLength() { return length; }
protected:
/** custom deleter func allowing class Placement
* to take ownership of MObjct instances

View file

@ -40,6 +40,16 @@ namespace mobject
/** implementing the common MObject self test.
* Length definition is consitent, underlying
* media def is accessible etc. */
bool
Clip::isValid () const
{
UNIMPLEMENTED ("check consistency of clip length def, implies accessing the underlying media def");
}
void
Clip::setupLength()
{

View file

@ -33,6 +33,7 @@ namespace mobject
{
namespace session
{
using asset::Media;
/**
@ -63,6 +64,16 @@ namespace mobject
virtual void setupLength();
public:
virtual bool isValid() const;
/** access the underlying media asset */
virtual Media::PMedia getMedia ()
{
UNIMPLEMENTED ("how to relate MObjects and media assets...");
return AssetManager::instance().getAsset(IDA(0)); // KABOOM! (just to make it compile)
}
};

View file

@ -101,6 +101,14 @@ namespace mobject
return FixedLocation (solution.getTime(), solution.getTrack());
}
bool
LocatingPin::isOverdetermined () const
{
LocatingSolution solution;
resolve (solution);
return solution.is_impossible();
}
inline bool
still_to_solve (LocatingPin::LocatingSolution& solution)

View file

@ -51,7 +51,7 @@ using boost::scoped_ptr;
namespace mobject
{
class Placement;
template<class MO> class Placement;
namespace session
{
@ -89,10 +89,11 @@ namespace mobject
public:
const FixedLocation resolve () const;
bool isOverdetermined () const;
/* Factory functions for adding LocatingPins */
FixedLocation& operator() (Time, Track);
FixedLocation& operator() (Time, Track=0);
RelativeLocation& operator() (PMO refObj, Time offset=0);
LocatingPin (const LocatingPin&);

View file

@ -40,12 +40,14 @@ namespace mobject
* into a Placement, which takes ownership. So, when the
* render engine gets across this Clip-MO, it is able to
* obtain the media information contained in the corresponding
* asset.
* media asset. Depending on the mediaDef passed in, the
* created Clip could be a compound (multichannel) clip
* comprised of several SimpleClip subobjects.
* @todo implement creation of multichannel CompoundClip
*/
Placement<Clip>
MObjectFactory::operator() (PClipAsset& mediaDef)
{
//TODO sholdin't we rather store a ref to the underlying media assset??
return Placement<Clip> (new Clip (mediaDef));
}

View file

@ -52,14 +52,14 @@ namespace asset
class MakeClip_test : public Test
{
typedef shared_ptr<asset::Media> PM;
typedef shared_ptr<mobject::session::Clip> PC;
typedef asset::Media::PClipMO PC;
virtual void run (Arg arg)
{
PM mm = asset::Media::create("test-1", VIDEO);
PC cc = mm->createClip();
PM cm = static_pointer_cast<Media,Asset> (cc->getMedia()); //TODO: solve the reference/interface Problem on MObject, push down to Clip...
PM cm = cc->getMedia();
ASSERT (cm);
ASSERT (0 < cc->getLength());

View file

@ -66,24 +66,23 @@ namespace mobject
PM media = asset::Media::create("test-1", VIDEO);
Placement<Clip> pc = MObject::create(media);
// can use the Clip-MObject interface by dereferencing the placement
// use of the Clip-MObject interface by dereferencing the placement
PM clip_media = pc->getMedia();
ASSERT (clip_media->ident.category.hasKind (VIDEO));
// using the Placement interface
// TODO: how to handle unterdetermined Placement? Throw?
FixedPlacement & fixpla = pc.chain(Placement::FIXED, Time(1)); // TODO: the track??
FixedLocation & fixloc = pc.chain(Placement::FIXED, Time(1)); // TODO: the track??
ExplicitPlacement expla = pc.resolve();
ASSERT (expla.time == 1);
ASSERT (!expla.isOverdetermined());
ASSERT (!expla.chain.isOverdetermined());
ASSERT (*expla == *pc);
ASSERT (*fixpla == *pc);
// now overconstraining with another Placement
pc.chain(Placement::FIXED, Time(2));
expla = pc.resolve();
ASSERT (expla.time == 2); // the latest addition wins
ASSERT (expla.isOverdetermined());
ASSERT (expla.chain.isOverdetermined());
}
};