diff --git a/src/lib/time/control.hpp b/src/lib/time/control.hpp index 48af1813c..60809e53d 100644 --- a/src/lib/time/control.hpp +++ b/src/lib/time/control.hpp @@ -200,13 +200,27 @@ namespace time { { return is_sameType::value; } + + template + 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 struct Builder { - static TI buildChangedValue (TAR const& target) { @@ -235,7 +249,7 @@ namespace time { struct Builder { static TimeSpan - buildChangedValue (TimeSpan& target) + buildChangedValue (TimeSpan const& target) { return target; } @@ -245,7 +259,7 @@ namespace time { struct Builder { static QuTime - buildChangedValue (TAR& target) + buildChangedValue (TAR const& target) { return QuTime (target ,getDefaultGridFallback() //////////////////TICKET #810 @@ -256,7 +270,7 @@ namespace time { struct Builder { 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::value || is_sameType::value; }; + + template + struct canReceiveDuration + { + static const bool value = is_sameType::value + || is_sameType::value; + }; + } template @@ -342,6 +364,23 @@ namespace time { } }; + template + struct Policy, + Duration>::type, TAR> + { + static function + buildChangeHandler (TAR&) + { + return bind ( ignore_change_and_return_Zero ); + } + + static Duration + ignore_change_and_return_Zero() + { + return Duration::NIL; + } + }; + // template // struct Policy // { diff --git a/tests/lib/time/time-control-test.cpp b/tests/lib/time/time-control-test.cpp index a57c758f2..ab12a2591 100644 --- a/tests/lib/time/time-control-test.cpp +++ b/tests/lib/time/time-control-test.cpp @@ -200,9 +200,9 @@ namespace test{ template 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()) + { + CHECK (target == org, "Logic error: Duration used to change time value"); + } + else if (isQuTime()) { 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()) { - CHECK (Duration::NIL == follower.receivedValue()); + CHECK (materialise(target) == follower.receivedValue() + || Duration::NIL == follower.receivedValue() ); } else if (isQuTime())