#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.");
}
///
/// Sends an event to the child state machine.
///
///
public override void IncomingEvent(StateEngineEvent stateEngineEvent)
{
if (ParentStateMachine != null)
ParentStateMachine.IncomingEvent(stateEngineEvent);
}
///
/// A composite state machine will alway return true for started.
///
public override bool Started
{
get { return true; }
}
///
/// 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.
///
///
///
protected internal override State CreateState(string factoryName)
{
State newState = base.CreateState(factoryName);
if (newState != null)
newState.AssignParentState(ownerState);
return newState;
}
}
}