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
This commit is contained in:
Fischlurch 2012-12-02 01:17:02 +01:00
parent 5dfe5e099f
commit 3852c8f8e8
3 changed files with 32 additions and 11 deletions

View file

@ -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

View file

@ -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<NudgeMutation> (adjustment, gridID);
return EncapsulatedMutation::build<NudgeMutation> (adjustment, grid);
}

View file

@ -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&);