CompositeState.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. using System;
  28. using System.Collections.Generic;
  29. using System.Text;
  30. namespace Wayne.Lib.StateEngine.Generic
  31. {
  32. /// <summary>
  33. /// Generic composite state class that has a main object of a generic type.
  34. /// </summary>
  35. /// <typeparam name="TMain">Specifies the type of the main object.</typeparam>
  36. public abstract class CompositeState<TMain> : Wayne.Lib.StateEngine.CompositeState, IGenericState<TMain>
  37. {
  38. #region Properties
  39. /// <summary>
  40. /// The main object.
  41. /// </summary>
  42. protected TMain Main
  43. {
  44. get;
  45. private set;
  46. }
  47. #endregion
  48. #region Methods
  49. /// <summary>
  50. /// Configure the composite state machine
  51. /// </summary>
  52. protected abstract void ConfigureCompositeStateMachine();
  53. #endregion
  54. #region IGenericState<TMain> Members
  55. TMain IGenericState<TMain>.WritableMain
  56. {
  57. get { return Main; }
  58. set
  59. {
  60. Main = value;
  61. //Configure the state machine after the writable main has been assigned.
  62. ConfigureCompositeStateMachine();
  63. }
  64. }
  65. #endregion
  66. }
  67. }