Source code of Windows XP (NT5)
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.

113 lines
3.0 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CAction.cpp
  7. //
  8. // Description:
  9. // Contains the definition of the CAction class.
  10. //
  11. // Documentation:
  12. // TODO: Add pointer to external documentation later.
  13. //
  14. // Maintained By:
  15. // Vij Vasu (Vvasu) 25-APR-2000
  16. //
  17. //////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19. // Include Files
  20. //////////////////////////////////////////////////////////////////////////////
  21. // The precompiled header.
  22. #include "pch.h"
  23. // For the CAction class
  24. #include "CAction.h"
  25. //////////////////////////////////////////////////////////////////////////////
  26. //++
  27. //
  28. // void
  29. // CAction::Commit( void )
  30. //
  31. // Description:
  32. // This function just checks to make sure that this action has not already
  33. // been commmitted.
  34. //
  35. // Arguments:
  36. // None.
  37. //
  38. // Return Value:
  39. // None.
  40. //
  41. // Exceptions Thrown:
  42. // CAssert
  43. // If the action has already been committed.
  44. //
  45. //--
  46. //////////////////////////////////////////////////////////////////////////////
  47. void
  48. CAction::Commit( void )
  49. {
  50. BCATraceScope( "" );
  51. // Has this action already been committed?
  52. if ( FIsCommitComplete() )
  53. {
  54. BCATraceMsg( "This action has already been committed. Throwing exception." );
  55. THROW_ASSERT( E_UNEXPECTED, "This action has already been committed." );
  56. } // if: already committed.
  57. } //*** CAction::Commit()
  58. //////////////////////////////////////////////////////////////////////////////
  59. //++
  60. //
  61. // void
  62. // CAction::Rollback( void )
  63. //
  64. // Description:
  65. // Since the Commit() of this class does nothing, rollback does nothing
  66. // too. However, it checks to make sure that this action can indeed be
  67. // rolled back.
  68. //
  69. // Arguments:
  70. // None.
  71. //
  72. // Return Value:
  73. // None.
  74. //
  75. // Exceptions Thrown:
  76. // CAssert
  77. // If this action has not been committed yet or if rollback is not
  78. // possible.
  79. //
  80. //--
  81. //////////////////////////////////////////////////////////////////////////////
  82. void
  83. CAction::Rollback( void )
  84. {
  85. BCATraceScope( "" );
  86. // Check if this action list has completed successfully.
  87. if ( !FIsCommitComplete() )
  88. {
  89. // Cannot rollback an incomplete action.
  90. BCATraceMsg( "Cannot rollback - this action has not been committed. Throwing exception." );
  91. THROW_ASSERT( E_UNEXPECTED, "Cannot rollback - this action has been committed." );
  92. } // if: this action was not completed successfully
  93. // Check if this list can be rolled back.
  94. if ( !FIsRollbackPossible() )
  95. {
  96. // Cannot rollback an incompleted action.
  97. BCATraceMsg( "This action list cannot be rolled back." );
  98. THROW_ASSERT( E_UNEXPECTED, "This action does not allow rollbacks." );
  99. } // if: this action was not completed successfully
  100. } //*** CAction::Rollback()