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.

153 lines
4.9 KiB

  1. //***************************************************************************
  2. //
  3. // (c) 1999-2001 by Microsoft Corp. All Rights Reserved.
  4. //
  5. // sqlcache.h
  6. //
  7. // cvadai 6-May-1999 created.
  8. //
  9. //***************************************************************************
  10. #ifndef _SQLUTILS_H_
  11. #define _SQLUTILS_H_
  12. #include <seqstream.h>
  13. #include <sqlcache.h>
  14. class CWmiDbSession;
  15. typedef struct STRUCTHASINSTANCES
  16. {
  17. DB_NUMERIC dClassId;
  18. DWORD dwHasInst;
  19. } STRUCTHASINSTANCES;
  20. typedef struct STRUCTINSERTCLASS
  21. {
  22. BSTR sClassName;
  23. BSTR sObjectKey;
  24. BSTR sObjectPath;
  25. DB_NUMERIC dScopeID;
  26. DB_NUMERIC dParentClassId;
  27. int iClassState;
  28. BYTE *pClassBuff;
  29. int iClassFlags;
  30. int iInsertFlags;
  31. DB_NUMERIC dRetVal;
  32. } STRUCTINSERTCLASS;
  33. typedef struct STRUCTINSERTCLASSDATA
  34. {
  35. DB_NUMERIC dClassId;
  36. BSTR sPropName;
  37. int iCimType;
  38. int iStorageType;
  39. BSTR sValue;
  40. DB_NUMERIC dRefClassId;
  41. int iPropID;
  42. int iFlags;
  43. int iFlavor;
  44. int iRetVal;
  45. int iKnownID;
  46. BOOL bIsKey;
  47. } STRUCTINSERTCLASSDATA;
  48. typedef struct STRUCTOBJECTEXISTS
  49. {
  50. DB_NUMERIC dObjectId;
  51. DB_NUMERIC dClassId;
  52. DB_NUMERIC dScopeId;
  53. BOOL bExists;
  54. } STRUCTOBJECTEXISTS;
  55. typedef struct STRUCTINSERTBLOB
  56. {
  57. DB_NUMERIC dClassId;
  58. DB_NUMERIC dObjectId;
  59. int iPropertyId;
  60. BYTE *pImage;
  61. int iPos;
  62. } STRUCTINSERTBLOB;
  63. typedef struct STRUCTINSERTPROPBATCH
  64. {
  65. DB_NUMERIC dObjectId;
  66. BSTR sObjectKey;
  67. BSTR sObjectPath;
  68. BSTR sCompKey;
  69. DB_NUMERIC dClassId;
  70. DB_NUMERIC dScopeId;
  71. int iInsertFlags;
  72. int iPropId[5];
  73. BSTR sPropValue[5];
  74. int iPos[5];
  75. BOOL bInit;
  76. } STRUCTINSERTPROPBATCH;
  77. typedef struct STRUCTINSERTBATCH
  78. {
  79. DB_NUMERIC dObjectId; // @ObjectId
  80. DB_NUMERIC dScopeId; // @ScopeID
  81. DB_NUMERIC dClassId; // @ClassID
  82. int iQfrId[5]; // @QfrId?
  83. BSTR sPropValue[5]; // @QfrValue?
  84. int iPos[5]; // @QfrPos?
  85. int iPropId[5]; // @PropID?
  86. int iFlavor[5]; // @Flavor?
  87. } STRUCTINSERTBATCH;
  88. class _declspec( dllexport ) COLEDBConnection : public CSQLConnection
  89. {
  90. friend class CSQLConnCache;
  91. public:
  92. COLEDBConnection (IDBInitialize *pDBInit);
  93. ~COLEDBConnection ();
  94. IDBInitialize * GetDBInitialize () {return m_pDBInit;};
  95. IDBCreateSession * GetSessionObj() {return m_pSession;};
  96. IDBCreateCommand * GetCommand() {return m_pCmd;};
  97. ICommandText * GetCommandText(DWORD type) {return (ICommandText * )m_ObjMgr.GetObject(SQL_POS_ICOMMANDTEXT|type);};
  98. ICommandWithParameters * GetCommandWithParams(DWORD type) {return (ICommandWithParameters * )m_ObjMgr.GetObject(SQL_POS_ICOMMANDWITHPARAMS|type);};
  99. IAccessor * GetIAccessor(DWORD type) {return (IAccessor * )m_ObjMgr.GetObject(SQL_POS_IACCESSOR|type);};
  100. HACCESSOR GetAccessor(DWORD type) {return (HACCESSOR )m_ObjMgr.GetObject(SQL_POS_HACCESSOR|type);};
  101. IRowset * GetRowset(DWORD type) {return (IRowset * )m_ObjMgr.GetObject(SQL_POS_IROWSET|type);};
  102. IOpenRowset * GetOpenRowset(DWORD type) {return (IOpenRowset * )m_ObjMgr.GetObject(SQL_POS_IOPENROWSET|type);};
  103. IRowsetChange * GetRowsetChange(DWORD type) {return (IRowsetChange * )m_ObjMgr.GetObject(SQL_POS_IROWSETCHANGE|type);};
  104. IRowsetIndex * GetRowsetIndex(DWORD type) {return (IRowsetIndex * )m_ObjMgr.GetObject(SQL_POS_IROWSETINDEX|type);};
  105. void SetCommandText (DWORD type, ICommandText *pNew) {m_ObjMgr.SetObject(SQL_POS_ICOMMANDTEXT|type, pNew);};
  106. void SetCommandWithParams (DWORD type, ICommandWithParameters *pNew) {m_ObjMgr.SetObject(SQL_POS_ICOMMANDWITHPARAMS|type, pNew);};
  107. void SetIAccessor (DWORD type, IAccessor *pNew) {m_ObjMgr.SetObject(SQL_POS_IACCESSOR|type, pNew);};
  108. void SetAccessor (DWORD type, HACCESSOR hNew) {m_ObjMgr.SetObject(SQL_POS_HACCESSOR|type, (void *)hNew);};
  109. void SetRowset(DWORD type, IRowset *pNew) {m_ObjMgr.SetObject(SQL_POS_IROWSET|type, pNew);};
  110. void SetOpenRowset(DWORD type, IOpenRowset *pNew) {m_ObjMgr.SetObject(SQL_POS_IOPENROWSET|type, pNew);};
  111. void SetRowsetChange (DWORD type, IRowsetChange *pNew) {m_ObjMgr.SetObject(SQL_POS_IROWSETCHANGE|type, pNew);};
  112. void SetRowsetIndex (DWORD type, IRowsetIndex *pNew) {m_ObjMgr.SetObject(SQL_POS_IROWSETINDEX|type, pNew);};
  113. void SetSessionObj (IDBCreateSession *pNew) {m_pSession = pNew;};
  114. void SetCommand (IDBCreateCommand *pNew)
  115. {
  116. if (m_pCmd)
  117. m_pCmd->Release();
  118. m_pCmd = pNew;
  119. pNew->AddRef();
  120. };
  121. private:
  122. time_t m_tCreateTime;
  123. IDBInitialize *m_pDBInit;
  124. bool m_bInUse;
  125. IDBCreateSession *m_pSession;
  126. IDBCreateCommand *m_pCmd;
  127. ITransaction *m_pTrans;
  128. CDBObjectManager m_ObjMgr;
  129. };
  130. #endif // _SQLUTILS_H_