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.

265 lines
8.6 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. FTMan
  5. File Name:
  6. Item.h
  7. Abstract:
  8. The definition of class CItemData. A generic base class to store the data of items from the
  9. tree control of CFTTreeView and from the list control of CFTListView
  10. An item could be:
  11. - a root volumes item
  12. - a logical volume
  13. - a physical partition
  14. - a root free spaces item
  15. - a free space
  16. It also contains the definition of class CItemID. A generic class to store the minimum information
  17. needed to identify an item. It is used when refreshing the tree.
  18. Author:
  19. Cristian Teodorescu October 22, 1998
  20. Notes:
  21. Revision History:
  22. --*/
  23. /////////////////////////////////////////////////////////////////////////////
  24. #if !defined(AFX_ITEM_H_INCLUDED_)
  25. #define AFX_ITEM_H_INCLUDED_
  26. #if _MSC_VER > 1000
  27. #pragma once
  28. #endif // _MSC_VER > 1000
  29. #include <FTTypes.h>
  30. #include "FTManDef.h"
  31. #include "Global.h"
  32. ////////////////////////////////////////////////////////////////////////////////////////////////////
  33. // Class CItemData
  34. class CItemData : public CObject
  35. {
  36. // Public constructor
  37. public:
  38. CItemData( ITEM_TYPE wItemType, CItemData* pParentData = NULL, BOOL bIsRootVolume = FALSE );
  39. DECLARE_DYNAMIC(CItemData)
  40. // Copy constructor
  41. CItemData( CItemData& rData );
  42. virtual ~CItemData() {};
  43. // Public methods
  44. public:
  45. // Retrieve all information related to this volume
  46. // If something wrong happens inside this method strErrors will contain error message(s)
  47. virtual BOOL ReadItemInfo( CString& strErrors ) = 0;
  48. // Retrieve the members of this volume( as an array of CItemData )
  49. // If something wrong happens inside this method strErrors will contain error message(s)
  50. virtual BOOL ReadMembers( CObArray& arrMembersData, CString& strErrors ) = 0;
  51. // Read the drive letter and volume name of the volume
  52. BOOL ReadDriveLetterAndVolumeName();
  53. // Decides what image should be associated with the item ( depending on the status of the item )
  54. virtual int ComputeImageIndex() const = 0;
  55. // Returns the type of the item
  56. ITEM_TYPE GetItemType() const { return m_wItemType;} ;
  57. // Provides the number of members of this item ( the number retrieved by ReadItemInfo )
  58. ULONG GetMembersNumber() const { return m_ulNumMembers;};
  59. // Provides the drive letter of the item
  60. TCHAR GetDriveLetter() const { return m_cDriveLetter; };
  61. // Provides the volume name of this item
  62. const CString& GetVolumeName() const { return m_strVolumeName; };
  63. // Provides the mount paths of this item
  64. CStringArray& GetMountPaths() { return m_arrMountPaths; }
  65. // Provides the disks set of the volume
  66. const CULONGSet& GetDisksSet() const { return m_setDisks; };
  67. // Is this volume ready for IO operations
  68. BOOL IsIoOK() const { return m_bIoOK; };
  69. // Provides the status of the volume as a member of its parent's set
  70. void SetMemberStatus( FT_MEMBER_STATE nMemberStatus ) { m_nMemberStatus = nMemberStatus; };
  71. FT_MEMBER_STATE GetMemberStatus() const { return m_nMemberStatus; };
  72. // Is this a root volume?
  73. BOOL IsRootVolume() const { return m_bIsRootVolume; };
  74. // Is all information about this volume loaded into this object so we can use it properly?
  75. BOOL IsValid() const { return m_bValid; };
  76. void SetValid( BOOL bValid = TRUE ) { m_bValid = bValid; };
  77. // Provides the index of the image associated with this item
  78. int GetImageIndex() const { return m_iImage; };
  79. void SetImageIndex( int iImageIndex ) { m_iImage = iImageIndex; };
  80. // Provides a pointer to the item's parent data
  81. CItemData* GetParentData() const { return m_pParentData; };
  82. void SetParentData( CItemData* pParentData ) { m_pParentData = pParentData; } ;
  83. // Returns the tree item associated with this structure
  84. HTREEITEM GetTreeItem() const { return m_hTreeItem; };
  85. void SetTreeItem( HTREEITEM hItem) { m_hTreeItem = hItem; };
  86. // Returns the list item associated with this structure. If this is not -1 this doesn't mean automatically
  87. // that the item is in the list. If you are not sure that it is in the list better check first if its father
  88. // is the father of the items displayed in the list ( equivalent with its father is the selected item in the
  89. // tree )
  90. int GetListItem() const { return m_nListItem; };
  91. void SetListItem( int iItem ) { m_nListItem = iItem; };
  92. BOOL AreMembersInserted() const { return m_bAreMembersInserted; };
  93. void SetAreMembersInserted( BOOL bAreMembersInserted=TRUE) { m_bAreMembersInserted = bAreMembersInserted; };
  94. // Equivalence operator between 2 CItemData instances i.e. are they related to the same volume?
  95. virtual BOOL operator==(CItemData& rData) const = 0;
  96. BOOL operator!=(CItemData& rData) const { return !operator==(rData); };
  97. // Methods providing attributes of the item displayable in the list-view columns
  98. // Name ( string ). Used in list-view in Report mode
  99. virtual void GetDisplayName( CString& strDisplay ) const { strDisplay = _T(" "); };
  100. // Type ( string )
  101. virtual void GetDisplayType( CString& strDisplay ) const { strDisplay = _T(" "); };
  102. // Extended name = name + type. Used in tree view and in list-view in all modes other than Report
  103. virtual void GetDisplayExtendedName( CString& strDisplay ) const { MY_TRY GetDisplayName(strDisplay); MY_CATCH_AND_THROW };
  104. // VolumeID ( number & string )
  105. virtual BOOL GetVolumeID( FT_LOGICAL_DISK_ID& llVolID ) const { return FALSE; };
  106. virtual void GetDisplayVolumeID( CString& strDisplay) const;
  107. // Size ( number & string )
  108. virtual BOOL GetSize( LONGLONG& llSize ) const { return FALSE; };
  109. virtual void GetDisplaySize( CString& strDisplay) const;
  110. // Disk Number ( number(s) & string )
  111. virtual BOOL GetDiskNumber( ULONG& ulDiskNumber ) const { return FALSE; };
  112. void GetDisplayDisksSet( CString& strDisplay ) const;
  113. // Offset ( number & string )
  114. virtual BOOL GetOffset( LONGLONG& llOffset) const { return FALSE; };
  115. virtual void GetDisplayOffset( CString& strDisplay) const;
  116. // Public data members
  117. protected:
  118. /****** Some data about the volume ******/
  119. // The type of the item: root, logical volume or physical partition
  120. ITEM_TYPE m_wItemType;
  121. // The number of members
  122. ULONG m_ulNumMembers;
  123. // Drive letter ---- Used only by root volumes
  124. TCHAR m_cDriveLetter;
  125. // The name of the volume "\\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" ---- Used only by root volumes
  126. CString m_strVolumeName;
  127. // Mount paths ---- Used only by root volumes
  128. CStringArray m_arrMountPaths;
  129. // All disks used by this volume
  130. CULONGSet m_setDisks;
  131. // IO status of the volume. It decides whether the volume can be used or not for IO operations
  132. // For physical partitions it is always TRUE
  133. BOOL m_bIoOK;
  134. // The state of the volume as a member of its parent set ( if any )
  135. FT_MEMBER_STATE m_nMemberStatus;
  136. // Set only for those logical volumes and physical partitions that are root volumes
  137. BOOL m_bIsRootVolume;
  138. /****** Some data about the tree/list view item ******/
  139. // Is all information about this volume loaded into this object?
  140. // ( i.e. has ReadItemInfo succeeded? )
  141. BOOL m_bValid;
  142. // The index of the image associated with this item ( the image depends on the item type )
  143. int m_iImage;
  144. // Pointer to the data of the item's parent ( NULL for the root items )
  145. CItemData* m_pParentData;
  146. // The handle of the tree item containing this structure as tree data ( TVITEM.lParam )
  147. HTREEITEM m_hTreeItem;
  148. // The index of the list item containing this structure as item data
  149. int m_nListItem;
  150. // Are the members of the item inserted in the tree?
  151. BOOL m_bAreMembersInserted;
  152. protected:
  153. // Get the NT name of the volume ---- Used only by root volumes
  154. virtual BOOL RetrieveNTName( CString& strNTName ) const { return FALSE;};
  155. // Retrieve all disks used by the volume
  156. virtual BOOL RetrieveDisksSet() { return FALSE; };
  157. // Add a error message to a string
  158. // The error message will be formatted like this:
  159. // <Item name: >< My error message > [ System error message ]
  160. void AddError( CString& strErrors, UINT unErrorMsg, BOOL bAddSystemMsg = FALSE );
  161. };
  162. ////////////////////////////////////////////////////////////////////////////////////////////////////
  163. // Class CItemID
  164. class CItemID
  165. {
  166. // Public constructor
  167. public:
  168. // Constructor for a generic item ID
  169. CItemID();
  170. // Constructor based on a full CItemData instance
  171. CItemID( const CItemData& pData );
  172. public:
  173. ITEM_TYPE m_wItemType;
  174. union
  175. {
  176. struct //tagLogicalVolumeID
  177. {
  178. FT_LOGICAL_DISK_ID m_llVolID;
  179. } m_LogicalVolumeID;
  180. struct //tagPhysicalPartitionID
  181. {
  182. ULONG m_ulDiskNumber;
  183. LONGLONG m_llOffset;
  184. } m_PhysicalPartitionID, m_FreeSpaceID;
  185. } m_ID;
  186. public:
  187. void Load( const CItemData& rData );
  188. BOOL operator==( const CItemID& id ) const;
  189. BOOL operator>( const CItemID& id ) const;
  190. };
  191. #endif // !defined(AFX_ITEM_H_INCLUDED_)