From e04672936a520d57f616c43b0e25a443dae68619 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 12 Jan 2010 01:48:55 +0100 Subject: [PATCH] getting MObjectRef_test partially through the compiler --- src/proc/mobject/mobject-ref.hpp | 8 ++ .../proc/mobject/mobject-ref-test.cpp | 86 +++++++++++-------- .../proc/mobject/placement-ref-test.cpp | 6 +- 3 files changed, 63 insertions(+), 37 deletions(-) diff --git a/src/proc/mobject/mobject-ref.hpp b/src/proc/mobject/mobject-ref.hpp index be0b9385c..0f62d57d6 100644 --- a/src/proc/mobject/mobject-ref.hpp +++ b/src/proc/mobject/mobject-ref.hpp @@ -130,6 +130,14 @@ namespace mobject { } + /* == diagnostics == */ + size_t + use_count() const + { + return pRef_.use_count(); + } + + /* == equality comparisons == */ template diff --git a/tests/components/proc/mobject/mobject-ref-test.cpp b/tests/components/proc/mobject/mobject-ref-test.cpp index 158de4395..9d01a47d5 100644 --- a/tests/components/proc/mobject/mobject-ref-test.cpp +++ b/tests/components/proc/mobject/mobject-ref-test.cpp @@ -37,6 +37,7 @@ #include +using lib::test::showSizeof; using std::string; using std::cout; using std::endl; @@ -48,7 +49,8 @@ namespace test { using lumiera::Time; using session::Clip; - using session::SessionServiceMockIndex; + using session::SessionServiceMockIndex; + using session::PPIdx; @@ -75,40 +77,46 @@ namespace test { { // create data simulating a "Session" - PMObj pClip1 = asset::Media::create("test-1", asset::VIDEO)->createClip(); - PMObj pClip2 = asset::Media::create("test-2", asset::VIDEO)->createClip(); + PMObj testClip1 = asset::Media::create("test-1", asset::VIDEO)->createClip(); + PMObj testClip2 = asset::Media::create("test-2", asset::VIDEO)->createClip(); - // set up a tie to fixed start positions - pClip1.chain(Time(10)); - pClip2.chain(Time(20)); + // set up a tie to fixed start positions (i.e. "properties of placement") + testClip1.chain(Time(10)); + testClip2.chain(Time(20)); - ASSERT (pClip1->isValid()); - ASSERT (pClip2->isValid()); - ASSERT (2 == pClip1.use_count()); // one by the placement and one by the clip-Asset - ASSERT (2 == pClip2.use_count()); + ASSERT (testClip1->isValid()); + ASSERT (testClip2->isValid()); + ASSERT (2 == testClip1.use_count()); // one by the placement and one by the clip-Asset + ASSERT (2 == testClip2.use_count()); -#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! // Prepare an (test)Index PPIdx index = SessionServiceMockIndex::install(); PMO& root = index->getRoot(); - // Add the Clips to "session" - index->insert (pClip1, root); - index->insert (pClip2, root); + // Add the Clips to "session" (here: dummy index) + PMObj::ID clip1ID = index->insert (testClip1, root); + PMObj::ID clip2ID = index->insert (testClip2, root); ASSERT (2 == index->size()); + // use the IDs returned on insertion to fetch + // language references to the placement instance within the index + // we'll use these language refs as base to create MObejctRef handles. + PMObj& pClip1 = index->find(clip1ID); + PMObj& pClip2 = index->find(clip2ID); + // extract various kinds of IDs and refs PMObj & rP1 (pClip1); PMObj const& rP2 (pClip2); PMObj::ID id1 = pClip1.getID(); - PMObj::Id id2 = pClip2.getID(); + PMObj::Id id2 = pClip2.recastID(); // explicit unchecked re-declaration of target type LumieraUid luid = id1.get(); ///////////////////////////////////////////TODO: check the C-API representation here PlacementRef ref1 (id1); PlacementRef ref2 (pClip2); +#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! // -----Tests------------------ checkBuildMObjectRef (rP1, &pClip1); checkBuildMObjectRef (rP2, &pClip2); @@ -122,25 +130,26 @@ namespace test { checkLifecycle (rP1,rP2); checkTypeHandling (luid); // -----Tests------------------ +#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! // verify clean state index->remove (pClip1); - index->remove (pClip2); + index->remove (pClip2); // note: this invalidates pClip1 and pClip2; + ASSERT (!ref1); + ASSERT (!ref2); ASSERT (0 == index->size()); ASSERT (1 == index.use_count()); - ASSERT (2 == pClip1.use_count()); - ASSERT (2 == pClip2.use_count()); + ASSERT (2 == testClip1.use_count()); + ASSERT (2 == testClip2.use_count()); index.reset(); -#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! - } + template void checkBuildMObjectRef (REF refObj, void* placementAdr) { -#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! MORef rMO; ASSERT (!rMO); // still empty (not bound) cout << rMO << endl; @@ -152,17 +161,19 @@ namespace test { cout << rMO << endl; // access MObject (Clip API) - cout << rMO->operator string() << endl; - cout << rMO->getMedia()->ident << endl; +// cout << rMO->operator string() << endl; /////////////////////TICKET #428 + cout << string(rMO->getMedia()->ident) << endl; /////////////////////TICKET #520 ASSERT (rMO->isValid()); // access the Placement-API ASSERT (3 == rMO.use_count()); // now rMO shares ownership with the Placement - ASSERT (0 < rMO.getStartTime()); // (internally, this resolves to an ExplicitPlacement) +#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! + ASSERT (0 < rMO.getStartTime()); // (internally, this resolves to an ExplicitPlacement) /////////TICKET #332 ASSERT ( rMO.isCompatible()); ASSERT ( rMO.isCompatible()); ASSERT (!rMO.isCompatible()); Time start = rMO.getStartTime(); +#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! // re-link to the Placement (note we get the Clip API!) Placement & refP = rMO.getPlacement(); @@ -172,16 +183,14 @@ namespace test { cout << string(refP) << endl; ExplicitPlacement exPla = refP.resolve(); - ASSERT (exPla.time == start); // recovered Placement resolves to the same time as provided by the proxied API +// ASSERT (exPla.time == start); // recovered Placement resolves to the same time as provided by the proxied API ASSERT (4 == refP.use_count()); // but now we've indeed created an additional owner (exPla) ASSERT (4 == rMO.use_count()); -#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! } void checkLifecylce (PMObj const& p1, PMObj const& p2) { -#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! ASSERT (2 == p1.use_count()); ASSERT (2 == p2.use_count()); @@ -189,21 +198,27 @@ namespace test { ASSERT (!rMO); ASSERT (0 == rMO.use_count()); +#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! rMO.activate(p1); +#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! ASSERT (rMO); ASSERT (rMO->getMedia()->getFilename() == "test-1"); ASSERT (3 == rMO.use_count()); ASSERT (3 == p1.use_count()); ASSERT (2 == p2.use_count()); +#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! rMO.activate(p2); +#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! ASSERT (rMO); ASSERT (rMO->getMedia()->getFilename() == "test-2"); ASSERT (3 == rMO.use_count()); ASSERT (2 == p1.use_count()); ASSERT (3 == p2.use_count()); +#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! rMO.activate(p2); +#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! ASSERT (3 == rMO.use_count()); rMO.close(); @@ -212,14 +227,12 @@ namespace test { ASSERT (2 == p2.use_count()); VERIFY_ERROR (INVALID_PLACEMENTREF, rMO.getPlacement() ); - VERIFY_ERROR (INVALID_MOBJECTREF, rMO->getMedia() ); -#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! +// VERIFY_ERROR (INVALID_MOBJECTREF, rMO->getMedia() ); } void checkTypeHandling (LumieraUid luid) { -#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! MObjectRef rMObj; MORef rClip; MORef rSub1; @@ -228,19 +241,25 @@ namespace test { ASSERT (0 == rClip.use_count()); ASSERT (0 == rSub1.use_count()); +#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! rMObj.activate(luid); +#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! ASSERT (3 == rMObj.use_count()); ASSERT (0 == rClip.use_count()); ASSERT (0 == rSub1.use_count()); +#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! rClip.activate(rMObj); // attach on existing MObjectRef +#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! ASSERT (4 == rMObj.use_count()); ASSERT (4 == rClip.use_count()); ASSERT (0 == rSub1.use_count()); // impossible, because Clip isn't a subclass of TestSubMO1: +#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET 384 !!!!!!!!! VERIFY_ERROR (INVALID_PLACEMENTREF, rSub1.activate(luid) ); - VERIFY_ERROR (INVALID_PLACEMENTREF, rSub1 = rMObj ); +// VERIFY_ERROR (INVALID_PLACEMENTREF, rSub1 = rMObj ); +#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! ASSERT (rMObj->isValid()); ASSERT (rClip->isValid()); @@ -254,13 +273,12 @@ namespace test { ASSERT (3 == rMObj.use_count()); ASSERT (0 == rClip.use_count()); - rClip = rMObj; +// rClip = rMObj; ASSERT (4 == rMObj.use_count()); ASSERT (4 == rClip.use_count()); cout << rClip << endl; - cout << rClip->getMedia()->ident << endl; -#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! + cout << string(rClip->getMedia()->ident) << endl; //////////TICKET #520 } }; diff --git a/tests/components/proc/mobject/placement-ref-test.cpp b/tests/components/proc/mobject/placement-ref-test.cpp index 14272322e..70ad62453 100644 --- a/tests/components/proc/mobject/placement-ref-test.cpp +++ b/tests/components/proc/mobject/placement-ref-test.cpp @@ -96,7 +96,7 @@ namespace test { ASSERT (isSameObject (p1, *ref1)); ASSERT (isSameObject (p2, *ref2)); ASSERT (isSameObject (p2, *refX)); - + cout << string(*ref1) << endl; cout << string(*ref2) << endl; cout << string(*refX) << endl; @@ -148,7 +148,7 @@ namespace test { p1 = p2; ASSERT (refX.resolve().time == Time(2)); // now we get the time tie we originally set on p2 ASSERT (3 == ref2.use_count()); // p1, p2 and exPla share ownership - + // actually, the assignment has invalidated ref1, because of the changed ID ASSERT (p1.getID() == p2.getID()); @@ -169,7 +169,7 @@ namespace test { VERIFY_ERROR(INVALID_PLACEMENTREF, *bottom ); VERIFY_ERROR(INVALID_PLACEMENTREF, bottom->specialAPI() ); VERIFY_ERROR(INVALID_PLACEMENTREF, bottom.resolve() ); - + //consistency check; then reset PlacementRef index to default ASSERT (0 == index->size()); ASSERT (1 == index.use_count());