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.

261 lines
8.6 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // Property.h
  7. //
  8. // Description:
  9. // Definition of the cluster property classes for the MSCLUS automation
  10. // classes.
  11. //
  12. // Implementation File:
  13. // Property.cpp
  14. //
  15. // Author:
  16. // Charles Stacy Harris (stacyh) 28-Feb-1997
  17. // Galen Barbee (galenb) July 1998
  18. //
  19. // Revision History:
  20. // July 1998 GalenB Maaaaaajjjjjjjjjoooooorrrr clean up
  21. //
  22. // Notes:
  23. //
  24. /////////////////////////////////////////////////////////////////////////////
  25. #ifndef __PROPERTY_H__
  26. #define __PROPERTY_H__
  27. #ifndef _PROPLIST_H_
  28. #if CLUSAPI_VERSION >= 0x0500
  29. #include <PropList.h>
  30. #else
  31. #include "PropList.h"
  32. #endif // CLUSAPI_VERSION >= 0x0500
  33. #endif
  34. /////////////////////////////////////////////////////////////////////////////
  35. // Global defines
  36. /////////////////////////////////////////////////////////////////////////////
  37. #define READONLY 0x00000001 // is this property read only?
  38. #define PRIVATE 0x00000002 // is this a private property?
  39. #define MODIFIED 0x00000004 // has this property been modified?
  40. #define USEDEFAULT 0x00000008 // this property has been deleted.
  41. #ifndef __PROPERTYVALUE_H__
  42. #include "PropertyValue.h"
  43. #endif
  44. /////////////////////////////////////////////////////////////////////////////
  45. // Forward Class Declarations
  46. /////////////////////////////////////////////////////////////////////////////
  47. class CClusProperty;
  48. class CClusProperties;
  49. class CClusterObject;
  50. /////////////////////////////////////////////////////////////////////////////
  51. //++
  52. //
  53. // class CClusProperty
  54. //
  55. // Description:
  56. // Cluster Property Automation Class.
  57. //
  58. // Inheritance:
  59. // IDispatchImpl< ISClusProperty, &IID_ISClusProperty, &LIBID_MSClusterLib, MAJORINTERFACEVER, MINORINTERFACEVER >,
  60. // CSupportErrorInfo
  61. // CComObjectRootEx< CComSingleThreadModel >
  62. // CComCoClass< CClusProperty, &CLSID_ClusProperty >
  63. //
  64. //--
  65. /////////////////////////////////////////////////////////////////////////////
  66. class ATL_NO_VTABLE CClusProperty :
  67. public IDispatchImpl< ISClusProperty, &IID_ISClusProperty, &LIBID_MSClusterLib, MAJORINTERFACEVER, MINORINTERFACEVER >,
  68. public CSupportErrorInfo,
  69. public CComObjectRootEx< CComSingleThreadModel >,
  70. public CComCoClass< CClusProperty, &CLSID_ClusProperty >
  71. {
  72. typedef CComObjectRootEx< CComSingleThreadModel > BaseComClass;
  73. public:
  74. CClusProperty( void );
  75. ~CClusProperty( void );
  76. BEGIN_COM_MAP(CClusProperty)
  77. COM_INTERFACE_ENTRY(IDispatch)
  78. COM_INTERFACE_ENTRY(ISClusProperty)
  79. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  80. END_COM_MAP()
  81. DECLARE_NOT_AGGREGATABLE(CClusProperty)
  82. DECLARE_NO_REGISTRY()
  83. private:
  84. DWORD m_dwFlags;
  85. CComBSTR m_bstrName;
  86. CComObject< CClusPropertyValues > * m_pValues;
  87. HRESULT HrBinaryCompare( IN const CComVariant rvarOldValue, IN const VARIANT & rvarValue, OUT BOOL * pbEqual );
  88. HRESULT HrCoerceVariantType( IN CLUSTER_PROPERTY_FORMAT cpfFormat, IN OUT VARIANT & rvarValue );
  89. HRESULT HrConvertVariantTypeToClusterFormat(
  90. IN const VARIANT & rvar,
  91. IN VARTYPE varType,
  92. OUT CLUSTER_PROPERTY_FORMAT * pcpfFormat
  93. );
  94. HRESULT HrCreateValuesCollection( IN const CClusPropValueList & pvlValue );
  95. HRESULT HrCreateValuesCollection(
  96. IN VARIANT varValue,
  97. IN CLUSTER_PROPERTY_TYPE cptType,
  98. IN CLUSTER_PROPERTY_FORMAT cpfFormat
  99. );
  100. HRESULT HrSaveBinaryProperty( IN CComObject< CClusPropertyValue > * pPropValue, IN const VARIANT & rvarValue );
  101. public:
  102. HRESULT Create( IN BSTR bstrName, IN VARIANT varValue, IN BOOL bPrivate, IN BOOL bReadOnly );
  103. HRESULT Create(
  104. IN BSTR bstrName,
  105. IN const CClusPropValueList & varValue,
  106. IN BOOL bPrivate,
  107. IN BOOL bReadOnly
  108. );
  109. STDMETHODIMP get_Name( OUT BSTR * pbstrName );
  110. STDMETHODIMP put_Name( IN BSTR bstrName );
  111. STDMETHODIMP get_Type( OUT CLUSTER_PROPERTY_TYPE * pcptType );
  112. STDMETHODIMP put_Type( IN CLUSTER_PROPERTY_TYPE cptType );
  113. STDMETHODIMP get_Value( OUT VARIANT * pvarValue );
  114. STDMETHODIMP put_Value( IN VARIANT varValue );
  115. STDMETHODIMP get_Format( OUT CLUSTER_PROPERTY_FORMAT * pcpfFormat );
  116. STDMETHODIMP put_Format( IN CLUSTER_PROPERTY_FORMAT cpfFormat );
  117. STDMETHODIMP get_Length( OUT long * plLength );
  118. STDMETHODIMP get_ValueCount( OUT long * plCount );
  119. STDMETHODIMP get_Values( OUT ISClusPropertyValues ** ppClusterPropertyValues );
  120. STDMETHODIMP get_ReadOnly( OUT VARIANT * pvarReadOnly );
  121. STDMETHODIMP get_Private( OUT VARIANT * pvarPrivate );
  122. STDMETHODIMP get_Common( OUT VARIANT * pvarCommon );
  123. STDMETHODIMP get_Modified( OUT VARIANT * pvarModified );
  124. BOOL Modified( void ) const { return ( m_dwFlags & MODIFIED ); }
  125. BOOL Modified( BOOL bModified );
  126. const BSTR Name( void ) const { return m_bstrName; }
  127. DWORD CbLength( void ) const { return (*m_pValues)[ 0 ]->CbLength(); }
  128. const CComVariant & Value( void ) const { return (*m_pValues)[ 0 ]->Value(); }
  129. const CComObject< CClusPropertyValues > & Values( void ) const { return *m_pValues; }
  130. STDMETHODIMP UseDefaultValue( void );
  131. BOOL IsDefaultValued( void ) const { return ( m_dwFlags & USEDEFAULT ); };
  132. }; //*** Class CClusProperty
  133. /////////////////////////////////////////////////////////////////////////////
  134. //++
  135. //
  136. // class CClusProperties
  137. //
  138. // Description:
  139. // Cluster Properties Collection Automation Class.
  140. //
  141. // Inheritance:
  142. // IDispatchImpl< ISClusProperties, &IID_ISClusProperties, &LIBID_MSClusterLib, MAJORINTERFACEVER, MINORINTERFACEVER >
  143. // CSupportErrorInfo
  144. // CComObjectRootEx< CComSingleThreadModel >
  145. // CComCoClass< CClusProperties, &CLSID_ClusProperties >
  146. //
  147. //--
  148. /////////////////////////////////////////////////////////////////////////////
  149. class ATL_NO_VTABLE CClusProperties :
  150. public IDispatchImpl< ISClusProperties, &IID_ISClusProperties, &LIBID_MSClusterLib, MAJORINTERFACEVER, MINORINTERFACEVER >,
  151. public CSupportErrorInfo,
  152. public CComObjectRootEx< CComSingleThreadModel >,
  153. public CComCoClass< CClusProperties, &CLSID_ClusProperties >
  154. {
  155. typedef CComObjectRootEx< CComSingleThreadModel > BaseComClass;
  156. public:
  157. typedef std::vector< CComObject< CClusProperty > * > CClusPropertyVector;
  158. CClusProperties( void );
  159. ~CClusProperties( void );
  160. BEGIN_COM_MAP(CClusProperties)
  161. COM_INTERFACE_ENTRY(IDispatch)
  162. COM_INTERFACE_ENTRY(ISClusProperties)
  163. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  164. END_COM_MAP()
  165. DECLARE_NOT_AGGREGATABLE(CClusProperties)
  166. DECLARE_NO_REGISTRY()
  167. void Clear( void );
  168. private:
  169. CClusPropertyVector m_Properties;
  170. CClusterObject * m_pcoParent;
  171. DWORD m_dwFlags;
  172. HRESULT FindItem( IN LPWSTR lpszPropName, OUT UINT * pnIndex );
  173. HRESULT FindItem( IN ISClusProperty * pProperty, OUT UINT * pnIndex );
  174. HRESULT GetIndex( IN VARIANT varIndex, OUT UINT * pnIndex );
  175. HRESULT HrFillPropertyVector( IN OUT CClusPropList & PropList );
  176. // HRESULT RemoveAt( IN size_t nPos );
  177. public:
  178. HRESULT Create( IN CClusterObject * pcoParent, IN BOOL bPrivateProps, IN BOOL bReadOnly );
  179. STDMETHODIMP get_Count( OUT long * plCount );
  180. STDMETHODIMP get_Item( IN VARIANT varIndex, OUT ISClusProperty ** ppProperty );
  181. STDMETHODIMP get__NewEnum( OUT IUnknown ** ppunk );
  182. STDMETHODIMP CreateItem( IN BSTR bstrName, VARIANT varValue, OUT ISClusProperty ** ppProperty );
  183. STDMETHODIMP UseDefaultValue( IN VARIANT varIndex );
  184. STDMETHODIMP Refresh( void );
  185. STDMETHODIMP SaveChanges( OUT VARIANT * pvarStatusCode );
  186. STDMETHODIMP get_ReadOnly( OUT VARIANT * pvarReadOnly );
  187. STDMETHODIMP get_Private( OUT VARIANT * pvarPrivate );
  188. STDMETHODIMP get_Common( OUT VARIANT * pvarCommon );
  189. STDMETHODIMP get_Modified( OUT VARIANT * pvarModified );
  190. }; //*** Class CClusProperties
  191. HRESULT HrSafeArraySizeof( SAFEARRAY * psa, unsigned int nDimension, long * pcElements );
  192. #endif // __PROPERTY_H__