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.

170 lines
4.2 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 2000 Microsoft Corporation
  4. //
  5. // scope.h
  6. //
  7. // alanbos 16-Feb-00 Created.
  8. //
  9. // Path component helper implementation.
  10. //
  11. //***************************************************************************
  12. #ifndef _PATHCMPS_H_
  13. #define _PATHCMPS_H_
  14. class CSWbemObjectPathComponents;
  15. class CEnumObjectPathComponent;
  16. //***************************************************************************
  17. //
  18. // CLASS NAME:
  19. //
  20. // CSWbemObjectPathComponents
  21. //
  22. // DESCRIPTION:
  23. //
  24. // Implements the ISWbemObjectPathComponents interface.
  25. //
  26. //***************************************************************************
  27. class CSWbemObjectPathComponents : public ISWbemObjectPathComponents,
  28. public ISupportErrorInfo,
  29. public IProvideClassInfo
  30. {
  31. friend CEnumObjectPathComponent;
  32. private:
  33. CDispatchHelp m_Dispatch;
  34. CWbemPathCracker *m_pCWbemPathCracker;
  35. bool m_bMutable;
  36. protected:
  37. long m_cRef; //Object reference count
  38. public:
  39. CSWbemObjectPathComponents(CWbemPathCracker *pCWbemPathCracker, bool bMutable = true);
  40. CSWbemObjectPathComponents (const BSTR & bsPath, bool bMutable = true);
  41. virtual ~CSWbemObjectPathComponents(void);
  42. //Non-delegating object IUnknown
  43. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  44. STDMETHODIMP_(ULONG) AddRef(void);
  45. STDMETHODIMP_(ULONG) Release(void);
  46. // IDispatch
  47. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
  48. {return m_Dispatch.GetTypeInfoCount(pctinfo);}
  49. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  50. {return m_Dispatch.GetTypeInfo(itinfo, lcid, pptinfo);}
  51. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  52. UINT cNames, LCID lcid, DISPID* rgdispid)
  53. {return m_Dispatch.GetIDsOfNames(riid, rgszNames, cNames,
  54. lcid,
  55. rgdispid);}
  56. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  57. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  58. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  59. {return m_Dispatch.Invoke(dispidMember, riid, lcid, wFlags,
  60. pdispparams, pvarResult, pexcepinfo, puArgErr);}
  61. // ISWbemObjectPathComponents methods
  62. HRESULT STDMETHODCALLTYPE get__NewEnum (
  63. /*[out, retval]*/ IUnknown **pUnk
  64. );
  65. HRESULT STDMETHODCALLTYPE Item (
  66. /*[in]*/ long iIndex,
  67. /*[out, retval]*/ BSTR *bsComponent
  68. );
  69. HRESULT STDMETHODCALLTYPE get_Count (
  70. /*[out, retval]*/ long *iCount
  71. );
  72. HRESULT STDMETHODCALLTYPE Add (
  73. /*[in]*/ BSTR bsComponent,
  74. /*[in, defaultvalue(-1)]*/ long iIndex
  75. );
  76. HRESULT STDMETHODCALLTYPE Remove (
  77. /*[in]*/ long iIndex
  78. );
  79. HRESULT STDMETHODCALLTYPE DeleteAll (
  80. );
  81. HRESULT STDMETHODCALLTYPE Set (
  82. /*[in]*/ BSTR bsComponent,
  83. /*[in, defaultvalue(-1)]*/ long iIndex
  84. );
  85. // ISupportErrorInfo methods
  86. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  87. (
  88. /* [in] */ REFIID riid
  89. )
  90. {
  91. return (IID_ISWbemObjectPathComponents == riid) ? S_OK : S_FALSE;
  92. }
  93. // IProvideClassInfo methods
  94. HRESULT STDMETHODCALLTYPE GetClassInfo
  95. (
  96. /* [in] */ ITypeInfo **ppTI
  97. )
  98. {
  99. return m_Dispatch.GetClassInfo (ppTI);
  100. }
  101. };
  102. //***************************************************************************
  103. //
  104. // CLASS NAME:
  105. //
  106. // CEnumObjectPathComponent
  107. //
  108. // DESCRIPTION:
  109. //
  110. // Implements the IEnumVARIANT interface for ISWbemObjectPathComponents
  111. //
  112. //***************************************************************************
  113. class CEnumObjectPathComponent : public IEnumVARIANT
  114. {
  115. private:
  116. long m_cRef;
  117. unsigned long m_iIndex;
  118. CWbemPathCracker *m_pCWbemPathCracker;
  119. bool m_bMutable;
  120. public:
  121. CEnumObjectPathComponent (CWbemPathCracker *pCWbemPathCracker, bool bMutable = true);
  122. virtual ~CEnumObjectPathComponent (void);
  123. // Non-delegating object IUnknown
  124. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  125. STDMETHODIMP_(ULONG) AddRef(void);
  126. STDMETHODIMP_(ULONG) Release(void);
  127. // IEnumVARIANT
  128. STDMETHODIMP Next(
  129. unsigned long celt,
  130. VARIANT FAR* rgvar,
  131. unsigned long FAR* pceltFetched
  132. );
  133. STDMETHODIMP Skip(
  134. unsigned long celt
  135. );
  136. STDMETHODIMP Reset();
  137. STDMETHODIMP Clone(
  138. IEnumVARIANT **ppenum
  139. );
  140. };
  141. #endif // _SCOPE_H