Leaked source code of windows server 2003
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.

224 lines
7.2 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. MOFDATA.H
  5. Abstract:
  6. Defines MOF compiler classes related to complete MOF file representation
  7. and transfer of data into WinMgmt. Division of labor between these and
  8. the classes defined in MOFPROP.H/CPP is not clear-cut.
  9. History:
  10. 11/27/96 a-levn Compiles.
  11. --*/
  12. #ifndef _MCAUX_H_
  13. #define _MCAUX_H_
  14. #include <windows.h>
  15. #include <wbemidl.h>
  16. #include <miniafx.h>
  17. #include <mofprop.h>
  18. //******************************************************************************
  19. //******************************************************************************
  20. //
  21. // class CNamespaceCache
  22. //
  23. // Represents the cache of pointers to the various namespaces MOF compiler
  24. // has connection to.
  25. //
  26. //******************************************************************************
  27. //
  28. // Constructor.
  29. //
  30. // Constructs the cache given the IWbemLocator pointer to WinMgmt. This class will
  31. // use this pointer to connect to whatever namespace is required.
  32. //
  33. // PARAMETERS:
  34. //
  35. // ADDREF IWbemLocator* pLocator Locator pointer. This function AddRefs
  36. // it. It is Released in destructor.
  37. //
  38. //******************************************************************************
  39. //
  40. // Destructor
  41. //
  42. // Releases the locator pointer we were given in the constructor.
  43. // Releases all cached namespace pointers.
  44. //
  45. //******************************************************************************
  46. //
  47. // GetNamespace
  48. //
  49. // Retrieves a pointer to a given namespace. If in cache, the cached copy is
  50. // returned. If not, a new connection is established and cached.
  51. //
  52. // PARAMETERS:
  53. //
  54. // COPY LPCWSTR wszName Full name of the namespace to connect to.
  55. //
  56. // RETURN VALUES:
  57. //
  58. // IWbemServices*: NULL if an error occurs. If not NULL, the caller must
  59. // release this pointer when no longer necessary.
  60. //
  61. //******************************************************************************
  62. class CNamespaceCache
  63. {
  64. private:
  65. IWbemLocator* m_pLocator;
  66. struct CNamespaceRecord
  67. {
  68. LPWSTR m_wszName;
  69. IWbemServices* m_pNamespace;
  70. CNamespaceRecord(COPY LPCWSTR wszName, ADDREF IWbemServices* pNamespace);
  71. ~CNamespaceRecord();
  72. };
  73. CPtrArray m_aRecords; // CNamespaceRecord*
  74. public:
  75. CNamespaceCache(ADDREF IWbemLocator* pLocator);
  76. ~CNamespaceCache();
  77. RELEASE_ME IWbemServices* GetNamespace(COPY LPCWSTR wszName, SCODE & scRet,
  78. WCHAR * pUserName, WCHAR * pPassword,
  79. WCHAR * pAuthority,IWbemContext * pCtx,
  80. GUID LocatorGUID, LONG fConnectFlags);
  81. };
  82. //*****************************************************************************
  83. //*****************************************************************************
  84. //
  85. // class CMofData
  86. //
  87. // Represents an entire MOF file, basically --- a collection of objects. See
  88. // CMObject in mofprop.h for details of object representation.
  89. //
  90. // Capable of storing its data into WinMgmt.
  91. //
  92. //******************************************************************************
  93. //
  94. // AddObject
  95. //
  96. // Adds another object to the store.
  97. //
  98. // PARAMETERS:
  99. //
  100. // ACQUIRE CMObject* pObject The object to add. The class acquires this
  101. // object and will delete it on destruction.
  102. //
  103. //******************************************************************************
  104. //
  105. // GetNumObjects
  106. //
  107. // RETURN VALUES:
  108. //
  109. // int: the number of objects in the store.
  110. //
  111. //******************************************************************************
  112. //
  113. // GetObject
  114. //
  115. // Returns the object stored at a given index
  116. //
  117. // PARAMETERS:
  118. //
  119. // int nIndex The index to retrieve the object at.
  120. //
  121. // RETURN VALUES:
  122. //
  123. // CMObject*: NULL if nIndex is out of range. Otherwise, an INTERNAL
  124. // pointer which is NOT to be deleted by the caller.
  125. //
  126. //******************************************************************************
  127. //
  128. // Store
  129. //
  130. // Transfers all the data to WinMgmt.
  131. //
  132. // PARAMETERS:
  133. //
  134. // OLE_MODIFY IWbemLocator* pLocator WinMgmt locator pointer to store into.
  135. // long lClassFlags WBEM_FLAG_CREATE_OR_UPATE,
  136. // WBEM_FLAG_CREAYE_ONLY, or
  137. // WBEM_FLAG_UPDATE_ONLY to apply to
  138. // class operations.
  139. // long lInstanceFlags Same as lClassFlags, but for
  140. // instance operations.
  141. // BOOL bRollBackable Not implemented. Must be TRUE.
  142. //
  143. class CMofParser;
  144. class CMofData : private CMofAliasCollection
  145. {
  146. private:
  147. CPtrArray m_aObjects; // CMObject*
  148. CPtrArray m_aQualDefaults; // CMoQualifier*
  149. BYTE * m_pBmofData;
  150. BYTE * m_pBmofToFar;
  151. HRESULT RollBack(int nObjects);
  152. INTERNAL LPCWSTR FindAliasee(READ_ONLY LPWSTR wszAlias);
  153. friend CMObject;
  154. PDBG m_pDbg;
  155. BOOL GotLineNumber(int nIndex);
  156. void PrintError(int nIndex, long lMsgNum, HRESULT hres, WBEM_COMPILE_STATUS_INFO *pInfo);
  157. public:
  158. void SetBmofBuff(BYTE * pData){m_pBmofData = pData;};
  159. BYTE * GetBmofBuff(){return m_pBmofData;};
  160. void SetBmofToFar(BYTE * pData){m_pBmofToFar = pData;};
  161. BYTE * GetBmofToFar(){return m_pBmofToFar;};
  162. BOOL CMofData::IsAliasInUse(READ_ONLY LPWSTR wszAlias);
  163. void AddObject(ACQUIRE CMObject* pObject) {m_aObjects.Add(pObject);}
  164. int GetNumObjects() {return m_aObjects.GetSize();}
  165. CPtrArray * GetObjArrayPtr(){return &m_aObjects;};
  166. INTERNAL CMObject* GetObject(int nIndex)
  167. {return (CMObject*)m_aObjects[nIndex];}
  168. void SetQualifierDefault(ACQUIRE CMoQualifier* pDefault);
  169. HRESULT SetDefaultFlavor(MODIFY CMoQualifier& Qual, bool bTopLevel, QUALSCOPE qs, PARSESTATE ps);
  170. int GetNumDefaultQuals(){return m_aQualDefaults.GetSize();};
  171. CMoQualifier* GetDefaultQual(int nIndex){return (CMoQualifier*)m_aQualDefaults.GetAt(nIndex);};
  172. CMofData(PDBG pDbg){m_pDbg = pDbg;};
  173. ~CMofData()
  174. {
  175. int i;
  176. for(i = 0; i < m_aObjects.GetSize(); i++)
  177. delete (CMObject*)m_aObjects[i];
  178. for(i = 0; i < m_aQualDefaults.GetSize(); i++)
  179. delete (CMoQualifier*)m_aQualDefaults[i];
  180. }
  181. HRESULT Store(CMofParser & Parser, OLE_MODIFY IWbemLocator* pLocator, IWbemServices *pOverride,
  182. BOOL bRollBackable, WCHAR * pUserName, WCHAR * pPassword, WCHAR *pAuthority,
  183. IWbemContext * pCtx, GUID LocatorGUID,
  184. WBEM_COMPILE_STATUS_INFO *pInfo,
  185. BOOL bClassOwnerUpdate,
  186. BOOL bInstanceOwnerUpdate,
  187. LONG fConnectFlags);
  188. HRESULT Split(CMofParser & Parser, LPWSTR BMOFFileName, WBEM_COMPILE_STATUS_INFO *pInfo, BOOL bUnicode,
  189. BOOL bAutoRecovery,LPWSTR pwszAmendment);
  190. void RecursiveSetAmended(CMObject * pObj);
  191. };
  192. #endif