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.

417 lines
12 KiB

  1. ///////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft WMIOLE DB Provider
  4. // (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // @module ROW.H | CRow base object and contained interface
  7. //
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////////
  10. #ifndef _ROW_H_
  11. #define _ROW_H_
  12. typedef enum tagROWCREATEBINDFLAG
  13. {
  14. ROWOPEN =0,ROWCREATE =1 , ROWOVERWRITE = 1
  15. }ROWCREATEBINDFLAG;
  16. typedef enum tagROWTYPE
  17. {
  18. ROW_SCOPE =0,ROW_INSTANCE =1
  19. }ROWTYPE;
  20. #include "baserowobj.h"
  21. class CImpIRowChange;
  22. class CImpIColumnsInfo;
  23. class CImpIGetSession;
  24. class CImpIRow;
  25. class CImpIScopedOperations;
  26. //class CRowFetchObj;
  27. typedef CImpIRowChange* PIMPIROWCHANGE;
  28. typedef CImpIRow* PIMPIROW;
  29. typedef CImpIGetSession* PIMPIGETSESSION;
  30. typedef CImpIScopedOperations* PIMPISCOPEDOPERATIONS;
  31. typedef CRowFetchObj* PROWFETCHOBJ;
  32. class CRow : public CBaseRowObj
  33. {
  34. friend class CImpIRowChange;
  35. friend class CImpIRow;
  36. friend class CImpIGetSession;
  37. friend class CImpIScopedOperations;
  38. friend class CRowFetchObj;
  39. friend class CDBSession;
  40. PIMPIROW m_pIRow; // Contained IRow
  41. PIMPIGETSESSION m_pIGetSession; // Contained IGetSession
  42. PIMPIROWCHANGE m_pIRowChange; // Contained IRowChange;
  43. PIMPISCOPEDOPERATIONS m_pIScopedOperations; // Contained IScopedOperations
  44. UDWORD m_dwStatus; // status word for the entire cursor
  45. cRowColumnInfoMemMgr * m_pRowColumns; // column information for all the columns other than
  46. // than the source rowset
  47. WCHAR * m_strURL; // URL of the row
  48. WCHAR * m_strKey; // Key of the row
  49. CWbemClassInstanceWrapper * m_pInstance; // Pointer to the instance corresponding to the row
  50. BOOL m_bHelperFunctionCreated; // flag to indicate whethe helper function are created or not
  51. BOOL m_bClassChanged; // flag which stores if the instance being represented, is
  52. // is of different type ( belong to different class) as
  53. // compared to the rowset which created it. This will
  54. // have meaning only when row is created from rowset
  55. CRowset * m_pSourcesRowset; // Pointer to the rowset , if it this row is created by the row
  56. ROWTYPE m_rowType; // type of the object which the row represents
  57. void InitVars();
  58. HRESULT GetColumns(DBORDINAL cColumns,DBCOLUMNACCESS rgColumns[ ]);
  59. HRESULT GetColumnsFromRowset(DBORDINAL cColumns,DBCOLUMNACCESS rgColumns[]);
  60. HRESULT UpdateRow(DBORDINAL cColumns,DBCOLUMNACCESS rgColumns[ ]);
  61. HRESULT UpdateColumnsFromRowset(DBORDINAL cColumns,DBCOLUMNACCESS rgColumns[ ]);
  62. HRESULT GetColumnInfo(DBORDINAL* pcColumns, DBCOLUMNINFO** prgInfo,WCHAR** ppStringsBuffer);
  63. HRESULT GetRowColumnInfo();
  64. HRESULT GatherColumnInfo();
  65. HRESULT GetColumnInfo();
  66. HRESULT GetColumnData(DBCOLUMNACCESS &col);
  67. HRESULT SetColumnData(DBCOLUMNACCESS &col , BOOL bNewRow = FALSE);
  68. HRESULT GetRowData(DBORDINAL cColumns,DBCOLUMNACCESS rgColumns[]);
  69. HRESULT SetRowData(DBORDINAL cColumns,DBCOLUMNACCESS rgColumns[]);
  70. HRESULT OpenChild(IUnknown *pUnkOuter,WCHAR *strColName ,REFIID riid, IUnknown **ppUnk,BOOL bIsChildRowset);
  71. WCHAR * GetPropertyNameFromColName(WCHAR *pColName);
  72. HRESULT GetEmbededInstancePtrAndSetMapClass(CURLParser *urlParser);
  73. HRESULT GetChildRowet( IUnknown *pUnkOuter,
  74. WCHAR *strColName,
  75. DBPROPSET *rgPropertySets,
  76. ULONG cPropSets,
  77. REFIID riid,
  78. IUnknown **ppUnk);
  79. HRESULT GetChildRow(IUnknown *pUnkOuter,
  80. WCHAR *strColName,
  81. DBPROPSET *rgPropertySets,
  82. ULONG cPropSets,
  83. REFIID riid,
  84. IUnknown **ppUnk);
  85. HRESULT CreateNewRow(CWbemClassInstanceWrapper **pNewInst);
  86. HRESULT AllocateInterfacePointers();
  87. HRESULT InitializeWmiOledbMap(LPWSTR strPath,
  88. LPWSTR strTableID ,
  89. DWORD dwFlags);
  90. HRESULT AddInterfacesForISupportErrorInfo();
  91. HRESULT OpenRow(LPCOLESTR pwszURL,IUnknown * pUnkOuter,REFIID riid,IUnknown** ppOut);
  92. HRESULT OpenRowset(LPCOLESTR pwszURL,
  93. IUnknown * pUnkOuter,
  94. REFIID riid,
  95. BOOL bContainer ,
  96. IUnknown** ppOut,
  97. ULONG cPropertySets = 0,
  98. DBPROPSET __RPC_FAR rgPropertySets[] = NULL);
  99. HRESULT SetRowProperties(const ULONG cPropertySets, const DBPROPSET rgPropertySets[] );
  100. HRESULT Delete(LPCOLESTR lpszURL,DWORD dwDeleteFlags,DBSTATUS &dbStatus);
  101. HRESULT MoveObjects(WCHAR * pStrDstURL,WCHAR * pstrSrcURL, WCHAR *& pstrUrl,DBSTATUS &dbStatus);
  102. HRESULT CopyObjects(WCHAR * pStrDstURL,WCHAR * pstrSrcURL, WCHAR *& pNewURL,DBSTATUS &dbStatus);
  103. BOOL GetPathFromURL(BSTR &str);
  104. BOOL IsContainer();
  105. HRESULT GetIUnknownColumnValue(DBORDINAL iCol,REFIID riid,IUnknown ** ppUnk,LPCWSTR pStrColName);
  106. public:
  107. CRow(LPUNKNOWN,CRowset *pRowset,PCDBSESSION pObj,CWbemConnectionWrapper *pCon = NULL);
  108. CRow(LPUNKNOWN pUnkOuter, PCDBSESSION pObj);
  109. ~CRow();
  110. HRESULT InitRow(HROW hRow = 0,
  111. CWbemClassWrapper *pInst = NULL,
  112. ROWCREATEBINDFLAG rowCreateFlag = ROWOPEN);
  113. HRESULT InitRow(LPWSTR strPath ,
  114. LPWSTR strTableID ,
  115. DWORD dwFlags = -1,
  116. ROWCREATEBINDFLAG rowCreateFlag = ROWOPEN);
  117. HRESULT UpdateKeysForNewInstance();
  118. STDMETHODIMP QueryInterface(REFIID, LPVOID *);
  119. STDMETHODIMP_(ULONG) AddRef(void);
  120. STDMETHODIMP_(ULONG) Release(void);
  121. };
  122. class CImpIGetSession:public IGetSession
  123. {
  124. private:
  125. CRow *m_pObj;
  126. DEBUGCODE(ULONG m_cRef);
  127. public:
  128. CImpIGetSession( CRow *pObj )
  129. {
  130. DEBUGCODE(m_cRef = 0L);
  131. m_pObj = pObj;
  132. }
  133. ~CImpIGetSession()
  134. {
  135. }
  136. STDMETHODIMP_(ULONG) AddRef(void)
  137. {
  138. DEBUGCODE(InterlockedIncrement((long*)&m_cRef));
  139. return m_pObj->GetOuterUnknown()->AddRef();
  140. }
  141. STDMETHODIMP_(ULONG) Release(void)
  142. {
  143. DEBUGCODE(long lRef = InterlockedDecrement((long*)&m_cRef);
  144. if( lRef < 0 ){
  145. ASSERT("Reference count on Object went below 0!")
  146. })
  147. return m_pObj->GetOuterUnknown()->Release();
  148. }
  149. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv)
  150. {
  151. return m_pObj->GetOuterUnknown()->QueryInterface(riid, ppv);
  152. }
  153. STDMETHODIMP GetSession(REFIID riid,IUnknown ** ppSession);
  154. };
  155. class CImpIRow:public IRow
  156. {
  157. private:
  158. CRow *m_pObj;
  159. DEBUGCODE(ULONG m_cRef);
  160. public:
  161. CImpIRow( CRow *pObj )
  162. {
  163. DEBUGCODE(m_cRef = 0L);
  164. m_pObj = pObj;
  165. }
  166. ~CImpIRow()
  167. {
  168. }
  169. STDMETHODIMP_(ULONG) AddRef(void)
  170. {
  171. DEBUGCODE(InterlockedIncrement((long*)&m_cRef));
  172. return m_pObj->GetOuterUnknown()->AddRef();
  173. }
  174. STDMETHODIMP_(ULONG) Release(void)
  175. {
  176. DEBUGCODE(long lRef = InterlockedDecrement((long*)&m_cRef);
  177. if( lRef < 0 ){
  178. ASSERT("Reference count on Object went below 0!")
  179. })
  180. return m_pObj->GetOuterUnknown()->Release();
  181. }
  182. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv)
  183. {
  184. return m_pObj->GetOuterUnknown()->QueryInterface(riid, ppv);
  185. }
  186. STDMETHODIMP GetColumns(DBORDINAL cColumns,DBCOLUMNACCESS rgColumns[ ]);
  187. STDMETHODIMP GetSourceRowset(REFIID riid,IUnknown ** ppRowset,HROW *phRow);
  188. STDMETHODIMP Open( IUnknown * pUnkOuter,
  189. DBID * pColumnID,
  190. REFGUID rguidColumnType,
  191. DWORD dwFlags,
  192. REFIID riid,
  193. IUnknown ** ppUnk);
  194. };
  195. class CImpIRowChange:public IRowChange
  196. {
  197. private:
  198. CRow *m_pObj;
  199. DEBUGCODE(ULONG m_cRef);
  200. public:
  201. CImpIRowChange( CRow *pObj )
  202. {
  203. DEBUGCODE(m_cRef = 0L);
  204. m_pObj = pObj;
  205. }
  206. ~CImpIRowChange()
  207. {
  208. }
  209. STDMETHODIMP_(ULONG) AddRef(void)
  210. {
  211. DEBUGCODE(InterlockedIncrement((long*)&m_cRef));
  212. return m_pObj->GetOuterUnknown()->AddRef();
  213. }
  214. STDMETHODIMP_(ULONG) Release(void)
  215. {
  216. DEBUGCODE(long lRef = InterlockedDecrement((long*)&m_cRef);
  217. if( lRef < 0 ){
  218. ASSERT("Reference count on Object went below 0!")
  219. })
  220. return m_pObj->GetOuterUnknown()->Release();
  221. }
  222. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv)
  223. {
  224. return m_pObj->GetOuterUnknown()->QueryInterface(riid, ppv);
  225. }
  226. STDMETHODIMP SetColumns(DBORDINAL cColumns,DBCOLUMNACCESS rgColumns[ ]);
  227. };
  228. class CImpIScopedOperations:public IScopedOperations
  229. {
  230. private:
  231. CRow *m_pObj;
  232. DEBUGCODE(ULONG m_cRef);
  233. BOOL CheckBindURLFlags(DBBINDURLFLAG dwBindURLFlags , REFGUID rguid); // Function to check if proper flags are
  234. // are set for the require object
  235. // To check if URL Matches the requested type of object
  236. HRESULT CheckIfProperURL(LPOLESTR & lpszURL,REFGUID rguid);
  237. HRESULT BindURL(IUnknown * pUnkOuter,
  238. LPCOLESTR pwszURL,
  239. DBBINDURLFLAG dwBindURLFlags,
  240. REFGUID rguid,
  241. REFIID riid,
  242. DBIMPLICITSESSION * pImplSession,
  243. DBBINDURLSTATUS * pdwBindStatus,
  244. IUnknown ** ppUnk);
  245. // Copy or move objects from one scope/container to another
  246. HRESULT ManipulateObjects(DBCOUNTITEM cRows,
  247. LPCOLESTR __RPC_FAR rgpwszSourceURLs[ ],
  248. LPCOLESTR __RPC_FAR rgpwszDestURLs[ ],
  249. DBSTATUS __RPC_FAR rgdwStatus[ ],
  250. LPOLESTR __RPC_FAR rgpwszNewURLs[ ],
  251. OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer,
  252. BOOL bMoveObjects);
  253. public:
  254. CImpIScopedOperations( CRow *pObj )
  255. {
  256. DEBUGCODE(m_cRef = 0L);
  257. m_pObj = pObj;
  258. }
  259. ~CImpIScopedOperations()
  260. {
  261. }
  262. STDMETHODIMP_(ULONG) AddRef(void)
  263. {
  264. DEBUGCODE(InterlockedIncrement((long*)&m_cRef));
  265. return m_pObj->GetOuterUnknown()->AddRef();
  266. }
  267. STDMETHODIMP_(ULONG) Release(void)
  268. {
  269. DEBUGCODE(long lRef = InterlockedDecrement((long*)&m_cRef);
  270. if( lRef < 0 ){
  271. ASSERT("Reference count on Object went below 0!")
  272. })
  273. return m_pObj->GetOuterUnknown()->Release();
  274. }
  275. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv)
  276. {
  277. return m_pObj->GetOuterUnknown()->QueryInterface(riid, ppv);
  278. }
  279. STDMETHODIMP Bind(IUnknown * pUnkOuter,
  280. LPCOLESTR pwszURL,
  281. DBBINDURLFLAG dwBindURLFlags,
  282. REFGUID rguid,
  283. REFIID riid,
  284. IAuthenticate * pAuthenticate,
  285. DBIMPLICITSESSION * pImplSession,
  286. DBBINDURLSTATUS * pdwBindStatus,
  287. IUnknown ** ppUnk);
  288. STDMETHODIMP Copy(DBCOUNTITEM cRows,
  289. LPCOLESTR __RPC_FAR rgpwszSourceURLs[ ],
  290. LPCOLESTR __RPC_FAR rgpwszDestURLs[ ],
  291. DWORD dwCopyFlags,
  292. IAuthenticate __RPC_FAR *pAuthenticate,
  293. DBSTATUS __RPC_FAR rgdwStatus[ ],
  294. LPOLESTR __RPC_FAR rgpwszNewURLs[ ],
  295. OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);
  296. STDMETHODIMP Move(DBCOUNTITEM cRows,
  297. LPCOLESTR __RPC_FAR rgpwszSourceURLs[ ],
  298. LPCOLESTR __RPC_FAR rgpwszDestURLs[ ],
  299. DWORD dwMoveFlags,
  300. IAuthenticate __RPC_FAR *pAuthenticate,
  301. DBSTATUS __RPC_FAR rgdwStatus[ ],
  302. LPOLESTR __RPC_FAR rgpwszNewURLs[ ],
  303. OLECHAR __RPC_FAR *__RPC_FAR *ppStringsBuffer);
  304. STDMETHODIMP Delete(DBCOUNTITEM cRows,
  305. LPCOLESTR __RPC_FAR rgpwszURLs[ ],
  306. DWORD dwDeleteFlags,
  307. DBSTATUS __RPC_FAR rgdwStatus[ ]);
  308. STDMETHODIMP OpenRowset(IUnknown __RPC_FAR *pUnkOuter,
  309. DBID __RPC_FAR *pTableID,
  310. DBID __RPC_FAR *pIndexID,
  311. REFIID riid,
  312. ULONG cPropertySets,
  313. DBPROPSET __RPC_FAR rgPropertySets[ ],
  314. IUnknown __RPC_FAR *__RPC_FAR *ppRowset);
  315. };
  316. #endif