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.

168 lines
4.4 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1997 Microsoft Corporation. All Rights Reserved.
  5. Component: MetaUtil object
  6. File: PropCol.h
  7. Owner: t-BrianM
  8. This file contains the headers for the property collection and
  9. property object.
  10. ===================================================================*/
  11. #ifndef __PROPCOL_H_
  12. #define __PROPCOL_H_
  13. #if _MSC_VER >= 1000
  14. #pragma once
  15. #endif // _MSC_VER >= 1000
  16. #include "resource.h" // main symbols
  17. /*
  18. * C P r o p e r t y C o l l e c t i o n
  19. *
  20. * Implements property collections
  21. */
  22. class CPropertyCollection :
  23. public IDispatchImpl<IPropertyCollection, &IID_IPropertyCollection, &LIBID_MetaUtil>,
  24. public ISupportErrorInfo,
  25. public CComObjectRoot
  26. {
  27. public:
  28. CPropertyCollection();
  29. HRESULT Init(const CComPtr<IMSAdminBase> &pIMeta, CMetaSchemaTable *pCSchemaTable, LPTSTR tszKey);
  30. ~CPropertyCollection();
  31. BEGIN_COM_MAP(CPropertyCollection)
  32. COM_INTERFACE_ENTRY(IDispatch)
  33. COM_INTERFACE_ENTRY(IPropertyCollection)
  34. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  35. END_COM_MAP()
  36. DECLARE_NOT_AGGREGATABLE(CPropertyCollection)
  37. // ISupportsErrorInfo
  38. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  39. // IPropertyCollection
  40. STDMETHOD(get_Count)(/*[out, retval]*/ long *plReturn);
  41. STDMETHOD(get_Item)(/*[in]*/ long lIndex, /*[out, retval]*/ LPDISPATCH *ppIReturn);
  42. STDMETHOD(get__NewEnum)(/*[out, retval]*/ LPUNKNOWN *ppIReturn);
  43. STDMETHOD(Get)(/*[in]*/ VARIANT varId, /*[out, retval]*/ IProperty **ppIReturn);
  44. STDMETHOD(Add)(/*[in]*/ VARIANT varId, /*[out, retval]*/ IProperty **ppIReturn);
  45. STDMETHOD(Remove)(/*[in]*/ VARIANT varId);
  46. private:
  47. LPTSTR m_tszKey;
  48. // Pointer to IMSAdminBase so we don't have to recreate it multiple times
  49. CComPtr<IMSAdminBase> m_pIMeta;
  50. CMetaSchemaTable *m_pCSchemaTable;
  51. };
  52. /*
  53. * C P r o p e r t y E n u m
  54. *
  55. * Implements property enumberations
  56. */
  57. class CPropertyEnum :
  58. public IEnumVARIANT,
  59. public CComObjectRoot
  60. {
  61. public:
  62. CPropertyEnum();
  63. HRESULT Init(const CComPtr<IMSAdminBase> &pIMeta, CMetaSchemaTable *pCSchemaTable, LPCTSTR tszKey, int iIndex);
  64. ~CPropertyEnum();
  65. BEGIN_COM_MAP(CPropertyEnum)
  66. COM_INTERFACE_ENTRY(IEnumVARIANT)
  67. END_COM_MAP()
  68. DECLARE_NOT_AGGREGATABLE(CPropertyEnum)
  69. //IEnumVARIANT
  70. STDMETHOD(Next)(unsigned long ulNumToGet,
  71. VARIANT FAR* rgvarDest,
  72. unsigned long FAR* pulNumGot);
  73. STDMETHOD(Skip)(unsigned long ulNumToSkip);
  74. STDMETHOD(Reset)();
  75. STDMETHOD(Clone)(IEnumVARIANT FAR* FAR* ppIReturn);
  76. private:
  77. int m_iIndex;
  78. LPTSTR m_tszKey;
  79. // Pointer to IMSAdminBase so we don't have to recreate it multiple times
  80. CComPtr<IMSAdminBase> m_pIMeta;
  81. CMetaSchemaTable *m_pCSchemaTable;
  82. };
  83. /*
  84. * C P r o p e r t y
  85. *
  86. * Implements property objects.
  87. */
  88. class CProperty :
  89. public IDispatchImpl<IProperty, &IID_IProperty, &LIBID_MetaUtil>,
  90. public ISupportErrorInfo,
  91. public CComObjectRoot
  92. {
  93. public:
  94. CProperty();
  95. HRESULT Init(const CComPtr<IMSAdminBase> &pIMeta, CMetaSchemaTable *pCSchemaTable, LPCTSTR tszKey, DWORD dwId, BOOL bCreate);
  96. HRESULT Init(const CComPtr<IMSAdminBase> &pIMeta, CMetaSchemaTable *pCSchemaTable, LPCTSTR tszKey, METADATA_RECORD *mdr);
  97. ~CProperty();
  98. BEGIN_COM_MAP(CProperty)
  99. COM_INTERFACE_ENTRY(IDispatch)
  100. COM_INTERFACE_ENTRY(IProperty)
  101. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  102. END_COM_MAP()
  103. DECLARE_NOT_AGGREGATABLE(CProperty)
  104. // ISupportsErrorInfo
  105. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  106. // IProperty
  107. STDMETHOD(get_Id)(/*[out, retval]*/ long *plId);
  108. STDMETHOD(get_Name)(/*[out, retval]*/ BSTR *pbstrName);
  109. STDMETHOD(get_Attributes)(/*[out, retval]*/ long *plAttributes);
  110. STDMETHOD(put_Attributes)(/*[in]*/ long plAttributes);
  111. STDMETHOD(get_UserType)(/*[out, retval]*/ long *plAttributes);
  112. STDMETHOD(put_UserType)(/*[in]*/ long plAttributes);
  113. STDMETHOD(get_DataType)(/*[out, retval]*/ long *plAttributes);
  114. STDMETHOD(put_DataType)(/*[in]*/ long plAttributes);
  115. STDMETHOD(get_Data)(/*[out, retval]*/ VARIANT *pvarData);
  116. STDMETHOD(put_Data)(/*[in]*/ VARIANT varData);
  117. STDMETHOD(Write)();
  118. private:
  119. LPTSTR m_tszKey;
  120. DWORD m_dwId;
  121. DWORD m_dwAttributes;
  122. DWORD m_dwUserType;
  123. DWORD m_dwDataType;
  124. VARIANT m_varData;
  125. // Pointer to IMSAdminBase so we don't have to recreate it multiple times
  126. CComPtr<IMSAdminBase> m_pIMeta;
  127. CMetaSchemaTable *m_pCSchemaTable;
  128. HRESULT SetDataToVar(BYTE *pbData, DWORD dwDataLen);
  129. HRESULT GetDataFromVar(BYTE * &pbData, DWORD &dwDataLen);
  130. };
  131. #endif //ifndef __PROPCOL_H_