From 3852c8f8e832d5a9e2fc752e26bc0842cadcbd64 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 2 Dec 2012 01:17:02 +0100 Subject: [PATCH] provide a time mutation for nudging based on symbolic grid reference time handling is part of the library, while this convenience shortcut relies on the Advice system, which resides in the application lib. To allow this kind of symbolic acces to a grid entity defined "elesewhere", client code needs to be linked against liblumieracore.so --- src/common/integration/common-services.cpp | 15 ++++++++++++++ src/lib/time/mutation.cpp | 23 ++++++++++++---------- src/lib/time/mutation.hpp | 5 ++++- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/common/integration/common-services.cpp b/src/common/integration/common-services.cpp index 50c8d7373..1e147ea92 100644 --- a/src/common/integration/common-services.cpp +++ b/src/common/integration/common-services.cpp @@ -56,6 +56,7 @@ namespace error = lumiera::error; #include "lib/time/timequant.hpp" #include "lib/time/quantiser.hpp" +#include "lib/time/mutation.hpp" #include "common/advice.hpp" @@ -107,4 +108,18 @@ namespace time { } + /** build a time mutation to \em nudge the target time value in steps based on a pre-defined grid. + * @param adjustment number of grid steps to apply as offset + * @param gridID symbolic reference to a grid, which needs to be defined "somewhere" + * within the system, typically within the session. + * @see #nudge(int,PQuant) variant of this function using a direct grid reference + */ + EncapsulatedMutation + Mutation::nudge (int adjustment, Symbol gridID) + { + return nudge (adjustment, Quantiser::retrieve(gridID)); + } + + + }} // namespace lib::time diff --git a/src/lib/time/mutation.cpp b/src/lib/time/mutation.cpp index 182d5a7bd..da018fb0c 100644 --- a/src/lib/time/mutation.cpp +++ b/src/lib/time/mutation.cpp @@ -202,16 +202,15 @@ namespace time { { static Offset - materialiseGridPoint (Symbol gridID, int steps) + materialiseGridPoint (PQuant const& grid, int steps) { - REQUIRE (!isnil (gridID)); - PQuant grid;//////////TODO = Quantiser::retrieve(gridID); + REQUIRE (grid); return Offset(grid->timeOf(0), grid->timeOf(steps)); } public: - NudgeMutation (int relativeSteps, Symbol gridID) - : ImposeOffsetMutation(materialiseGridPoint (gridID,relativeSteps)) + NudgeMutation (int relativeSteps, PQuant const& grid) + : ImposeOffsetMutation(materialiseGridPoint (grid,relativeSteps)) { } }; @@ -343,14 +342,18 @@ namespace time { * resulting in the net result of two quantisation operations * being applied in sequence. * @param adjustment number of grid steps to apply as offset - * @param gridID symbolic name used to register or define a - * suitable nudge grid, typically somewhere globally - * in the session (as meta asset) + * @param grid reference to a concrete grid instance + * @note there is a variant of this function, using just a + * symbolic name to refer to the grid, allowing to nudge + * based on a grid known to exist somewhere in the session. + * Using this approach involves the Advice system and thus + * requires linking against \c liblumieracommon.so + * @see #nudge(int,Symbol) */ EncapsulatedMutation - Mutation::nudge (int adjustment, Symbol gridID) + Mutation::nudge (int adjustment, PQuant const& grid) { - return EncapsulatedMutation::build (adjustment, gridID); + return EncapsulatedMutation::build (adjustment, grid); } diff --git a/src/lib/time/mutation.hpp b/src/lib/time/mutation.hpp index f6e2f3f5f..4fd277bff 100644 --- a/src/lib/time/mutation.hpp +++ b/src/lib/time/mutation.hpp @@ -109,7 +109,10 @@ namespace time { static EncapsulatedMutation adjust (Offset); static EncapsulatedMutation materialise (QuTime const&); static EncapsulatedMutation nudge (int adjustment); - static EncapsulatedMutation nudge (int adjustment, Symbol gridID); + static EncapsulatedMutation nudge (int adjustment, Symbol gridID); ///<@note defined in common-services.cpp +#ifdef LIB_TIME_TIMEQUQNT_H + static EncapsulatedMutation nudge (int adjustment, PQuant const& grid); +#endif protected: static TimeValue& imposeChange (TimeValue&, TimeValue const&);