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.

139 lines
3.4 KiB

  1. #ifndef _INC_DSKQUOTA_UNDO_H
  2. #define _INC_DSKQUOTA_UNDO_H
  3. ///////////////////////////////////////////////////////////////////////////////
  4. /* File: undo.h
  5. Description: Declarations for classes associated with the "undo" feature.
  6. Revision History:
  7. Date Description Programmer
  8. -------- --------------------------------------------------- ----------
  9. 09/30/96 Initial creation. BrianAu
  10. */
  11. ///////////////////////////////////////////////////////////////////////////////
  12. #ifndef _INC_DSKQUOTA_H
  13. # include "dskquota.h"
  14. #endif
  15. #ifndef _INC_DSKQUOTA_DYNARRAY_H
  16. # include "dynarray.h"
  17. #endif
  18. class UndoList; // Fwd decl.
  19. //
  20. // Virtual base class for all undo actions.
  21. // UndoList maintains a list of these.
  22. //
  23. class UndoAction
  24. {
  25. protected:
  26. PDISKQUOTA_CONTROL m_pQuotaControl; // Ptr to quota control object.
  27. PDISKQUOTA_USER m_pUser; // User object affected by action.
  28. UndoList *m_pUndoList; // Containing undo list object.
  29. LONGLONG m_llLimit; // User object's previous quota limit.
  30. LONGLONG m_llThreshold; // Previous quota threshold.
  31. public:
  32. UndoAction(PDISKQUOTA_USER pUser, LONGLONG llThreshold, LONGLONG llLimit,
  33. PDISKQUOTA_CONTROL pQuotaControl = NULL);
  34. ~UndoAction(VOID);
  35. virtual HRESULT Undo(VOID) = 0;
  36. VOID SetUndoList(UndoList *pUndoList)
  37. { m_pUndoList = pUndoList; }
  38. };
  39. //
  40. // Class for restoring a deleted record.
  41. //
  42. class UndoDelete : public UndoAction
  43. {
  44. public:
  45. UndoDelete(
  46. PDISKQUOTA_USER pUser,
  47. LONGLONG llThreshold,
  48. LONGLONG llLimit
  49. ) : UndoAction(pUser, llThreshold, llLimit) { }
  50. HRESULT Undo(VOID);
  51. };
  52. //
  53. // Class for restoring a newly added record (delete it).
  54. //
  55. class UndoAdd : public UndoAction
  56. {
  57. public:
  58. UndoAdd(
  59. PDISKQUOTA_USER pUser,
  60. PDISKQUOTA_CONTROL pQuotaControl
  61. ) : UndoAction(pUser, 0, 0, pQuotaControl) { }
  62. HRESULT Undo(VOID);
  63. };
  64. //
  65. // Class for restoring a record's previous settings.
  66. //
  67. class UndoModify : public UndoAction
  68. {
  69. public:
  70. UndoModify(
  71. PDISKQUOTA_USER pUser,
  72. LONGLONG llThreshold,
  73. LONGLONG llLimit
  74. ) : UndoAction(pUser, llThreshold, llLimit) { }
  75. HRESULT Undo(VOID);
  76. };
  77. //
  78. // Container for a set of undo actions.
  79. //
  80. class UndoList
  81. {
  82. private:
  83. PointerList m_hList; // List of undo action object ptrs.
  84. PointerList *m_pUserList; // List of quota user object ptrs.
  85. HWND m_hwndListView; // Listview we'll update.
  86. public:
  87. UndoList(PointerList *pUserList, HWND hwndListView)
  88. : m_pUserList(pUserList),
  89. m_hwndListView(hwndListView) { }
  90. ~UndoList(VOID);
  91. VOID Add(UndoAction *pAction)
  92. {
  93. pAction->SetUndoList(this),
  94. m_hList.Append((LPVOID)pAction);
  95. }
  96. HWND GetListViewHwnd(VOID)
  97. { return m_hwndListView; }
  98. PointerList *GetUserList(VOID)
  99. { return m_pUserList; }
  100. VOID Undo(VOID);
  101. VOID Clear(VOID);
  102. INT Count(VOID)
  103. { return m_hList.Count(); }
  104. };
  105. #endif // _INC_DSKQUOTA_UNDO_H