#include <timespan.h>
Inheritance diagram for TimeSpan:
Public Member Functions | |
TimeSpan () | |
Constructs an empty TimeSpan object. | |
TimeSpan (TimeSlice lower, TimeSlice upper) | |
Constructs an bounded TimeSpan object. | |
TimeSpan (const TimeSpan &other) | |
Copy contructor for the TimeSpan object. | |
TimeSlice | Lo () const |
TimeSlice | Hi () const |
TimeSlice | GetLowerBound () const |
Dig out the lower bound of this TimeSpan object. | |
TimeSlice | GetUpperBound () const |
Dig out the upper bound of this TimeSpan object. It should always be greater than or equal to the lower bound, otherwise this span is invalid. | |
BOOL | IsEmpty () const |
Check whether this time span object contains a non empty time frame. A time span becomes empty as a result of trying to perform boolean operations on time spans resulting in empty spans. | |
double | GetRelativeTime (TimeSlice current) const |
Convert the absolute time 'current' into a relative value. If the current value is within this time span then the double result will lie between 0 and 1, otherwise it will lie somewhere on the real line. | |
TimeSlice | GetAbsoluteTime (double current) const |
Convert the relative time 'current' into an absolute value. Performs a linear interpolation on this timespans start and end times. Hence if 0<=current<=1 then the returned time will be somewhere within this time span. | |
TimeSpan | Union (const TimeSpan &other) const |
Find the union of this span with the other span. This union will always be valid if either or both spans are non empty. | |
TimeSpan | Intersection (const TimeSpan &other) const |
Find the intersection of this span with 'other' span. If the intersection does not exist, either because one of the spans is empty or both spans are valid but they don't intersect then an empty timespan object is returned. Otherwise the intersection is returned. | |
BOOL | SetBounds (TimeSlice lower, TimeSlice upper) |
Set the bounds of this time span object. The bounds are always set in the object even if they are invalid. | |
BOOL | IsSameAs (const TimeSpan &other) const |
Check whether two TimeSpan objects are the same. | |
BOOL | IsIntersectedWith (const TimeSpan &other) const |
Determine if this time span is intersected with the time span supplied. | |
BOOL | Contains (const TimeSpan &other) const |
Check wether the time span expressed by 'other' is contained entirely within this time span. | |
BOOL | InBounds (TimeSlice current) const |
Checks whether the given time slice is within the bounds of this span. | |
void | Inflate (TimeSlice inflate) |
Inflates the bounds of this object by 'inflate'. | |
TimeSpan | operator+ (TimeSlice shift) const |
Returns TimeSpanA = TimeSpanB + TimeSlice. | |
TimeSpan | operator+ (const TimeSpan &other) const |
Overload operator+ to perform a union opertion. | |
TimeSpan | operator- (TimeSlice shift) const |
Subtracts 'value' from the bounds of this timespan and returns the result as a new time span. | |
TimeSpan | operator- (const TimeSpan &other) const |
Overload the operator- function to perform an intersection of two time spans returning the result in a new timespan. | |
TimeSpan & | operator= (const TimeSpan &other) |
Assignment operator overload, assigns this time span with that of 'other' and returns a reference for further assignment. | |
Protected Member Functions | |
void | MakeInvalid () |
Set the lower and upper time span bounds to the view's now and the documents max time.Make this time span invalid. | |
Private Attributes | |
TimeSlice | LO |
TimeSlice | HI |
Definition at line 116 of file timespan.h.
|
Constructs an empty TimeSpan object.
Definition at line 117 of file timespan.cpp.
|
|
Constructs an bounded TimeSpan object.
Definition at line 135 of file timespan.cpp. 00136 { 00137 if (!SetBounds(lower,upper)) 00138 { 00139 ERROR3("TimeSpan() constructor called with invalid bounds") 00140 } 00141 }
|
|
Copy contructor for the TimeSpan object.
Definition at line 155 of file timespan.cpp.
|
|
Check wether the time span expressed by 'other' is contained entirely within this time span.
Definition at line 430 of file timespan.cpp. 00431 { 00432 // A.Contains(Empty(B))? Empty(A).Contains(B)? 00433 if (IsEmpty() || other.IsEmpty()) 00434 return FALSE; 00435 00436 return (LO<=other.GetLowerBound() && HI>=other.GetUpperBound()); 00437 }
|
|
Convert the relative time 'current' into an absolute value. Performs a linear interpolation on this timespans start and end times. Hence if 0<=current<=1 then the returned time will be somewhere within this time span.
Definition at line 494 of file timespan.cpp. 00495 { 00496 ERROR3IF(IsEmpty(),"TimeSpan::GetAbsoluteTime() called on an empty span"); 00497 return (LO + (TimeSlice)(0.5+current*((double)(HI-LO)))); 00498 }
|
|
Dig out the lower bound of this TimeSpan object.
Definition at line 198 of file timespan.cpp. 00199 { 00200 ERROR3IF(IsEmpty(), "TimeSpan::GetLowerBound() called on an empty TimeSpan"); 00201 return LO; 00202 }
|
|
Convert the absolute time 'current' into a relative value. If the current value is within this time span then the double result will lie between 0 and 1, otherwise it will lie somewhere on the real line.
Definition at line 473 of file timespan.cpp. 00474 { 00475 ERROR3IF(IsEmpty(),"TimeSpan::GetRelativeTime() called on an empty span"); 00476 return ((double)(LO-current)) / ((double)(HI-LO)); 00477 }
|
|
Dig out the upper bound of this TimeSpan object. It should always be greater than or equal to the lower bound, otherwise this span is invalid.
Definition at line 225 of file timespan.cpp. 00226 { 00227 ERROR3IF(IsEmpty(), "TimeSpan::GetUpperBound() called on an empty TimeSpan"); 00228 return HI; 00229 }
|
|
Definition at line 231 of file timespan.cpp. 00232 { 00233 ERROR3IF(IsEmpty(), "TimeSpan::Hi() called on an empty TimeSpan"); 00234 return HI; 00235 }
|
|
Checks whether the given time slice is within the bounds of this span.
Definition at line 406 of file timespan.cpp. 00407 { 00408 // Although Lo>Hi will return false always, lo==hi==current will return true 00409 // on an empty time span so check this. 00410 if (IsEmpty()) 00411 return FALSE; 00412 00413 return (LO<=current && current<=HI); 00414 }
|
|
Inflates the bounds of this object by 'inflate'.
Definition at line 452 of file timespan.cpp. 00453 { 00454 ERROR3IF(IsEmpty(),"TimeSpan::Inflate() called on an empty span"); 00455 LO-=inflate; 00456 HI+=inflate; 00457 }
|
|
Find the intersection of this span with 'other' span. If the intersection does not exist, either because one of the spans is empty or both spans are valid but they don't intersect then an empty timespan object is returned. Otherwise the intersection is returned.
Definition at line 363 of file timespan.cpp.
|
|
Check whether this time span object contains a non empty time frame. A time span becomes empty as a result of trying to perform boolean operations on time spans resulting in empty spans.
Definition at line 297 of file timespan.cpp.
|
|
Determine if this time span is intersected with the time span supplied.
Definition at line 381 of file timespan.cpp. 00382 { 00383 // both bounds must be valid for an intersection 00384 if (IsEmpty() || other.IsEmpty()) 00385 return FALSE; 00386 00387 // check for none intersection case 00388 TimeSlice lower = other.GetLowerBound(); 00389 TimeSlice upper = other.GetUpperBound(); 00390 return !(upper<LO || lower>HI); 00391 }
|
|
Check whether two TimeSpan objects are the same.
Definition at line 318 of file timespan.cpp. 00319 { 00320 BOOL same = (IsEmpty() == other.IsEmpty()); 00321 if (!IsEmpty() && same) 00322 { 00323 same = same && (LO == other.GetLowerBound()); 00324 same = same && (HI == other.GetUpperBound()); 00325 } 00326 return same; 00327 }
|
|
Definition at line 204 of file timespan.cpp. 00205 { 00206 ERROR3IF(IsEmpty(), "TimeSpan::Lo() called on an empty TimeSpan"); 00207 return LO; 00208 }
|
|
Set the lower and upper time span bounds to the view's now and the documents max time.Make this time span invalid.
Definition at line 275 of file timespan.cpp.
|
|
Overload operator+ to perform a union opertion.
Definition at line 532 of file timespan.cpp. 00533 { 00534 // is this empty? 00535 if (IsEmpty()) 00536 return other; 00537 00538 if (other.IsEmpty()) 00539 return (*this); 00540 00541 // make a union out of the bounds 00542 TimeSlice lower = other.GetLowerBound(); 00543 TimeSlice upper = other.GetUpperBound(); 00544 if (LO<lower) lower=LO; 00545 if (HI>upper) upper=HI; 00546 00547 return TimeSpan(lower,upper); 00548 }
|
|
Returns TimeSpanA = TimeSpanB + TimeSlice.
Definition at line 514 of file timespan.cpp.
|
|
Overload the operator- function to perform an intersection of two time spans returning the result in a new timespan.
Definition at line 586 of file timespan.cpp. 00587 { 00588 // both bounds must be valid for an intersection 00589 if (IsEmpty() || other.IsEmpty()) 00590 return (*this); 00591 00592 // check for none intersection case 00593 TimeSlice lower = other.GetLowerBound(); 00594 TimeSlice upper = other.GetUpperBound(); 00595 if (upper<LO || lower>HI) 00596 return (*this); 00597 00598 // make an intersection now we know the two actually do intersect 00599 if (HI<upper) upper=HI; 00600 if (LO>lower) lower=LO; 00601 00602 return TimeSpan(lower,upper); 00603 }
|
|
Subtracts 'value' from the bounds of this timespan and returns the result as a new time span.
Definition at line 567 of file timespan.cpp.
|
|
Assignment operator overload, assigns this time span with that of 'other' and returns a reference for further assignment.
Definition at line 620 of file timespan.cpp. 00621 { 00622 LO = other.GetLowerBound(); 00623 HI = other.GetUpperBound(); 00624 return (*this); 00625 }
|
|
Set the bounds of this time span object. The bounds are always set in the object even if they are invalid.
Definition at line 176 of file timespan.cpp.
|
|
Find the union of this span with the other span. This union will always be valid if either or both spans are non empty.
Definition at line 343 of file timespan.cpp.
|
|
Definition at line 158 of file timespan.h. |
|
Definition at line 157 of file timespan.h. |