diff --git a/src/proc/mobject/mobject-ref.hpp b/src/proc/mobject/mobject-ref.hpp index d858b7cb1..8bbab4c7a 100644 --- a/src/proc/mobject/mobject-ref.hpp +++ b/src/proc/mobject/mobject-ref.hpp @@ -46,6 +46,7 @@ //#include +///////////////////////////////////////////TODO: define an C-API representation here, make the header multilingual! namespace mobject { diff --git a/tests/components/proc/mobject/mobject-ref-test.cpp b/tests/components/proc/mobject/mobject-ref-test.cpp index 2a291c402..02156aafc 100644 --- a/tests/components/proc/mobject/mobject-ref-test.cpp +++ b/tests/components/proc/mobject/mobject-ref-test.cpp @@ -23,23 +23,26 @@ #include "lib/test/run.hpp" #include "lib/lumitime.hpp" +#include "proc/asset/media.hpp" #include "proc/mobject/mobject.hpp" #include "proc/mobject/mobject-ref.hpp" #include "proc/mobject/placement.hpp" #include "proc/mobject/placement-ref.hpp" +#include "proc/mobject/session/clip.hpp" #include "proc/mobject/explicitplacement.hpp" #include "proc/mobject/test-dummy-mobject.hpp" #include -using lumiera::Time; using std::string; using std::cout; +using std::endl; namespace mobject { namespace test { + using lumiera::Time; using session::Clip; @@ -90,8 +93,26 @@ namespace test { index->insert (pClip2, root); ASSERT (2 == index->size()); + // extract various kinds of IDs and refs + PMObj & rP1 (pClip1); + PMObj const& rP2 (pClip2); + PMObj::ID id1 = pClip1.getID(); + PMObj::Id id2 = pClip2.getID(); + LumieraUid luid = id1.get(); + ///////////////////////////////////////////TODO: check the C-API representation here + PlacementRef ref1 (id1); + PlacementRef ref2 (pClip2); + // -----Tests------------------ + checkBuildMObjectRef (rP1, &pClip1); + checkBuildMObjectRef (rP2, &pClip2); + checkBuildMObjectRef (id1, &pClip1); + checkBuildMObjectRef (id2, &pClip2); + checkBuildMObjectRef (luid, &pClip1); + ///////////////////////////////////////////TODO: check the C-API representation here + checkBuildMObjectRef (ref1, &pClip1); + checkBuildMObjectRef (ref2, &pClip2); // -----Tests------------------ // verify clean state @@ -102,6 +123,47 @@ namespace test { ASSERT (2 == pClip2.use_count()); reset_PlacementIndex(); } + + + template + void + checkBuildMObjectRef (REF refObj, void* placementAdr) + { + MORef rMO; + ASSERT (!rMO); // still empty (not bound) + cout << rMO << endl; + cout << showSizeof(rMO) << endl; + + // activate by binding to provided ref + rMO.activate(refObj); + ASSERT (rMO); // now bound + cout << rMO << endl; + + // access MObject (Clip API) + cout << rMO->operator string() << endl; + cout << rMO->getMedia()->ident << endl; + ASSERT (rMO->isValid()); + + // access the Placement-API + ASSERT (2 == rMO.use_count()); // we are referring, not creating a new Placement + ASSERT (0 < rMO.getStartTime()); // (internally, this resolves to an ExplicitPlacement) + ASSERT ( rMO.isCompatible()); + ASSERT ( rMO.isCompatible()); + ASSERT (!rMO.isCompatible()); + Time start = rMO.getStartTime(); + + // re-link to the Placement (note we get the Clip API!) + Placement & refP = rMO.getPlacement(); + ASSERT (refP); + ASSERT (2 == refP.use_count()); + ASSERT (&refP == placementAdr); // actually denotes the address of the original Placement in the "session" + 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 (3 == refP.use_count()); // but now we've indeed created an additional owner (exPla) + ASSERT (3 == rMO.use_count()); + } };