2007-05-11 21:15:35 +00:00
|
|
|
#region CPL License
|
|
|
|
/*
|
|
|
|
Nuclex Framework
|
2008-01-07 18:04:02 +00:00
|
|
|
Copyright (C) 2002-2008 Nuclex Development Labs
|
2007-05-11 21:15:35 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the IBM Common Public License as
|
|
|
|
published by the IBM Corporation; either version 1.0 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
IBM Common Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the IBM Common Public
|
|
|
|
License along with this library
|
|
|
|
*/
|
|
|
|
#endregion
|
2007-07-24 20:15:19 +00:00
|
|
|
|
2007-04-16 18:31:59 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace Nuclex.Support.Tracking {
|
|
|
|
|
2008-06-11 20:28:08 +00:00
|
|
|
/// <summary>Waitable with an associated weight for the total progress</summary>
|
|
|
|
public class WeightedWaitable<WaitableType> where WaitableType : Waitable {
|
2007-04-18 20:20:03 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2008-06-11 20:28:08 +00:00
|
|
|
/// Initializes a new weighted waitable with a default weight of 1.0
|
2007-04-18 20:20:03 +00:00
|
|
|
/// </summary>
|
2008-06-11 20:28:08 +00:00
|
|
|
/// <param name="waitable">Waitable whose progress to monitor</param>
|
|
|
|
public WeightedWaitable(WaitableType waitable) : this(waitable, 1.0f) { }
|
|
|
|
|
|
|
|
/// <summary>Initializes a new weighted waitable</summary>
|
|
|
|
/// <param name="waitable">Waitable whose progress to monitor</param>
|
|
|
|
/// <param name="weight">Weighting of the waitable's progress</param>
|
|
|
|
public WeightedWaitable(WaitableType waitable, float weight) {
|
|
|
|
this.waitable = waitable;
|
2008-05-14 19:06:06 +00:00
|
|
|
this.weight = weight;
|
2007-04-16 18:31:59 +00:00
|
|
|
}
|
|
|
|
|
2008-06-11 20:28:08 +00:00
|
|
|
/// <summary>Waitable being wrapped by this weighted waitable</summary>
|
|
|
|
public WaitableType Waitable {
|
|
|
|
get { return this.waitable; }
|
2007-04-16 18:31:59 +00:00
|
|
|
}
|
|
|
|
|
2008-06-11 20:28:08 +00:00
|
|
|
/// <summary>The contribution of this waitable to the total progress</summary>
|
2007-04-16 18:31:59 +00:00
|
|
|
public float Weight {
|
|
|
|
get { return this.weight; }
|
|
|
|
}
|
|
|
|
|
2008-06-11 20:28:08 +00:00
|
|
|
/// <summary>Waitable whose progress we're tracking</summary>
|
|
|
|
private WaitableType waitable;
|
|
|
|
/// <summary>Weighting of this waitable in the total progress</summary>
|
2007-04-16 18:31:59 +00:00
|
|
|
private float weight;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Nuclex.Support.Tracking
|