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.

320 lines
7.7 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation
  4. //
  5. // nvalue.h
  6. //
  7. // alanbos 27-Mar-00 Created.
  8. //
  9. // General purpose include file.
  10. //
  11. //***************************************************************************
  12. #ifndef _NVALUE_H_
  13. #define _NVALUE_H_
  14. //***************************************************************************
  15. //
  16. // CLASS NAME:
  17. //
  18. // CSWbemNamedValueSet
  19. //
  20. // DESCRIPTION:
  21. //
  22. // Implements the ISWbemNamedValueSetE interface.
  23. //
  24. //***************************************************************************
  25. class CSWbemNamedValueSet : public ISWbemNamedValueSet,
  26. public ISWbemInternalContext,
  27. public IObjectSafety,
  28. public ISupportErrorInfo,
  29. public IProvideClassInfo
  30. {
  31. private:
  32. class CContextDispatchHelp : public CDispatchHelp
  33. {
  34. public:
  35. HRESULT HandleError (
  36. DISPID dispidMember,
  37. unsigned short wFlags,
  38. DISPPARAMS FAR* pdispparams,
  39. VARIANT FAR* pvarResult,
  40. UINT FAR* puArgErr,
  41. HRESULT hRes
  42. );
  43. };
  44. CSWbemServices *m_pSWbemServices;
  45. IWbemContext *m_pIWbemContext;
  46. CContextDispatchHelp m_Dispatch;
  47. CWbemPathCracker *m_pCWbemPathCracker;
  48. bool m_bMutable;
  49. void BuildContextFromKeyList ();
  50. HRESULT SetValueIntoContext (BSTR bsName, VARIANT *pVal, ULONG lFlags);
  51. protected:
  52. long m_cRef; //Object reference count
  53. public:
  54. CSWbemNamedValueSet (void);
  55. CSWbemNamedValueSet (CSWbemServices *pService, IWbemContext *pIWbemContext);
  56. CSWbemNamedValueSet (CWbemPathCracker *pCWbemPathCracker, bool bMutable = true);
  57. ~CSWbemNamedValueSet (void);
  58. //Non-delegating object IUnknown
  59. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  60. STDMETHODIMP_(ULONG) AddRef(void);
  61. STDMETHODIMP_(ULONG) Release(void);
  62. // IDispatch
  63. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
  64. {return m_Dispatch.GetTypeInfoCount(pctinfo);}
  65. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  66. {return m_Dispatch.GetTypeInfo(itinfo, lcid, pptinfo);}
  67. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  68. UINT cNames, LCID lcid, DISPID* rgdispid)
  69. {return m_Dispatch.GetIDsOfNames(riid, rgszNames, cNames,
  70. lcid,
  71. rgdispid);}
  72. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  73. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  74. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  75. {return m_Dispatch.Invoke(dispidMember, riid, lcid, wFlags,
  76. pdispparams, pvarResult, pexcepinfo, puArgErr);}
  77. // ISWbemInternalContext
  78. STDMETHODIMP GetIWbemContext (IWbemContext **pContext);
  79. // Collection methods
  80. HRESULT STDMETHODCALLTYPE get__NewEnum
  81. (
  82. /*[out]*/ IUnknown **ppUnk
  83. );
  84. HRESULT STDMETHODCALLTYPE get_Count
  85. (
  86. /*[out]*/ long *plCount
  87. );
  88. HRESULT STDMETHODCALLTYPE Add
  89. (
  90. /*[in]*/ BSTR Name,
  91. /*[in]*/ VARIANT *pValue,
  92. /*[in]*/ long lFlags,
  93. /*[out]*/ ISWbemNamedValue **ppNamedValue
  94. );
  95. HRESULT STDMETHODCALLTYPE Item
  96. (
  97. /*[in]*/ BSTR Name,
  98. /*[in]*/ long lFlags,
  99. /*[out]*/ ISWbemNamedValue **ppValue
  100. );
  101. HRESULT STDMETHODCALLTYPE Remove
  102. (
  103. /*[in]*/ BSTR Name,
  104. /*[in]*/ long lFlags
  105. );
  106. // ISWbemNamedValueSet methods
  107. HRESULT STDMETHODCALLTYPE Clone
  108. (
  109. /*[out]*/ ISWbemNamedValueSet **pNewCopy
  110. );
  111. HRESULT STDMETHODCALLTYPE DeleteAll
  112. (
  113. );
  114. // CSWbemNamedValueSet methods
  115. HRESULT STDMETHODCALLTYPE BeginEnumeration
  116. (
  117. );
  118. HRESULT STDMETHODCALLTYPE Next
  119. (
  120. /*[in]*/ long lFlags,
  121. /*[out]*/ ISWbemNamedValue **ppNamedValue
  122. );
  123. // IObjectSafety methods
  124. HRESULT STDMETHODCALLTYPE SetInterfaceSafetyOptions
  125. (
  126. /* [in] */ REFIID riid,
  127. /* [in] */ DWORD dwOptionSetMask,
  128. /* [in] */ DWORD dwEnabledOptions
  129. )
  130. {
  131. return (dwOptionSetMask & dwEnabledOptions) ? E_FAIL : S_OK;
  132. }
  133. HRESULT STDMETHODCALLTYPE GetInterfaceSafetyOptions(
  134. /* [in] */ REFIID riid,
  135. /* [out] */ DWORD __RPC_FAR *pdwSupportedOptions,
  136. /* [out] */ DWORD __RPC_FAR *pdwEnabledOptions
  137. )
  138. {
  139. if (pdwSupportedOptions) *pdwSupportedOptions = 0;
  140. if (pdwEnabledOptions) *pdwEnabledOptions = 0;
  141. return S_OK;
  142. }
  143. // ISupportErrorInfo methods
  144. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  145. (
  146. /* [in] */ REFIID riid
  147. );
  148. // IProvideClassInfo methods
  149. HRESULT STDMETHODCALLTYPE GetClassInfo
  150. (
  151. /* [in,out] */ ITypeInfo **ppTI
  152. )
  153. {
  154. return m_Dispatch.GetClassInfo (ppTI);
  155. };
  156. // Other methods
  157. static IWbemContext *GetIWbemContext (IDispatch *pDispatch, IServiceProvider *pServiceProvider = NULL);
  158. static IDispatch *GetSWbemContext(IDispatch *pDispatch,
  159. IServiceProvider *pServiceProvider, CSWbemServices *pServices);
  160. IWbemContext *GetIWbemContext ()
  161. {
  162. m_pIWbemContext->AddRef ();
  163. return m_pIWbemContext;
  164. }
  165. CWbemPathCracker *GetWbemPathCracker ()
  166. {
  167. CWbemPathCracker *pCWbemPathCracker = NULL;
  168. if (m_pCWbemPathCracker)
  169. {
  170. pCWbemPathCracker = m_pCWbemPathCracker;
  171. pCWbemPathCracker->AddRef ();
  172. }
  173. return pCWbemPathCracker;
  174. }
  175. };
  176. //***************************************************************************
  177. //
  178. // CLASS NAME:
  179. //
  180. // CSWbemNamedValue
  181. //
  182. // DESCRIPTION:
  183. //
  184. // Implements the ISWbemNamedValue interface.
  185. //
  186. //***************************************************************************
  187. class CSWbemNamedValue : public ISWbemNamedValue,
  188. public ISupportErrorInfo,
  189. public IProvideClassInfo
  190. {
  191. private:
  192. class CNamedValueDispatchHelp : public CDispatchHelp
  193. {
  194. public:
  195. HRESULT HandleError (
  196. DISPID dispidMember,
  197. unsigned short wFlags,
  198. DISPPARAMS FAR* pdispparams,
  199. VARIANT FAR* pvarResult,
  200. UINT FAR* puArgErr,
  201. HRESULT hRes
  202. );
  203. bool HandleNulls (
  204. DISPID dispidMember,
  205. unsigned short wFlags)
  206. {
  207. return false;
  208. }
  209. };
  210. CSWbemServices *m_pSWbemServices;
  211. CSWbemNamedValueSet *m_pCSWbemNamedValueSet;
  212. CNamedValueDispatchHelp m_Dispatch;
  213. BSTR m_name;
  214. bool m_bMutable;
  215. protected:
  216. long m_cRef; //Object reference count
  217. public:
  218. CSWbemNamedValue (CSWbemServices *pService, CSWbemNamedValueSet *pCSWbemNamedValueSet,
  219. BSTR name, bool bMutable = true);
  220. ~CSWbemNamedValue (void);
  221. //Non-delegating object IUnknown
  222. STDMETHODIMP QueryInterface(REFIID, LPVOID*);
  223. STDMETHODIMP_(ULONG) AddRef(void);
  224. STDMETHODIMP_(ULONG) Release(void);
  225. // IDispatch
  226. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo)
  227. {return m_Dispatch.GetTypeInfoCount(pctinfo);}
  228. STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
  229. {return m_Dispatch.GetTypeInfo(itinfo, lcid, pptinfo);}
  230. STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR** rgszNames,
  231. UINT cNames, LCID lcid, DISPID* rgdispid)
  232. {return m_Dispatch.GetIDsOfNames(riid, rgszNames, cNames,
  233. lcid,
  234. rgdispid);}
  235. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid,
  236. WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  237. EXCEPINFO* pexcepinfo, UINT* puArgErr)
  238. {return m_Dispatch.Invoke(dispidMember, riid, lcid, wFlags,
  239. pdispparams, pvarResult, pexcepinfo, puArgErr);}
  240. // ISWbemNamedValue methods
  241. HRESULT STDMETHODCALLTYPE get_Value
  242. (
  243. /*[out]*/ VARIANT *value
  244. );
  245. HRESULT STDMETHODCALLTYPE put_Value
  246. (
  247. /*[in]*/ VARIANT *value
  248. );
  249. HRESULT STDMETHODCALLTYPE get_Name
  250. (
  251. /*[out]*/ BSTR *name
  252. );
  253. // ISupportErrorInfo methods
  254. HRESULT STDMETHODCALLTYPE InterfaceSupportsErrorInfo
  255. (
  256. /* [in] */ REFIID riid
  257. );
  258. // IProvideClassInfo methods
  259. HRESULT STDMETHODCALLTYPE GetClassInfo
  260. (
  261. /* [in,out] */ ITypeInfo **ppTI
  262. )
  263. {
  264. return m_Dispatch.GetClassInfo (ppTI);
  265. };
  266. };
  267. #endif