1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #region --------------- Copyright Dresser Wayne Pignone -------------
- /*
- * $Log: /Wrk/WayneLibraries/Wrk/StateEngine/CompositeStateMachine.cs $
- *
- * 4 08-02-26 14:07 Mattias.larsson
- * Renamed stateName to factoryName.
- */
- #endregion
- #region Old file header
- /*===============================================================================
- * CompositeState
- *
- * Change history
- * When Who Comment
- * ---------- ------ ------------------------------------
- * 2006-07-17 RMa Created
- *
- ---------------------------------------------------------------------------------*/
- #endregion
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Wayne.Lib.StateEngine
- {
- internal class CompositeStateMachine : StateMachine
- {
- #region Fields
- CompositeState ownerState;
- #endregion
- #region Construction
- public CompositeStateMachine(CompositeState ownerState)
- : base(ownerState.GetType().FullName, null, null) //The debug logger properties are assigned later.
- {
- this.ownerState = ownerState;
- }
- #endregion
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "Wayne.Lib.StateEngine.StateEngineException.#ctor(System.String)")]
- public override void Start()
- {
- throw new StateEngineException("You may not call Start on a state machine in a composite state.");
- }
- /// <summary>
- /// Sends an event to the child state machine.
- /// </summary>
- /// <param name="stateEngineEvent"></param>
- public override void IncomingEvent(StateEngineEvent stateEngineEvent)
- {
- if (ParentStateMachine != null)
- ParentStateMachine.IncomingEvent(stateEngineEvent);
- }
- /// <summary>
- /// A composite state machine will alway return true for started.
- /// </summary>
- public override bool Started
- {
- get { return true; }
- }
- /// <summary>
- /// Override of the Create state method. This adds the functionality to equip the
- /// newly created state with a reference to the the parent composite state.
- /// </summary>
- /// <param name="factoryName"></param>
- /// <returns></returns>
- protected internal override State CreateState(string factoryName)
- {
- State newState = base.CreateState(factoryName);
- if (newState != null)
- newState.AssignParentState(ownerState);
- return newState;
- }
- }
- }
|