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.

287 lines
9.5 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // PropertyValue.h
  7. //
  8. // Description:
  9. // Definition of the cluster property value classes for the MSCLUS automation
  10. // classes.
  11. //
  12. // Implementation File:
  13. // PropertyValue.cpp
  14. //
  15. // Author:
  16. // Galen Barbee (GalenB) 16-Dec-1998
  17. //
  18. // Revision History:
  19. //
  20. // Notes:
  21. //
  22. /////////////////////////////////////////////////////////////////////////////
  23. #ifndef __PROPERTYVALUE_H__
  24. #define __PROPERTYVALUE_H__
  25. #ifndef _PROPLIST_H_
  26. #if CLUSAPI_VERSION >= 0x0500
  27. #include <PropList.h>
  28. #else
  29. #include "PropList.h"
  30. #endif // CLUSAPI_VERSION >= 0x0500
  31. #endif
  32. /////////////////////////////////////////////////////////////////////////////
  33. // Forward Class Declarations
  34. /////////////////////////////////////////////////////////////////////////////
  35. class CClusPropertyValueData;
  36. class CClusPropertyValue;
  37. class CClusPropertyValues;
  38. /////////////////////////////////////////////////////////////////////////////
  39. //++
  40. //
  41. // class CClusPropertyValueData
  42. //
  43. // Description:
  44. // Cluster Properties Collection Automation Class.
  45. //
  46. // Inheritance:
  47. // IDispatchImpl< ISClusPropertyValueData, &IID_ISClusPropertyValueData, &LIBID_MSClusterLib, MAJORINTERFACEVER, MINORINTERFACEVER >
  48. // CSupportErrorInfo
  49. // CComObjectRootEx< CComSingleThreadModel >
  50. // CComCoClass< CClusPropertyValueData, &CLSID_ClusPropertyValueData >
  51. //
  52. //--
  53. /////////////////////////////////////////////////////////////////////////////
  54. class ATL_NO_VTABLE CClusPropertyValueData :
  55. public IDispatchImpl< ISClusPropertyValueData, &IID_ISClusPropertyValueData, &LIBID_MSClusterLib, MAJORINTERFACEVER, MINORINTERFACEVER >,
  56. public CSupportErrorInfo,
  57. public CComObjectRootEx< CComSingleThreadModel >,
  58. public CComCoClass< CClusPropertyValueData, &CLSID_ClusPropertyValueData >
  59. {
  60. typedef CComObjectRootEx< CComSingleThreadModel > BaseComClass;
  61. public:
  62. typedef std::vector< CComVariant > CClusPropertyValueDataVector;
  63. CClusPropertyValueData( void );
  64. ~CClusPropertyValueData( void );
  65. BEGIN_COM_MAP(CClusPropertyValueData)
  66. COM_INTERFACE_ENTRY(IDispatch)
  67. COM_INTERFACE_ENTRY(ISClusPropertyValueData)
  68. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  69. END_COM_MAP()
  70. DECLARE_NOT_AGGREGATABLE(CClusPropertyValueData)
  71. DECLARE_NO_REGISTRY()
  72. void Clear( void );
  73. private:
  74. CClusPropertyValueDataVector m_cpvdvData;
  75. DWORD m_dwFlags;
  76. CLUSTER_PROPERTY_FORMAT m_cpfFormat;
  77. HRESULT GetIndex( IN VARIANT varIndex, OUT UINT * pnIndex );
  78. HRESULT HrCreateMultiSz( IN CLUSPROP_BUFFER_HELPER cbhValue );
  79. HRESULT HrCreateBinary( IN CLUSPROP_BUFFER_HELPER cbhValue );
  80. public:
  81. HRESULT Create( IN VARIANT varValue, IN CLUSTER_PROPERTY_FORMAT cpfFormat, IN BOOL bReadOnly );
  82. HRESULT Create( IN CLUSPROP_BUFFER_HELPER cbhValue, IN BOOL bReadOnly );
  83. STDMETHODIMP get_Count( OUT long * plCount );
  84. STDMETHODIMP get_Item( IN VARIANT varIndex, OUT VARIANT * pvarValue );
  85. STDMETHODIMP get__NewEnum( OUT IUnknown ** ppunk );
  86. STDMETHODIMP CreateItem( IN VARIANT varValue, OUT VARIANT * pvarData );
  87. STDMETHODIMP RemoveItem( IN VARIANT varIndex );
  88. CComVariant & operator[]( IN int nIndex ) { return m_cpvdvData[ nIndex ]; };
  89. const CComVariant & operator=( IN const CComVariant & varValue );
  90. const CClusPropertyValueDataVector & DataList( void ) const { return m_cpvdvData; };
  91. HRESULT HrFillMultiSzBuffer( OUT LPWSTR * ppsz ) const;
  92. HRESULT HrBinaryValue( IN SAFEARRAY * psa );
  93. };
  94. /////////////////////////////////////////////////////////////////////////////
  95. //++
  96. //
  97. // class CClusPropertyValue
  98. //
  99. // Description:
  100. // Cluster Property Automation Class.
  101. //
  102. // Inheritance:
  103. // IDispatchImpl< ISClusPropertyValue, &IID_ISClusPropertyValue, &LIBID_MSClusterLib, MAJORINTERFACEVER, MINORINTERFACEVER >,
  104. // CSupportErrorInfo
  105. // CComObjectRootEx< CComSingleThreadModel >
  106. // CComCoClass< CClusPropertyValue, &CLSID_ClusProperty >
  107. //
  108. //--
  109. /////////////////////////////////////////////////////////////////////////////
  110. class ATL_NO_VTABLE CClusPropertyValue :
  111. public IDispatchImpl< ISClusPropertyValue, &IID_ISClusPropertyValue, &LIBID_MSClusterLib, MAJORINTERFACEVER, MINORINTERFACEVER >,
  112. public CSupportErrorInfo,
  113. public CComObjectRootEx< CComSingleThreadModel >,
  114. public CComCoClass< CClusPropertyValue, &CLSID_ClusPropertyValue >
  115. {
  116. typedef CComObjectRootEx< CComSingleThreadModel > BaseComClass;
  117. public:
  118. CClusPropertyValue( void );
  119. ~CClusPropertyValue( void );
  120. BEGIN_COM_MAP(CClusPropertyValue)
  121. COM_INTERFACE_ENTRY(IDispatch)
  122. COM_INTERFACE_ENTRY(ISClusPropertyValue)
  123. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  124. END_COM_MAP()
  125. DECLARE_NOT_AGGREGATABLE(CClusPropertyValue)
  126. DECLARE_NO_REGISTRY()
  127. HRESULT Create(
  128. IN VARIANT varValue,
  129. IN CLUSTER_PROPERTY_TYPE cptType,
  130. IN CLUSTER_PROPERTY_FORMAT cpfFormat,
  131. IN size_t cbLength,
  132. IN BOOL bReadOnly
  133. );
  134. HRESULT Create( IN CLUSPROP_BUFFER_HELPER cbhValue, IN BOOL bReadOnly );
  135. STDMETHODIMP get_Value( OUT VARIANT * pvarValue );
  136. STDMETHODIMP put_Value( IN VARIANT varValue );
  137. STDMETHODIMP get_Type( OUT CLUSTER_PROPERTY_TYPE * pcptType );
  138. STDMETHODIMP put_Type( IN CLUSTER_PROPERTY_TYPE cptType );
  139. STDMETHODIMP get_Format( OUT CLUSTER_PROPERTY_FORMAT * pcpfFormat );
  140. STDMETHODIMP put_Format( IN CLUSTER_PROPERTY_FORMAT cpfFormat );
  141. STDMETHODIMP get_Length( OUT long * plLength );
  142. STDMETHODIMP get_DataCount( OUT long * plCount );
  143. STDMETHODIMP get_Data( OUT ISClusPropertyValueData ** ppClusterPropertyValueData );
  144. BOOL Modified( void ) const { return ( m_dwFlags & MODIFIED ); }
  145. BOOL Modified( IN BOOL bModified );
  146. const CComVariant & Value( void ) const { return (*m_pcpvdData)[ 0 ]; };
  147. DWORD CbLength( void ) const {return m_cbLength; };
  148. CComVariant Value( IN const CComVariant & rvarValue );
  149. HRESULT HrBinaryValue( IN SAFEARRAY * psa );
  150. CComObject< CClusPropertyValueData > * Data( void ) const { return m_pcpvdData; };
  151. private:
  152. DWORD m_dwFlags;
  153. CLUSTER_PROPERTY_TYPE m_cptType;
  154. CLUSTER_PROPERTY_FORMAT m_cpfFormat;
  155. CComObject< CClusPropertyValueData > * m_pcpvdData;
  156. size_t m_cbLength;
  157. };
  158. /////////////////////////////////////////////////////////////////////////////
  159. //++
  160. //
  161. // class CClusPropertyValues
  162. //
  163. // Description:
  164. // Cluster Properties Collection Automation Class.
  165. //
  166. // Inheritance:
  167. // IDispatchImpl< ISClusPropertyValues, &IID_ISClusPropertyValues, &LIBID_MSClusterLib, MAJORINTERFACEVER, MINORINTERFACEVER >
  168. // CSupportErrorInfo
  169. // CComObjectRootEx< CComSingleThreadModel >
  170. // CComCoClass< CClusPropertyValues, &CLSID_ClusProperties >
  171. //
  172. //--
  173. /////////////////////////////////////////////////////////////////////////////
  174. class ATL_NO_VTABLE CClusPropertyValues :
  175. public IDispatchImpl< ISClusPropertyValues, &IID_ISClusPropertyValues, &LIBID_MSClusterLib, MAJORINTERFACEVER, MINORINTERFACEVER >,
  176. public CSupportErrorInfo,
  177. public CComObjectRootEx< CComSingleThreadModel >,
  178. public CComCoClass< CClusPropertyValues, &CLSID_ClusPropertyValues >
  179. {
  180. typedef CComObjectRootEx< CComSingleThreadModel > BaseComClass;
  181. public:
  182. typedef std::vector< CComObject< CClusPropertyValue > * > CClusPropertyValueVector;
  183. CClusPropertyValues( void );
  184. ~CClusPropertyValues( void );
  185. BEGIN_COM_MAP(CClusPropertyValues)
  186. COM_INTERFACE_ENTRY(IDispatch)
  187. COM_INTERFACE_ENTRY(ISClusPropertyValues)
  188. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  189. END_COM_MAP()
  190. DECLARE_NOT_AGGREGATABLE(CClusPropertyValues)
  191. DECLARE_NO_REGISTRY()
  192. void Clear( void );
  193. private:
  194. CClusPropertyValueVector m_cpvvValues;
  195. HRESULT HrGetVariantLength( IN const VARIANT rvarValue, OUT PDWORD pcbLength, IN CLUSTER_PROPERTY_FORMAT cpfFormat );
  196. HRESULT GetIndex( IN VARIANT varIndex, OUT UINT * pnIndex );
  197. HRESULT HrFillPropertyValuesVector( IN OUT CClusPropValueList & cplPropValueList, IN BOOL bReadOnly );
  198. public:
  199. HRESULT Create( IN const CClusPropValueList & pvlValue, IN BOOL bReadOnly );
  200. HRESULT Create(
  201. IN VARIANT varValue,
  202. IN CLUSTER_PROPERTY_TYPE cptType,
  203. IN CLUSTER_PROPERTY_FORMAT cpfFormat,
  204. IN BOOL bReadOnly
  205. );
  206. STDMETHODIMP get_Count( OUT long * plCount );
  207. STDMETHODIMP get_Item( IN VARIANT varIndex, OUT ISClusPropertyValue ** ppPropertyValue );
  208. STDMETHODIMP get__NewEnum( OUT IUnknown ** ppunk );
  209. STDMETHODIMP CreateItem( IN BSTR bstrName, IN VARIANT varValue, OUT ISClusPropertyValue ** ppPropertyValue );
  210. STDMETHODIMP RemoveItem( IN VARIANT varIndex );
  211. CComObject< CClusPropertyValue > * operator[]( IN int nIndex ) const { return m_cpvvValues[ nIndex ]; };
  212. DWORD CbLength( void ) const { return m_cpvvValues[ 0 ]->CbLength(); };
  213. const CClusPropertyValueVector & ValuesList (void ) const { return m_cpvvValues; };
  214. }; //*** Class CClusPropertyValues
  215. #endif // __PROPERTYVALUE_H__