time-entities refactoring: Duration isn't an Offset

removed that inheritance relation; it was a typical
example of abusing inheritance and violated the
Liscov substitution principle. It is sufficient
to allow promotion of an offset into a Duration.
Note: Duration is the time metric
This commit is contained in:
Fischlurch 2011-06-08 02:12:38 +02:00
parent 7c5f18643b
commit 9bd96a1b19
10 changed files with 88 additions and 57 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -178,7 +178,7 @@ namespace time {
static TimeSpan
buildChangedValue (TAR& target)
{
return TimeSpan (target, Duration::ZERO); /////////////TODO how to feed the "new value" duration????
return TimeSpan (target, Duration::NIL); /////////////TODO how to feed the "new value" duration????
}
};
template<>
@ -327,13 +327,13 @@ namespace time {
TimeSpan
Mutator<TimeSpan>::imposeOffset (TimeValue& target, Offset const& off)
{
return TimeSpan (Mutation::imposeChange (target, TimeVar(target)+off), Duration::ZERO);
return TimeSpan (Mutation::imposeChange (target, TimeVar(target)+off), Duration::NIL);
}
template<>
TimeSpan
Mutator<TimeSpan>::imposeNudge (TimeValue& target, int off_by_steps)
{
return TimeSpan (Mutation::imposeChange (target, TimeVar(target)+Time(FSecs(off_by_steps))), Duration::ZERO);
return TimeSpan (Mutation::imposeChange (target, TimeVar(target)+Time(FSecs(off_by_steps))), Duration::NIL);
}

View file

@ -121,12 +121,12 @@ namespace time {
/** duration of the given number of frames */
Duration::Duration (ulong count, FrameRate const& fps)
: Offset(TimeValue (count? lumiera_frame_duration (fps/count) : _raw(Duration::NIL)))
: TimeValue (count? lumiera_frame_duration (fps/count) : _raw(Duration::NIL))
{ }
/** constant to indicate "no duration" */
const Duration Duration::NIL = Offset(TimeValue(0));
const Duration Duration::NIL (Time::ZERO);

View file

@ -200,7 +200,7 @@ namespace time {
{
Time gt(gridTime);
TimeVar timePoint = gt + origin_;
timePoint += gridOffset * raster_;
timePoint += gridOffset * Offset(raster_);
return timePoint;
}

View file

@ -317,24 +317,24 @@ namespace time {
* possibility to send a \em Mutation message.
*/
class Duration
: public Offset
: public TimeValue
{
/// direct assignment prohibited
Duration& operator= (Duration const&);
public:
Duration (Offset const& distance)
: Offset(distance.abs())
: TimeValue(distance.abs())
{ }
explicit
Duration (TimeValue const& timeSpec)
: Offset(Offset(timeSpec).abs())
: TimeValue(Offset(timeSpec).abs())
{ }
explicit
Duration (FSecs const& timeSpan_in_secs)
: Offset(Offset(Time(timeSpan_in_secs)).abs())
: TimeValue(Offset(Time(timeSpan_in_secs)).abs())
{ }
Duration (TimeSpan const& interval);
@ -343,8 +343,38 @@ namespace time {
static const Duration NIL;
void accept (Mutation const&);
/// Supporting backwards use as offset
Offset operator- () const;
};
//-- support using a Duration to build offsets ---------------
inline Duration
operator+ (Duration const& base, Duration const& toAdd)
{
return Offset(base) + Offset(toAdd);
}
inline Offset
operator* (int factor, Duration const& dur)
{
return factor * Offset(dur);
}
inline Offset
operator* (Duration const& dur, int factor)
{
return factor*dur;
}
inline Offset
Duration::operator- () const
{
return -1 * (*this);
}
/**
@ -495,7 +525,7 @@ namespace time {
inline
Duration::Duration (TimeSpan const& interval)
: Offset(interval.duration())
: TimeValue(interval.duration())
{ }
inline

View file

@ -1,6 +1,6 @@
format 58
"CommonLib" // CommonLib
revision 24
revision 25
modified_by 5 "hiv"
// class settings
//class diagram settings
@ -916,12 +916,12 @@ ${inlines}
idl_decl ""
explicit_switch_type ""
classrelation 210437 // <generalisation>
relation 199557 ---|>
classrelation 215429 // <generalisation>
relation 204293 ---|>
a public
cpp default "${type}"
classrelation_ref 210437 // <generalisation>
b parent class_ref 172165 // Offset
classrelation_ref 215429 // <generalisation>
b parent class_ref 168709 // TimeValue
end
end
@ -1074,14 +1074,6 @@ ${inlines}
b parent class_ref 168709 // TimeValue
end
classrelation 208389 // val (<unidirectional association>)
relation 197509 --->
a role_name "val" multiplicity "1" protected
cpp default " ${comment}${static}${mutable}${volatile}${const}${type}* ${name}${value};
"
classrelation_ref 208389 // val (<unidirectional association>)
b multiplicity "*" parent class_ref 134917 // Time
end
end
class 170501 "QuTimeSpan"
@ -1126,7 +1118,6 @@ ${inlines}
classrelation_ref 208645 // <dependency>
b parent class_ref 170629 // TCode
end
end
class 170757 "Format"

View file

@ -30,11 +30,7 @@ classcanvas 130565 class_ref 169221 // TimeGrid
end
classcanvas 130949 class_ref 170373 // TimeVar
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 114 118 2000
end
classcanvas 131589 class_ref 170501 // QuTimeSpan
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 103 361 2000
xyz 170 118 2000
end
classcanvas 131973 class_ref 170629 // TCode
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
@ -54,7 +50,7 @@ classcanvas 133253 class_ref 171013 // CompoundGrid
end
classcanvas 133509 class_ref 172165 // Offset
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 46 118 2000
xyz 102 118 2000
end
classcanvas 135045 class_ref 137093 // Meta
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
@ -82,6 +78,14 @@ classcanvas 137349 class_ref 173829 // Digxel
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 191 548 2000
end
classcanvas 138117 class_ref 170501 // QuTimeSpan
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_members_multiplicity default show_members_initialization default member_max_width 0 show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default show_stereotype_properties default
xyz 104 361 2000
end
textcanvas 138373 "time metric"
xyzwh 97 182 2000 50 13
textcanvas 138501 "mutable"
xyzwh 178 157 2000 38 13
relationcanvas 128517 relation_ref 195205 // <generalisation>
geometry VHV unfixed
from ref 128005 z 1999 to point 269 88
@ -108,22 +112,12 @@ relationcanvas 130821 relation_ref 197253 // <generalisation>
end
relationcanvas 131077 relation_ref 197381 // <generalisation>
geometry VHV
from ref 130949 z 1999 to point 138 88
from ref 130949 z 1999 to point 194 88
line 131205 z 1999 to point 66 88
line 131333 z 1999 to ref 128261
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 131461 relation_ref 197509 // <unidirectional association>
from ref 130949 z 1999 to ref 128005
role_a_pos 225 120 3000 no_role_b
multiplicity_a_pos 232 143 3000 multiplicity_b_pos 176 143 3000
end
relationcanvas 131717 relation_ref 197637 // <generalisation>
from ref 131589 z 1999 to ref 128133
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 132741 relation_ref 198149 // <directional aggregation>
decenter_end 595
from ref 130181 z 1999 stereotype "<<provide>>" xyz 360 413 3000 to ref 132101
@ -141,13 +135,11 @@ relationcanvas 133381 relation_ref 198405 // <generalisation>
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 133637 relation_ref 199557 // <generalisation>
from ref 128389 z 1999 to ref 133509
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 133765 relation_ref 199685 // <generalisation>
from ref 133509 z 1999 to ref 128261
geometry VHV
from ref 133509 z 1999 to point 122 88
line 137861 z 1999 to point 66 88
line 137989 z 1999 to ref 128261
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
@ -162,7 +154,7 @@ relationcanvas 134661 relation_ref 199941 // <unidirectional association>
geometry VHr
from ref 128133 z 1999 to point 66 284
line 134789 z 1999 to ref 128389
role_a_pos 75 269 3000 no_role_b
role_a_pos 83 270 3000 no_role_b
multiplicity_a_pos 52 226 3000 no_multiplicity_b
end
relationcanvas 135301 relation_ref 200069 // <generalisation>
@ -212,4 +204,14 @@ relationcanvas 137477 relation_ref 201989 // <directional composition>
role_a_pos 245 554 3000 no_role_b
multiplicity_a_pos 245 573 3000 no_multiplicity_b
end
relationcanvas 137733 relation_ref 204293 // <generalisation>
from ref 128389 z 1999 to ref 128261
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
relationcanvas 138245 relation_ref 197637 // <generalisation>
from ref 138117 z 1999 to ref 128133
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
end
end

View file

@ -42,7 +42,10 @@ open
package_ref 128389 // RenderEngine
classdiagram_ref 142725 // Time flavours
class_ref 134917 // Time
class_ref 168837 // Duration
class_ref 169221 // TimeGrid
class_ref 170373 // TimeVar
class_ref 170501 // QuTimeSpan
classview_ref 128645 // Service Components
classview_ref 128266 // SmartPointers
end

View file

@ -1,6 +1,6 @@
format 58
"lumiera"
revision 68
revision 69
modified_by 5 "hiv"
cpp_root_dir "../../src/"

View file

@ -6870,23 +6870,28 @@ Thus the possibly mutalble time entities get an {{{accept(time::Mutation&amp;)}}
Based on this time::Mutation design, we provide a specialised element for dealing with //running time values:// When attached to a target time entity, a &quot;life&quot; connection is established. From then on, continuous changes and mutations can be fed to the target by invoking a functor interface. Besides, a change notification signal (callback) can be installed, which will be invoked on each change. This {{{time::Control}}} element is the foundation for implementing all kinds of running time display widgets, spin buttons, timeline selections, playheads, loop playback and similar.
</pre>
</div>
<div title="TimeQuant" modifier="Ichthyostega" modified="201101232031" created="201012181753" tags="Concepts Player spec img discuss draft" changecount="50">
<div title="TimeQuant" modifier="Ichthyostega" modified="201106080000" created="201012181753" tags="Concepts Player spec img discuss draft" changecount="52">
<pre>The term &amp;raquo;Time&amp;laquo; spans a variety of vastly different entities. Within a NLE we get to deal with various //flavours of time values.//
;continuous time
:without any additional assumptions, ''points in time'' can be specified with arbitrary precision.
:the time values are just numbers; the point of reference and the meaning is implicit.
:within Lumiera, time is encoded as integral number of //micro ticks,// practically continuous
;duration
;time distance
:a range of time, a ''distance'' on the time axis, measured with the same arbitrary precision as time points.
:distances and durations can be determined by //subtracting// two time points, consequently they are //signed numbers.//
:a duration always abstracts from the time //when// this duration or distance happens, the relation to any time scale remains implicit
:distances can be determined by //subtracting// two time points, consequently they are //signed numbers.//
;offset
:offsetting a time or a duration is an operation (not an entity): it means changing the denoted time point or duration.
:the //target// of an offset operation is a time or duration, while it's //argument// is a distance (synonymous to duration).
:Time values are //immutable,// like numbers. Only a ''time variable'' can be changed. Durations to the contrary can be mutable or const.
:a distance can be used to adjust (offset) a time or a duration: this means applying a relative change.
:the //target// of an offset operation is a time or duration, while it's //argument// is a distance (synonymous to offset).
;duration
:the length of a time range yields a ''time metric''.
:the duration can be defined as the //absolute value//&amp;nbsp; of the offset between start and endpoint of the time range.
:a duration always abstracts from the time //when// this duration or distance happens, the relation to any time scale remains implicit
;time span
:contrary to a mere duration, a ''time interval'' or time span is actually //anchored// at a specific point in time.
:it can be seen as a //special kind of duration,// which explicitly states the information //when// this time span takes place.
;changing time
:Time values are //immutable,// like numbers. Only a ''time variable'' can be changed.
:yet some of the special time entities can recieve [[mutation messages|TimeMutation]], allowing e.g. for adjustments to a time interval selection from the GUI
;internal time
:While the basic continuous time values don't imply any provision regarding the time scale and origin to be used, actually, within the implementation of the application, the meaning of time values is uniform and free of contradictions. Thus effectively there is an ''implementation time scale'' -- but its scope of validity is //strictly limited to the implementation level of a single application instance.// It is never exposed and never persisted. It might not be reproducible over multiple instantiations of the application. The implementation reserves the right to recalibrate this internal scale. Later, when Lumiera gains the capability to run within a network of render nodes, these instance connections will include a negotiation about the internal time scale, which remains completely opaque to the outer world. This explains, why {{{lumiera::Time}}} instances lack the ability to show their time value beyond debugging purposes. This is to avoid confusion and to stress their opaque nature.