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.

161 lines
6.9 KiB

  1. //******************************************************************************
  2. //
  3. // ANALYSER.H
  4. //
  5. // Copyright (C) 1996-1999 Microsoft Corporation
  6. //
  7. //******************************************************************************
  8. #ifndef __WBEM_ANALYSER__H_
  9. #define __WBEM_ANALYSER__H_
  10. #include "esscpol.h"
  11. #include <stdio.h>
  12. #include "wbemidl.h"
  13. #include "wbemcomn.h"
  14. #include "parmdefs.h"
  15. #include "ql.h"
  16. #include "eventrep.h"
  17. #include "evaltree.h"
  18. struct ESSCLI_POLARITY CClassInformation
  19. {
  20. IWbemClassObject* m_pClass;
  21. LPWSTR m_wszClassName;
  22. BOOL m_bIncludeChildren;
  23. DWORD m_dwEventMask;
  24. public:
  25. CClassInformation()
  26. {
  27. m_wszClassName = NULL;
  28. m_pClass = NULL;
  29. }
  30. CClassInformation(const CClassInformation& Other)
  31. {
  32. m_wszClassName = CloneWstr(Other.m_wszClassName);
  33. if (!m_wszClassName)
  34. throw CX_MemoryException();
  35. m_pClass = Other.m_pClass;
  36. if(m_pClass) m_pClass->AddRef();
  37. m_bIncludeChildren = Other.m_bIncludeChildren;
  38. m_dwEventMask = Other.m_dwEventMask;
  39. }
  40. ~CClassInformation()
  41. {
  42. delete [] m_wszClassName;
  43. if(m_pClass) m_pClass->Release();
  44. }
  45. };
  46. class ESSCLI_POLARITY CClassInfoArray
  47. {
  48. protected:
  49. BOOL m_bLimited;
  50. CUniquePointerArray<CClassInformation>* m_pClasses;
  51. public:
  52. CClassInfoArray();
  53. ~CClassInfoArray();
  54. BOOL IsLimited() {return m_bLimited;}
  55. int GetNumClasses() {return m_pClasses->GetSize();}
  56. INTERNAL CClassInformation* GetClass(int nIndex)
  57. {return (*m_pClasses)[nIndex]; }
  58. void SetLimited(BOOL bLimited) {m_bLimited = bLimited;}
  59. bool operator=(CClassInfoArray& Other);
  60. bool SetOne(LPCWSTR wszClass, BOOL bIncludeChildren);
  61. void Clear() {m_bLimited = FALSE; m_pClasses->RemoveAll();}
  62. bool AddClass(ACQUIRE CClassInformation* pInfo)
  63. {return m_pClasses->Add(pInfo) >= 0;}
  64. void RemoveClass(int nIndex) {m_pClasses->RemoveAt(nIndex);}
  65. };
  66. class ESSCLI_POLARITY CQueryAnalyser
  67. {
  68. public:
  69. static HRESULT GetPossibleInstanceClasses(QL_LEVEL_1_RPN_EXPRESSION* pExpr,
  70. CClassInfoArray*& paInfos);
  71. static HRESULT GetDefiniteInstanceClasses(QL_LEVEL_1_RPN_EXPRESSION* pExpr,
  72. CClassInfoArray*& paInfos);
  73. static HRESULT GetLimitingQueryForInstanceClass(
  74. IN QL_LEVEL_1_RPN_EXPRESSION* pExpr,
  75. IN CClassInformation& Info,
  76. OUT LPWSTR& wszQuery);
  77. static HRESULT GetNecessaryQueryForProperty(
  78. IN QL_LEVEL_1_RPN_EXPRESSION* pExpr,
  79. IN CPropertyName& PropName,
  80. DELETE_ME QL_LEVEL_1_RPN_EXPRESSION*& pNewExpr);
  81. static HRESULT GetNecessaryQueryForClass(
  82. IN QL_LEVEL_1_RPN_EXPRESSION* pExpr,
  83. IWbemClassObject* pClass,
  84. CWStringArray& awsOverriden,
  85. DELETE_ME QL_LEVEL_1_RPN_EXPRESSION*& pNewExpr);
  86. static BOOL CompareRequestedToProvided(
  87. CClassInfoArray& aRequestedInstanceClasses,
  88. CClassInfoArray& aProvidedInstanceClasses);
  89. static HRESULT SimplifyQueryForChild(
  90. IN QL_LEVEL_1_RPN_EXPRESSION* pExpr,
  91. LPCWSTR wszClassName, IWbemClassObject* pClass,
  92. CContextMetaData* pMeta,
  93. DELETE_ME QL_LEVEL_1_RPN_EXPRESSION*& pNewExpr);
  94. static HRESULT CanPointToClass(IWbemClassObject* pRefClass,
  95. LPCWSTR wszPropName, LPCWSTR wszTargetClassName,
  96. CContextMetaData* pMeta);
  97. protected:
  98. enum
  99. {
  100. e_Keep, e_True, e_False, e_Invalid
  101. };
  102. static HRESULT GetInstanceClasses(QL_LEVEL_1_TOKEN& Token,
  103. CClassInfoArray& aInfos);
  104. static HRESULT AndPossibleClassArrays(IN CClassInfoArray* paFirst,
  105. IN CClassInfoArray* paSecond,
  106. OUT CClassInfoArray* paNew);
  107. static HRESULT OrPossibleClassArrays(IN CClassInfoArray* paFirst,
  108. IN CClassInfoArray* paSecond,
  109. OUT CClassInfoArray* paNew);
  110. static HRESULT NegatePossibleClassArray(IN CClassInfoArray* paOrig,
  111. OUT CClassInfoArray* paNew);
  112. static HRESULT AndDefiniteClassArrays(IN CClassInfoArray* paFirst,
  113. IN CClassInfoArray* paSecond,
  114. OUT CClassInfoArray* paNew);
  115. static HRESULT OrDefiniteClassArrays(IN CClassInfoArray* paFirst,
  116. IN CClassInfoArray* paSecond,
  117. OUT CClassInfoArray* paNew);
  118. static HRESULT NegateDefiniteClassArray(IN CClassInfoArray* paOrig,
  119. OUT CClassInfoArray* paNew);
  120. static BOOL IsTokenAboutProperty(
  121. IN QL_LEVEL_1_TOKEN& Token,
  122. IN CPropertyName& PropName);
  123. static void AppendQueryExpression(
  124. IN QL_LEVEL_1_RPN_EXPRESSION* pDest,
  125. IN QL_LEVEL_1_RPN_EXPRESSION* pSource);
  126. static HRESULT AndQueryExpressions(
  127. IN QL_LEVEL_1_RPN_EXPRESSION* pFirst,
  128. IN QL_LEVEL_1_RPN_EXPRESSION* pSecond,
  129. OUT QL_LEVEL_1_RPN_EXPRESSION* pNew);
  130. static HRESULT OrQueryExpressions(
  131. IN QL_LEVEL_1_RPN_EXPRESSION* pFirst,
  132. IN QL_LEVEL_1_RPN_EXPRESSION* pSecond,
  133. OUT QL_LEVEL_1_RPN_EXPRESSION* pNew);
  134. static HRESULT NegateQueryExpression(
  135. IN QL_LEVEL_1_RPN_EXPRESSION* pExpr,
  136. OUT QL_LEVEL_1_RPN_EXPRESSION* pNewExpr);
  137. static int SimplifyTokenForChild(QL_LEVEL_1_TOKEN& Token,
  138. LPCWSTR wszClass, IWbemClassObject* pClass,
  139. CContextMetaData* pMeta);
  140. static BOOL ValidateSQLDateTime(LPCWSTR wszDateTime);
  141. static HRESULT GetPropertiesThatMustDiffer(
  142. IN QL_LEVEL_1_RPN_EXPRESSION* pExpr,
  143. IN CClassInformation& Info,
  144. CWStringArray& wsProperties);
  145. static BOOL IsTokenAboutClass(QL_LEVEL_1_TOKEN& Token,
  146. IWbemClassObject* pClass,
  147. CWStringArray& awsOverriden);
  148. static BOOL IsPropertyInClass(CPropertyName& Prop,
  149. IWbemClassObject* pClass,
  150. CWStringArray& awsOverriden);
  151. };
  152. #endif