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.

329 lines
10 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CBCAInterface.h
  7. //
  8. // Description:
  9. // This file contains the declaration of the CBCAInterface
  10. // class. This class implements the IClusCfgBaseCluster interface.
  11. //
  12. // Documentation:
  13. // TODO: fill in pointer to external documentation
  14. //
  15. // Implementation Files:
  16. // CBCAInterface.cpp
  17. //
  18. // Maintained By:
  19. // Vij Vasu (VVasu) 07-MAR-2000
  20. //
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Make sure that this file is included only once per compile path.
  23. #pragma once
  24. //////////////////////////////////////////////////////////////////////////////
  25. // Include Files
  26. //////////////////////////////////////////////////////////////////////////////
  27. // For IUnknown
  28. #include <unknwn.h>
  29. // For IClusCfgBaseCluster
  30. // For IClusCfgInitialize
  31. // For IClusCfgCallback
  32. #include "ClusCfgServer.h"
  33. #include "ClusCfgPrivate.h"
  34. // For CSmartIfacePtr
  35. #include "SmartClasses.h"
  36. // For the a few common types and definitions
  37. #include "CommonDefs.h"
  38. // For the CStr class
  39. #include "CStr.h"
  40. // For the CList class
  41. #include "CList.h"
  42. //////////////////////////////////////////////////////////////////////////
  43. // Forward declarations.
  44. //////////////////////////////////////////////////////////////////////////
  45. class CBaseClusterAction;
  46. class CException;
  47. class CExceptionWithString;
  48. class CAssert;
  49. //////////////////////////////////////////////////////////////////////////////
  50. //++
  51. //
  52. // class CBCAInterface
  53. //
  54. // Description:
  55. // This class implements the IClusCfgBaseCluster interface.
  56. //
  57. //--
  58. //////////////////////////////////////////////////////////////////////////////
  59. class CBCAInterface
  60. : public IClusCfgBaseCluster
  61. , public IClusCfgInitialize
  62. {
  63. public:
  64. //////////////////////////////////////////////////////////////////////////
  65. // IUnknown methods
  66. //////////////////////////////////////////////////////////////////////////
  67. STDMETHOD( QueryInterface )( REFIID riidIn, void ** ppvOut );
  68. STDMETHOD_( ULONG, AddRef )( void );
  69. STDMETHOD_( ULONG, Release )( void );
  70. //////////////////////////////////////////////////////////////////////////
  71. // IClusCfgBaseCluster methods
  72. //////////////////////////////////////////////////////////////////////////
  73. // Indicate that a cluster is to be formed.
  74. STDMETHOD( SetForm )(
  75. const WCHAR * pcszClusterNameIn
  76. , const WCHAR * pcszClusterBindingStringIn
  77. , const WCHAR * pcszClusterAccountNameIn
  78. , const WCHAR * pcszClusterAccountPwdIn
  79. , const WCHAR * pcszClusterAccountDomainIn
  80. , const DWORD dwClusterIPAddressIn
  81. , const DWORD dwClusterIPSubnetMaskIn
  82. , const WCHAR * pcszClusterIPNetworkIn
  83. );
  84. // Indicate that this node should be added to a cluster.
  85. STDMETHOD( SetJoin )(
  86. const WCHAR * pcszClusterNameIn
  87. , const WCHAR * pcszClusterBindingStringIn
  88. , const WCHAR * pcszClusterAccountNameIn
  89. , const WCHAR * pcszClusterAccountPwdIn
  90. , const WCHAR * pcszClusterAccountDomainIn
  91. );
  92. // Indicate that this node needs to be cleaned up.
  93. STDMETHOD( SetCleanup )( void );
  94. // Commit the action desired.
  95. STDMETHOD( Commit )( void );
  96. // Rollback the committed action.
  97. STDMETHOD( Rollback )( void );
  98. //////////////////////////////////////////////////////////////////////////
  99. // IClusCfgInitialize methods
  100. //////////////////////////////////////////////////////////////////////////
  101. // Initialize this object.
  102. STDMETHOD( Initialize )(
  103. IUnknown * punkCallbackIn
  104. , LCID lcidIn
  105. );
  106. //////////////////////////////////////////////////////////////////////////
  107. // Other public methods
  108. //////////////////////////////////////////////////////////////////////////
  109. // Create an instance of this class.
  110. static HRESULT
  111. S_HrCreateInstance( IUnknown ** ppunkOut );
  112. // Send progress notification [ string id overload ]
  113. void
  114. SendStatusReport(
  115. const CLSID & clsidTaskMajorIn
  116. , const CLSID & clsidTaskMinorIn
  117. , ULONG ulMinIn
  118. , ULONG ulMaxIn
  119. , ULONG ulCurrentIn
  120. , HRESULT hrStatusIn
  121. , UINT uiDescriptionStringIdIn
  122. , bool fIsAbortAllowedIn = true
  123. );
  124. // Send progress notification [ string overload ]
  125. void
  126. SendStatusReport(
  127. const CLSID & clsidTaskMajorIn
  128. , const CLSID & clsidTaskMinorIn
  129. , ULONG ulMinIn
  130. , ULONG ulMaxIn
  131. , ULONG ulCurrentIn
  132. , HRESULT hrStatusIn
  133. , const WCHAR * pcszDescriptionStringIn
  134. , bool fIsAbortAllowedIn = true
  135. );
  136. // Queue a status report to be sent when an exception is caught.
  137. void
  138. QueueStatusReportCompletion(
  139. const CLSID & clsidTaskMajorIn
  140. , const CLSID & clsidTaskMinorIn
  141. , ULONG ulMinIn
  142. , ULONG ulMaxIn
  143. , UINT uiDescriptionStringIdIn
  144. );
  145. // Process an exception that should be shown to the user.
  146. HRESULT
  147. HrProcessException( CExceptionWithString & resExceptionObjectInOut ) throw();
  148. // Process an assert exception.
  149. HRESULT
  150. HrProcessException( const CAssert & rcaExceptionObjectIn ) throw();
  151. // Process a general exception.
  152. HRESULT
  153. HrProcessException( const CException & rceExceptionObjectIn ) throw();
  154. // Process an unknown exception.
  155. HRESULT
  156. HrProcessException( void ) throw();
  157. //////////////////////////////////////////////////////////////////////////
  158. // Public accessor methods
  159. //////////////////////////////////////////////////////////////////////////
  160. // Has this action been successfully committed?
  161. bool
  162. FIsCommitComplete() const throw() { return m_fCommitComplete; }
  163. // Can this action be rolled back?
  164. bool
  165. FIsRollbackPossible() const throw() { return m_fRollbackPossible; }
  166. // Are callbacks supported?
  167. bool
  168. FIsCallbackSupported() const throw() { return m_fCallbackSupported; }
  169. private:
  170. //////////////////////////////////////////////////////////////////////////
  171. // Private types
  172. //////////////////////////////////////////////////////////////////////////
  173. // Smart pointer to a base cluster action.
  174. typedef CSmartGenericPtr< CPtrTrait< CBaseClusterAction > > SmartBCAPointer;
  175. // Structure that holds the data required to send pending status reports.
  176. struct SPendingStatusReport
  177. {
  178. const CLSID m_clsidTaskMajor;
  179. const CLSID m_clsidTaskMinor;
  180. ULONG m_ulMin;
  181. ULONG m_ulMax;
  182. UINT m_uiDescriptionStringId;
  183. // Constructor
  184. SPendingStatusReport(
  185. const CLSID & rclsidTaskMajorIn
  186. , const CLSID & rclsidTaskMinorIn
  187. , ULONG ulMinIn
  188. , ULONG ulMaxIn
  189. , UINT uiDescriptionStringIdIn
  190. )
  191. : m_clsidTaskMajor( rclsidTaskMajorIn )
  192. , m_clsidTaskMinor( rclsidTaskMinorIn )
  193. , m_ulMin( ulMinIn )
  194. , m_ulMax( ulMaxIn )
  195. , m_uiDescriptionStringId( uiDescriptionStringIdIn )
  196. {
  197. } //*** SPendingStatusReport()
  198. }; // struct SPendingStatusReport
  199. // List of pending status reports
  200. typedef CList< SPendingStatusReport > PendingReportList;
  201. //////////////////////////////////////////////////////////////////////////
  202. // Private member functions
  203. //////////////////////////////////////////////////////////////////////////
  204. //
  205. // Private constructors, destructor and assignment operator.
  206. // All of these methods are private for two reasons:
  207. // 1. Lifetimes of objects of this class are controlled by S_HrCreateInstance and Release.
  208. // 2. Copying of an object of this class is prohibited.
  209. //
  210. // Default constructor.
  211. CBCAInterface( void );
  212. // Destructor.
  213. ~CBCAInterface( void );
  214. // Copy constructor.
  215. CBCAInterface( const CBCAInterface & );
  216. // Assignment operator.
  217. CBCAInterface & operator =( const CBCAInterface & );
  218. //////////////////////////////////////////////////////////////////////////
  219. // Private accessor methods
  220. //////////////////////////////////////////////////////////////////////////
  221. // Set the commit status.
  222. void
  223. SetCommitCompleted( bool fComplete = true ) throw() { m_fCommitComplete = fComplete; }
  224. // Indicate if rollback is possible
  225. void
  226. SetRollbackPossible( bool fPossible = true ) throw() { m_fRollbackPossible = fPossible; }
  227. // Indicate if callbacks are supported or not.
  228. void
  229. SetCallbackSupported( bool fSupported = true ) throw() { m_fCallbackSupported = fSupported; }
  230. //////////////////////////////////////////////////////////////////////////
  231. // Other private methods
  232. //////////////////////////////////////////////////////////////////////////
  233. // Send all those status reports that were supposed to be sent
  234. void
  235. CompletePendingStatusReports( HRESULT hrStatusIn ) throw();
  236. //////////////////////////////////////////////////////////////////////////
  237. // Private data
  238. //////////////////////////////////////////////////////////////////////////
  239. // Indicates if this action has been successfully committed or not.
  240. bool m_fCommitComplete;
  241. // Indicates if this action can be rolled back or not.
  242. bool m_fRollbackPossible;
  243. // Indicates if callbacks are supported or not.
  244. bool m_fCallbackSupported;
  245. // Reference count for this object.
  246. LONG m_cRef;
  247. // The locale id.
  248. LCID m_lcid;
  249. // Pointer to the action to be performed during Commit()
  250. SmartBCAPointer m_spbcaCurrentAction;
  251. // Pointer to the synchronous callback interface.
  252. CSmartIfacePtr< IClusCfgCallback > m_spcbCallback;
  253. // List of status reports that need to be send when an exception is caught.
  254. PendingReportList m_prlPendingReportList;
  255. }; //*** class CBCAInterface