From 484c771d2a060921664bfc1f0dc61807937c4dff Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 16 Jan 2011 23:58:42 +0100 Subject: [PATCH] establish hidden advice link to the session --- src/lib/time/quantiser.cpp | 30 ++++++++++++++++++++--- src/lib/time/quantiser.hpp | 14 +++++------ src/lib/time/timequant.hpp | 14 +++++++++-- tests/lib/time/time-quantisation-test.cpp | 7 +++--- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/lib/time/quantiser.cpp b/src/lib/time/quantiser.cpp index 22a469505..9c4eca790 100644 --- a/src/lib/time/quantiser.cpp +++ b/src/lib/time/quantiser.cpp @@ -25,6 +25,7 @@ #include "lib/time/timevalue.hpp" #include "lib/time/timequant.hpp" #include "lib/time.h" +#include "lib/advice.hpp" #include @@ -40,7 +41,16 @@ namespace time { namespace { // implementation helpers... - ///////////TODO superfluous?? + PQuant + retrieveQuantiser (Symbol gridID) + { + advice::Request query(gridID); + PQuant grid_found = query.getAdvice(); + if (!grid_found) + throw error::Logic ("unable to fetch the quantisation grid -- is it already defined?" + , LUMIERA_ERROR_UNKNOWN_GRID); + return grid_found; + } }//(End) implementation helpers @@ -49,13 +59,25 @@ namespace time { Grid::~Grid() { } // hint to emit the VTable here... - /** */ + /** + * build a quantised time value, referring the time grid by-name. + * This is the preferred standard way of establishing a quantisation, + * but it requires an existing time scale defined in the Lumiera Session, + * as TimeGrid (meta asset). Usually, such a time scale gets built based + * on the format and parameters of an output bus. + */ QuTime::QuTime (TimeValue raw, Symbol gridID) - : Time(raw) /////////////////////////////////////////////////TODO fetch quantiser + : Time(raw) + , quantiser_(retrieveQuantiser (gridID)) { } - /** */ + /** + * build a quantised time value by explicitly specifying a + * grid alignment facility and without any hidden reference + * to the Lumiera session. This is mainly intended for + * debugging and unit testing. + */ QuTime::QuTime (TimeValue raw, PQuant quantisation_to_use) : Time(raw) , quantiser_(quantisation_to_use) diff --git a/src/lib/time/quantiser.hpp b/src/lib/time/quantiser.hpp index c45489032..6aaff8e69 100644 --- a/src/lib/time/quantiser.hpp +++ b/src/lib/time/quantiser.hpp @@ -106,13 +106,13 @@ namespace time { /** - * Simple stand-alone Quantiser implementation for debugging and test. - * This is a self-contained quantiser implementation without any implicit - * referral to the Lumiera session. It is mainly intended for simplified unit testing. - * @warning real GUI and Proc-Layer code should always prefer to build a real quantiser, - * which referres some TimeGrid definition within the session. Basically, the overall - * purpose of the time-quantisation framework is to enforce such a link to a specific - * time and quantisation scale and to prevent "wild and uncoordinated" rounding attempts. + * Simple stand-alone Quantiser implementation based on a constant sized gird. + * This is a self-contained quantiser implementation without any implicit referral + * to the Lumiera session. As such it is suited for simplified unit testing. + * @warning real GUI and Proc-Layer code should always fetch a quantiser from the + * Session, referring to a pre defined TimeGrid. Basically, the overall purpose of + * the time-quantisation framework is to enforce such a link to a distinct time scale + * and quantisation, so to prevent "wild and uncoordinated" rounding attempts. */ class FixedFrameQuantiser : public Quantiser diff --git a/src/lib/time/timequant.hpp b/src/lib/time/timequant.hpp index 3b25592c3..0580d2e6f 100644 --- a/src/lib/time/timequant.hpp +++ b/src/lib/time/timequant.hpp @@ -40,9 +40,19 @@ namespace time { /** - * fixed format time specification. + * grid aligned time specification, referring to a specific scale. + * A quantised time value allows to access the time specification + * as numeric value in one of the supported timecode formats, and + * relative to the defined time scale. Usually this time scale + * exists already in the Lumiera session and is referred simply + * by symbolic ID, it will be fetched on demand through the + * \link advice.hpp advice system.\endlink * - * @todo WIP-WIP-WIP + * By creating a QuTime value, the relation to such a predefined + * time scale is made explicit. This doesn't change the internal + * time value, but the actual creation of a timecode formatted + * value (#formatAs) usually implies to quantise or grid align + * the time to the frame grid specific to this time scale. */ class QuTime : public Time diff --git a/tests/lib/time/time-quantisation-test.cpp b/tests/lib/time/time-quantisation-test.cpp index 3fae0c0f9..c2f0bfbf5 100644 --- a/tests/lib/time/time-quantisation-test.cpp +++ b/tests/lib/time/time-quantisation-test.cpp @@ -140,13 +140,12 @@ namespace test{ void checkGridLateBinding (TimeValue org) { - QuTime funny (org, "special_funny_grid"); // refer a not yet existing grid - CHECK (org == funny); // no problem, unless we request quantisation - - VERIFY_ERROR (UNKNOWN_GRID, funny.formatAs() ); + // refer to a grid not yet defined + VERIFY_ERROR (UNKNOWN_GRID, QuTime wired(org, "special_funny_grid")); TimeGrid::build("special_funny_grid", 1); // provide the grid's definition (1 frame per second) + QuTime funny (org, "special_funny_grid"); // now OK, grid is known int cnt = funny.formatAs(); // and now performing quantisation is OK SmpteTC smpte (funny); // also converting into SMPTE (which implies frame quantisation)