Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.5 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CActionList.h
  7. //
  8. // Description:
  9. // Header file for CActionList class.
  10. //
  11. // The CActionList is a class the provides a functionality for a list of
  12. // actions. When an action list is committed, it commits each of the
  13. // actions in its list. Either the entire list is committed or none of
  14. // actions are.
  15. //
  16. // Implementation Files:
  17. // CActionList.cpp
  18. //
  19. // Maintained By:
  20. // Vij Vasu (Vvasu) 03-MAR-2000
  21. //
  22. //////////////////////////////////////////////////////////////////////////////
  23. // Make sure that this file is included only once per compile path.
  24. #pragma once
  25. //////////////////////////////////////////////////////////////////////////
  26. // Include Files
  27. //////////////////////////////////////////////////////////////////////////
  28. // For the CAction base class
  29. #include "CAction.h"
  30. // For the list class
  31. #include "CList.h"
  32. //////////////////////////////////////////////////////////////////////////////
  33. //++
  34. //
  35. // class CActionList
  36. //
  37. // Description:
  38. // The CActionList is a class the provides a functionality for a list of
  39. // actions. When an action list is committed, it commits each of the
  40. // actions in its list.
  41. //
  42. // If any of the actions fail (indicated by throwing an exception), then
  43. // all the committed actions are rolled back.
  44. //
  45. // The CActionList derives from CAction since it can also be committed
  46. // or rolled back.
  47. //
  48. //--
  49. //////////////////////////////////////////////////////////////////////////////
  50. class CActionList : public CAction
  51. {
  52. public:
  53. //////////////////////////////////////////////////////////////////////////
  54. // Constructors and destructors
  55. //////////////////////////////////////////////////////////////////////////
  56. // Default constructor.
  57. CActionList();
  58. // Default virtual destructor.
  59. ~CActionList();
  60. //////////////////////////////////////////////////////////////////////////
  61. // Public methods
  62. //////////////////////////////////////////////////////////////////////////
  63. //
  64. // Base class method.
  65. // Commit this action list. This method has to be durable and consistent. It shoud
  66. // try as far as possible to be atomic.
  67. //
  68. void Commit();
  69. //
  70. // Base class method.
  71. // Rollback this action list. Be careful about throwing exceptions from this method
  72. // as a stack unwind might be in progress when this method is called.
  73. //
  74. void Rollback();
  75. // Add an action to the end of the list of actions to be performed.
  76. virtual void AppendAction( CAction * const paNewActionIn );
  77. // Returns the number of progress messages that this action will send.
  78. UINT
  79. UiGetMaxProgressTicks() const throw();
  80. protected:
  81. //////////////////////////////////////////////////////////////////////////
  82. // Protected type definitions
  83. //////////////////////////////////////////////////////////////////////////
  84. typedef CList<CAction *> ActionPtrList;
  85. //////////////////////////////////////////////////////////////////////////
  86. // Protected accessor methods
  87. //////////////////////////////////////////////////////////////////////////
  88. //
  89. // Pending action list accessor
  90. //
  91. ActionPtrList & AplGetPendingActionsList() throw()
  92. {
  93. return m_aplPendingActions;
  94. }
  95. //////////////////////////////////////////////////////////////////////////
  96. // Protected member functions
  97. //////////////////////////////////////////////////////////////////////////
  98. // Call commit on the action list. Called by Commit().
  99. void CommitList( ActionPtrList::CIterator & rapliFirstUncommittedOut );
  100. // Rollback the already committed actions.
  101. void RollbackCommitted( const ActionPtrList::CIterator & rapliFirstUncommittedIn );
  102. private:
  103. //////////////////////////////////////////////////////////////////////////
  104. // Private type definitions
  105. //////////////////////////////////////////////////////////////////////////
  106. typedef CAction BaseClass;
  107. //////////////////////////////////////////////////////////////////////////
  108. // Private data
  109. //////////////////////////////////////////////////////////////////////////
  110. // List of actions yet to be committed.
  111. ActionPtrList m_aplPendingActions;
  112. }; //*** class CActionList