69 lines
1.7 KiB
C#
69 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using CAnchor = Cryville.Crtr.Anchor;
|
|
|
|
namespace Cryville.Crtr {
|
|
public class StampedEvent : IComparable<StampedEvent> {
|
|
public double Time;
|
|
public ChartEvent Unstamped;
|
|
public EventContainer Container;
|
|
public StampedEvent Origin;
|
|
public List<StampedEvent> Subevents = new List<StampedEvent>();
|
|
public List<StampedEvent> Coevents;
|
|
private StampedEvent relev = null;
|
|
|
|
public double Duration {
|
|
get {
|
|
if (Unstamped == null) return 0;
|
|
if (Unstamped.IsLong)
|
|
return ReleaseEvent.Time - Time;
|
|
else return 0;
|
|
}
|
|
}
|
|
|
|
public virtual int Priority {
|
|
get {
|
|
if (Unstamped != null) return Unstamped.Priority;
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
public class Anchor : StampedEvent {
|
|
public CAnchor Target;
|
|
public override int Priority {
|
|
get { return 0; }
|
|
}
|
|
}
|
|
|
|
public StampedEvent ReleaseEvent {
|
|
get {
|
|
if (relev == null) relev = Subevents.FirstOrDefault(ev => ((InstantEvent)ev.Unstamped).IsRelease);
|
|
return relev;
|
|
}
|
|
}
|
|
|
|
public override string ToString() {
|
|
if (Unstamped == null)
|
|
return string.Format("stmpev at {0} {1}", Time, this.GetType().Name);
|
|
return string.Format("stmpev at {0} {1}", Time, Unstamped.GetType().Name);
|
|
}
|
|
|
|
public int CompareTo(StampedEvent other) {
|
|
int u = this.Time.CompareTo(other.Time);
|
|
if (u != 0) return u;
|
|
u = this.Priority.CompareTo(other.Priority);
|
|
if (u != 0) return u;
|
|
u = this.Duration.CompareTo(other.Duration);
|
|
if (u != 0) return u;
|
|
u = CompareExtra(other);
|
|
if (u != 0) return u;
|
|
return GetHashCode().CompareTo(other.GetHashCode());
|
|
}
|
|
|
|
protected virtual int CompareExtra(StampedEvent other) {
|
|
return 0;
|
|
}
|
|
}
|
|
}
|