additional quantisation and duration canges covered and passing test
This commit is contained in:
parent
a1427bb0b9
commit
fec2d25b52
2 changed files with 55 additions and 11 deletions
|
|
@ -200,13 +200,27 @@ namespace time {
|
|||
{
|
||||
return is_sameType<T,TimeSpan>::value;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T const&
|
||||
maybeMaterialise (T const& non_grid_aligned_TimeValue)
|
||||
{
|
||||
return non_grid_aligned_TimeValue;
|
||||
}
|
||||
#ifdef LIB_TIME_TIMEQUQNT_H
|
||||
inline QuTime
|
||||
maybeMaterialise (QuTime const& alignedTime)
|
||||
{
|
||||
PQuant const& grid(alignedTime);
|
||||
return QuTime(grid->materialise(alignedTime), grid);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template<class TI, class TAR>
|
||||
struct Builder
|
||||
{
|
||||
|
||||
static TI
|
||||
buildChangedValue (TAR const& target)
|
||||
{
|
||||
|
|
@ -235,7 +249,7 @@ namespace time {
|
|||
struct Builder<TimeSpan, TimeSpan>
|
||||
{
|
||||
static TimeSpan
|
||||
buildChangedValue (TimeSpan& target)
|
||||
buildChangedValue (TimeSpan const& target)
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
|
@ -245,7 +259,7 @@ namespace time {
|
|||
struct Builder<QuTime, TAR>
|
||||
{
|
||||
static QuTime
|
||||
buildChangedValue (TAR& target)
|
||||
buildChangedValue (TAR const& target)
|
||||
{
|
||||
return QuTime (target
|
||||
,getDefaultGridFallback() //////////////////TICKET #810
|
||||
|
|
@ -256,7 +270,7 @@ namespace time {
|
|||
struct Builder<QuTime, QuTime>
|
||||
{
|
||||
static QuTime
|
||||
buildChangedValue (QuTime& target)
|
||||
buildChangedValue (QuTime const& target)
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
|
@ -273,8 +287,8 @@ namespace time {
|
|||
static TI
|
||||
processValueChange (TAR& target, SRC const& change)
|
||||
{
|
||||
imposeChange (target,change);
|
||||
return buildChangedValue(target);
|
||||
imposeChange (target, maybeMaterialise(change));
|
||||
return buildChangedValue (maybeMaterialise(target));
|
||||
}
|
||||
|
||||
static TI
|
||||
|
|
@ -329,6 +343,14 @@ namespace time {
|
|||
|| is_sameType<T,Offset>::value
|
||||
|| is_sameType<T,int>::value;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct canReceiveDuration
|
||||
{
|
||||
static const bool value = is_sameType<T,Duration>::value
|
||||
|| is_sameType<T,TimeSpan>::value;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<class TI, class SRC>
|
||||
|
|
@ -342,6 +364,23 @@ namespace time {
|
|||
}
|
||||
};
|
||||
|
||||
template<class TAR>
|
||||
struct Policy<Duration, typename disable_if< canReceiveDuration<TAR>,
|
||||
Duration>::type, TAR>
|
||||
{
|
||||
static function<Duration(Duration const&)>
|
||||
buildChangeHandler (TAR&)
|
||||
{
|
||||
return bind ( ignore_change_and_return_Zero );
|
||||
}
|
||||
|
||||
static Duration
|
||||
ignore_change_and_return_Zero()
|
||||
{
|
||||
return Duration::NIL;
|
||||
}
|
||||
};
|
||||
|
||||
// template<class TI>
|
||||
// struct Policy<TI,Duration,Duration>
|
||||
// {
|
||||
|
|
|
|||
|
|
@ -200,9 +200,9 @@ namespace test{
|
|||
|
||||
template<class T>
|
||||
inline TimeValue
|
||||
materialise (T const&)
|
||||
materialise (T const& someTime)
|
||||
{
|
||||
NOTREACHED ("only grid aligned values can be materialised");
|
||||
return someTime;
|
||||
}
|
||||
inline TimeValue
|
||||
materialise (QuTime const& alignedTime)
|
||||
|
|
@ -284,6 +284,11 @@ namespace test{
|
|||
CHECK (target == org, "Logic error: Duration was changed by time value");
|
||||
}
|
||||
else
|
||||
if (isDuration<SRC>())
|
||||
{
|
||||
CHECK (target == org, "Logic error: Duration used to change time value");
|
||||
}
|
||||
else
|
||||
if (isQuTime<SRC>())
|
||||
{
|
||||
CHECK (target != org);
|
||||
|
|
@ -346,8 +351,7 @@ namespace test{
|
|||
____verify_nudged (QuTime const& target, QuTime const& refState, int64_t offsetSteps)
|
||||
{
|
||||
CHECK (target != refState || !offsetSteps);
|
||||
PQuant grid(target);
|
||||
CHECK (target == Time (grid->materialise(refState))
|
||||
CHECK (target == Time (materialise(refState))
|
||||
+ Offset(offsetSteps, FrameRate::PAL));
|
||||
}
|
||||
|
||||
|
|
@ -358,7 +362,8 @@ namespace test{
|
|||
{
|
||||
if (isDuration<SRC>())
|
||||
{
|
||||
CHECK (Duration::NIL == follower.receivedValue());
|
||||
CHECK (materialise(target) == follower.receivedValue()
|
||||
|| Duration::NIL == follower.receivedValue() );
|
||||
}
|
||||
else
|
||||
if (isQuTime<TAR>())
|
||||
|
|
|
|||
Loading…
Reference in a new issue