///<summary> /// Notifies the position updater that an updateable has changed state. ///</summary> ///<param name="updateable">Updateable with changed state.</param> ///<param name="previousMode">Previous state the updateable was in.</param> public void UpdateableModeChanged(ICCDPositionUpdateable updateable, PositionUpdateMode previousMode) { switch (previousMode) { case PositionUpdateMode.Discrete: discreteUpdateables.Remove(updateable); break; case PositionUpdateMode.Passive: passiveUpdateables.Remove(updateable); break; case PositionUpdateMode.Continuous: continuousUpdateables.Remove(updateable); break; } switch (updateable.PositionUpdateMode) { case PositionUpdateMode.Discrete: discreteUpdateables.Add(updateable); break; case PositionUpdateMode.Passive: passiveUpdateables.Add(updateable); break; case PositionUpdateMode.Continuous: continuousUpdateables.Add(updateable); break; } }
///<summary> /// Removes an updateable from the updater. ///</summary> ///<param name="updateable">Item to remove.</param> ///<exception cref="Exception">Thrown if the updater does not own the updateable.</exception> public override void Remove(IPositionUpdateable updateable) { if (updateable.PositionUpdater == this) { updateable.PositionUpdater = null; ICCDPositionUpdateable ccdUpdateable = updateable as ICCDPositionUpdateable; if (ccdUpdateable != null) { switch (ccdUpdateable.PositionUpdateMode) { case PositionUpdateMode.Discrete: discreteUpdateables.Remove(updateable); break; case PositionUpdateMode.Passive: passiveUpdateables.Remove(ccdUpdateable); break; case PositionUpdateMode.Continuous: continuousUpdateables.Remove(ccdUpdateable); break; } } else { discreteUpdateables.Remove(updateable); } } else { throw new ArgumentException( "Cannot remove object from this Integrator. The object doesn't belong to it."); } }
///<summary> /// Adds an object to the position updater. ///</summary> ///<param name="updateable">Updateable to add.</param> ///<exception cref="Exception">Thrown if the updateable already belongs to a position updater.</exception> public override void Add(IPositionUpdateable updateable) { if (updateable.PositionUpdater == null) { updateable.PositionUpdater = this; ICCDPositionUpdateable ccdUpdateable = updateable as ICCDPositionUpdateable; if (ccdUpdateable != null) { switch (ccdUpdateable.PositionUpdateMode) { case PositionUpdateMode.Discrete: discreteUpdateables.Add(updateable); break; case PositionUpdateMode.Passive: passiveUpdateables.Add(ccdUpdateable); break; case PositionUpdateMode.Continuous: continuousUpdateables.Add(ccdUpdateable); break; } } else { discreteUpdateables.Add(updateable); } } else { throw new ArgumentException("Cannot add object to Integrator; it already belongs to one."); } }