CompositeState.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #region --------------- Copyright Dresser Wayne Pignone -------------
  2. /*
  3. * $Log: /Wrk/WayneLibraries/Wrk/StateEngine/Generic/CompositeState.cs $
  4. *
  5. * 6 08-05-07 15:35 roger.månsson
  6. * Obsoleted constructor with main object reference again. Instead, use
  7. * WritableMain property. When this is set on a composite state object,
  8. * the abstract method "ConfigureCompositeStateMachine" is called, and the
  9. * configuration of the state machine can be made.
  10. *
  11. * 5 08-04-25 9:02 Mattias.larsson
  12. * Obsoleted the WritableMain-usage. A state-constructor taking the
  13. * Main-object as an argument should be used.
  14. *
  15. * 4 08-04-24 15:45 Mattias.larsson
  16. *
  17. * 3 08-02-26 14:12 Mattias.larsson
  18. * Removed Obsolete methods.
  19. *
  20. * 2 07-03-12 15:17 roger.månsson
  21. * Documentation update.
  22. *
  23. * 1 07-03-02 13:20 roger.mnsson
  24. * Created generic reusable state classes that has a main object.
  25. */
  26. #endregion
  27. namespace Wayne.Lib.StateEngine.Generic
  28. {
  29. /// <summary>
  30. /// Generic composite state class that has a main object of a generic type.
  31. /// </summary>
  32. /// <typeparam name="TMain">Specifies the type of the main object.</typeparam>
  33. public abstract class CompositeState<TMain> : Wayne.Lib.StateEngine.CompositeState, IGenericState<TMain>
  34. {
  35. #region Properties
  36. /// <summary>
  37. /// The main object.
  38. /// </summary>
  39. protected TMain Main
  40. {
  41. get;
  42. private set;
  43. }
  44. #endregion
  45. #region Methods
  46. /// <summary>
  47. /// Configure the composite state machine
  48. /// </summary>
  49. protected abstract void ConfigureCompositeStateMachine();
  50. #endregion
  51. #region IGenericState<TMain> Members
  52. TMain IGenericState<TMain>.WritableMain
  53. {
  54. get { return Main; }
  55. set
  56. {
  57. Main = value;
  58. //Configure the state machine after the writable main has been assigned.
  59. ConfigureCompositeStateMachine();
  60. }
  61. }
  62. #endregion
  63. }
  64. }