better avoid throwing and use a default time grid in some cases
This commit is contained in:
parent
47afbbeab0
commit
a8fd0bf7c5
4 changed files with 35 additions and 15 deletions
|
|
@ -162,7 +162,7 @@ namespace time {
|
|||
TI
|
||||
Mutator<TI>::imposeNudge (TimeValue& target, int off_by_steps)
|
||||
{
|
||||
return TI (Mutation::imposeChange (target, TimeVar(target)+Time(FSecs(off_by_steps))));
|
||||
return TI (Mutation::imposeChange (target, TimeVar(target)+Time(FSecs(off_by_steps)))); //////////////////TICKET #810
|
||||
}
|
||||
|
||||
// special cases...
|
||||
|
|
@ -226,19 +226,19 @@ namespace time {
|
|||
}
|
||||
template<>
|
||||
QuTime
|
||||
Mutator<QuTime>::imposeOffset (TimeValue&, Offset const&)
|
||||
Mutator<QuTime>::imposeOffset (TimeValue& target, Offset const& off)
|
||||
{
|
||||
throw error::Logic ("can't deliver result of the change as grid-aligned time, "
|
||||
"because it's not evident which concrete grid to use"
|
||||
,LUMIERA_ERROR_UNKNOWN_GRID); //////////////////TODO: we could pick up a "default grid" from session?
|
||||
return QuTime (Mutation::imposeChange (target, TimeVar(target)+off)
|
||||
,getDefaultGridFallback() //////////////////TICKET #810
|
||||
);
|
||||
}
|
||||
template<>
|
||||
QuTime
|
||||
Mutator<QuTime>::imposeNudge (TimeValue&, int)
|
||||
Mutator<QuTime>::imposeNudge (TimeValue& target, int off_by_steps)
|
||||
{
|
||||
throw error::Logic ("can't deliver result of the change as grid-aligned time, "
|
||||
"because it's not evident which concrete grid to use"
|
||||
,LUMIERA_ERROR_UNKNOWN_GRID);
|
||||
return QuTime (Mutation::imposeChange (target, TimeVar(target)+Time(FSecs(off_by_steps)))
|
||||
,getDefaultGridFallback() //////////////////TICKET #810
|
||||
);
|
||||
}
|
||||
#endif //(End)quantisation special case
|
||||
|
||||
|
|
|
|||
|
|
@ -51,10 +51,19 @@ namespace time {
|
|||
, LUMIERA_ERROR_UNKNOWN_GRID);
|
||||
return grid_found;
|
||||
}
|
||||
|
||||
}//(End) implementation helpers
|
||||
|
||||
|
||||
PQuant
|
||||
getDefaultGridFallback()
|
||||
{
|
||||
static PQuant globalDefaultGrid (new FixedFrameQuantiser(1));
|
||||
return globalDefaultGrid; ///////////////////////TICKET #810
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Grid::~Grid() { } // hint to emit the VTable here...
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,17 @@ namespace time {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/** @todo placeholder for accessing
|
||||
* a current or default session grid.
|
||||
* To be implemented later.
|
||||
*/
|
||||
PQuant getDefaultGridFallback(); ///////////////////////TICKET #810
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Facility to create grid-aligned time values.
|
||||
* Effectively, a quantiser exposes the value Grid API, but
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ namespace test{
|
|||
: BASE
|
||||
{
|
||||
void
|
||||
performTestCases(TimeValue const& o, TimeValue const& c)
|
||||
performTestCases(TimeValue const& org, TimeValue const& c)
|
||||
{
|
||||
cout << "Test-Case. Target=" << showType<TAR>()
|
||||
<<" <--feed--- " << showType<SRC>()
|
||||
|
|
@ -305,16 +305,16 @@ namespace test{
|
|||
|
||||
Control<SRC> controller;
|
||||
|
||||
TAR target = TestTarget<TAR>::build(o);
|
||||
TAR target = TestTarget<TAR>::build(org);
|
||||
target.accept (controller);
|
||||
|
||||
SRC change = TestChange<SRC>::prepareChangeValue(c);
|
||||
controller (change);
|
||||
verify_wasChanged (target, o, change);
|
||||
verify_wasChanged (target, org, change);
|
||||
|
||||
Offset offset(c);
|
||||
controller (offset);
|
||||
verify_wasOffset (target, o, offset);
|
||||
verify_wasOffset (target, org, offset);
|
||||
|
||||
TAR oldState(target);
|
||||
controller (0);
|
||||
|
|
@ -337,7 +337,7 @@ namespace test{
|
|||
|
||||
|
||||
// tail recursion: further test combinations....
|
||||
BASE::performTestCases(o,c);
|
||||
BASE::performTestCases(org,c);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue