Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
TimeInterval.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 namespace SiliconStudio.BuildEngine
6 {
7  /// <summary>
8  /// An helper class used to store command timing
9  /// </summary>
10  public class TimeInterval
11  {
12  public long StartTime { get; private set; }
13 
14  public long EndTime { get { return endTimeVal; } private set { endTimeVal = value; } }
15  private long endTimeVal = IntervalNotEnded;
16 
17  public bool HasEnded { get { return endTimeVal != IntervalNotEnded; } }
18 
19  private const long IntervalNotEnded = long.MaxValue;
20 
21  public TimeInterval(long startTime)
22  {
23  StartTime = startTime;
24  }
25 
26  public TimeInterval(long startTime, long endTime)
27  {
28  StartTime = startTime;
29  EndTime = endTime;
30  }
31 
32  public void End(long endTime)
33  {
34  if (endTimeVal != IntervalNotEnded)
35  throw new InvalidOperationException("TimeInterval has already ended");
36 
37  EndTime = endTime;
38  }
39 
40  public bool Overlap(long startTime, long endTime)
41  {
42  return (StartTime > startTime ? StartTime : startTime) < (EndTime < endTime ? EndTime : endTime);
43  }
44  }
45 
46  public class TimeInterval<T> : TimeInterval
47  {
48  public T Object { get; protected set; }
49 
50  public TimeInterval(T obj, long startTime)
51  : base(startTime)
52  {
53  Object = obj;
54  }
55 
56  public TimeInterval(T obj, long startTime, long endTime)
57  : base(startTime, endTime)
58  {
59  Object = obj;
60  }
61  }
62 }
TimeInterval(long startTime, long endTime)
Definition: TimeInterval.cs:26
TimeInterval(T obj, long startTime, long endTime)
Definition: TimeInterval.cs:56
bool Overlap(long startTime, long endTime)
Definition: TimeInterval.cs:40
An helper class used to store command timing
Definition: TimeInterval.cs:10